views:

199

answers:

2

Whenever a user visits "Page A" on my site, I immediately redirect him to "Page B" by setting window.location with Javascript. "Page A" has no Google Analytics tracking on it -- when someone is redirected from "Page A" to "Page B" I want to track him as if he entered the site via "Page B". Unfortunately, my current setup breaks referrer information since people who are redirected to "Page B" appear to Google Analytics as if they came from "Page A":

alt text

After users are redirected to "Page B", I want to tell Google Analytics their "real" referrer (i.e., the referrer to "Page A"). How can I do this?

(Note: I realize that using a real HTTP redirect instead of a Javascript-based redirect would solve this problem. Unfortunately this isn't an option)

+2  A: 

Why are you not using a proper HTTP redirect?

It is the right way to redirect users, and it will not break Google Analytics.

Barring this option, I'm not sure you can use a JS redirect and maintain proper GA behavior. The browser decides which URL to send as the referrer, and this is not something you can control.

Actually, you can try to use the ?utm_nooverride=1 parameter. It's a long shot, but it just might work.

Yuval A
@Horace: Unfortunately I believe Yuval is correct. There's no way to do this without using a proper HTTP redirect. Maybe your question should be about how to get around whatever is preventing you from using a real redirect...
Josh
What about manually tracking the page view with `_trackPageView`? Is there no way to specify a referrer that way?
David Murdoch
+1  A: 

The solution described in this blog post seems to work -- I added this to "Page A":

<script type="text/javascript"> 
  var pageTracker = _gat._getTracker("UA-xxxxxx-11");
  pageTracker._initData();
</script>

Which seems to capture the initial referrer without recording duplicate pageviews

Horace Loeb