Why is my own site listed as a referrer?

Here are two reasons why our JavaScript may pick up your own site as a Referrer.

1. Is the Kissmetrics JavaScript on all of your pages?

Let’s say you have a setup that looks like this:

🚧

Is the JavaScript snippet on landing.mysite.com?

If it is, then our script will capture as Referrer the last page a visitor was on – the [internet page]. This is correct and what you’re interested in.

Suppose our JS is not on landing.mysite.com, but is only on www.mysite.com. The script will then capture as Referrer the last page a visitor was on – landing.mysite.com. This is not useful for you.

2. Is your browser redirected when entering your site?

Let’s say you have a setup that looks like this:

That is, typing in www.mysite.com actually redirects you to the /splash page. There are two types of redirects…to the user, they do the same thing, but to the browser, there are differences.

I. JavaScript-based Redirect (problematic)

On http://www.mysite.com/, there is a small bit of JavaScript that handles the redirect.

<script type="text/javascript">
// This is code on http://www.mysite.com/
document.location = "http://www.mysite.com/splash.php";
</script>

Because the browser loads http://www.mysite.com/ ever so briefly, the browser progresses through pages like this:

The Kissmetrics script is located on the /splash.php page. When we check for the Referrer, we see that the last page visited was http://www.mysite.com; the info about the [internet page] is lost during the redirect.

II. Location Header (non-JavaScript)

Location Header redirects are done via server-side software, like in Ruby or PHP. This is the more typical way to redirect users.

With this method, the browser reads the headers before rendering the page, so that it knows to go to the next page without counting the visit to www.mysite.com as a “hit”.

<?php
// This is code on http://www.mysite.com/
header("Location: http://www.mysite.com/splash.php");
?>

The progression then looks like this:

Again, the Kissmetrics script is located on the /splash.php page. So when we check for the Referrer, we see that the last page visited was [internet page], ignoring the fact we got redirected from www.mysite.com.