Update on Tracking JavaScript Redirects
In a previous post (Track Redirects in Analytics), I gave a couple of examples on how you can track redirects using Google Analytics. One of these methods was to implement a JavaScript redirect after you run your Google Analytics tracking JavaScript. This way the redirect runs after the page has tracked a visit (and the visit will show up in your Content section in Analytics).
Someone pointed out that, having tried this, they noticed that not every redirect was tracking, and that it was likely that the page was sometimes redirecting before the Analytics JavaScript was being completely run. So I decided to run a test with the help of some co-workers.
Testing with a Delay
We created two JavaScript redirect pages with the Analytics tracking running before the redirect. However, one of the pages had a time delay of one second. 8 of us visited both redirecting URLs. Sure enough, the page with the one second delay showed 8 visitors. The page with no delay showed 4. So half of the visitors weren’t tracked when no delay being implemented. So it would appear that a redirect with no time delay doesn’t always allow for enough time for the Analytics tracking to run.
The lesson here is; if you’re going with the JavaScript redirect option, you’ll want to use a one second delay in order to track visitors correctly.

Related Posts:
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Comments
Hi there
Thanks a lot for this post!
I was trying to track traffic on a redirecting page. I tried it with a php-redirect after the analytics tracking code, adding a delay. Still, i could not find any data in the analytics’ content section.
I’m currently trying to do the redirect with a java script as described in your post. However, since there is no code-example in this post, here is what i wrote (placed beneath the GA-tracking code):
window.setTimeout (’redirect_to (”http://www.mylandingpage.com”)’, 3000);
function redirect_to (destination) {
window.location.href = destination;
}
Should this work or what would you suggest?
Thank you very much!



[...] and your Analytics reports won’t capture every redirect. Read more on this related post: Update on Tracking JavaScript Redirects Google Analytics [...]