Track Redirects in Analytics - How to Track a Redirect in Analytics
One of the problems people run into is their inability to track redirects in Google Analytics. For example, let’s say you purchase radio or print ads in order to advertise a product. Rather than simply advertising your domain name (ie (www.yourdomain.com), you may add an easy to remember folder name (ie. www.yourdomain.com/adpage), which redirects to the appropriate product page (which is probably too long and complicated to display on a radio, TV, or print ad).
Depending on the type of redirect you use, Analytics may not be able to track visits and user behavior. Fortunately, there are at least 2 ways you can track redirects. In both instances, you have to make sure the directory actually exists as a file (ie. /adpage/index.php). The difference lies in the type of redirect you use. If you use a 301 redirect, you’ll want to add campaign tracking to the url you are redirecting to, so Analytics can track visits as a campaign. The other option is to use a standard javascript redirect, and add the Analytics tracking to the redirecting page (ie. /adpage/index.php). This way, you can track visits and user behavior in the Analytics Content section.
Let’s say you are advertising the following page via radio ads:
www.yourdomain.com/adpage
This page actually redirects to the page below
www.yourdomain.com/long-url-product-page.php
Here are two ways you can track visits and user behavior for people landing on www.yourdomain.com/adpage.
1- Tracking a redirect using a 301 redirect:
Add campaign tracking to your forwarding page. So, on this page:
www.yourdomain.com/adpage/index.php
Rather than 301 redirecting to:
www.yourdomain.com/product-page.php
The 301 redirect should actually redirect to:
www.yourdomain.com/product-page.php?utm_source=yoursource&utm_medium=yourmedium&utm_campaign=yourcampaign
You will then be able to track the number of times www.yourdomain.com/adpage was visited by looking at your new Campaign (under Traffic Sources) metrics.
2- Tracking a redirect using a javascript redirect:
Make sure your analytics tracking is on your redirecting page, before the script to run your redirect. So on this page:
www.yourdomain.com/adpage/index.php
Make sure your analytics tracking code appears before your redirect runs. You will then be able to track the number of times www.yourdomain.com/adpage/index.php was visited by looking at your Top Content or Top Landing Pages (under Traffic Sources).
*** This method only works efficiently if you implement a time delay in the JavaScript redirect. Otherwise, the Analytics script won’t always finish running before the page redirects, and your Analytics reports won’t capture every redirect. Read more on this related post: Update on Tracking JavaScript Redirects
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
Chris, thanks so much for answering my questions. I have gone through your post titled “Track Redirects in Analytics - How to Track a Redirect in Analytics”. It raised up other questions for me. The outbound link that leads a visitor to leave my site isn’t really an outbound link in the sense that it is actually a php file on my website with a header redirect which only contains my affiliate link. Assuming that the affiliate network has my tracking pixel set up:
1. Will EventTracking still be working fine in this case so that conversion (sale) can be tracked properly and viewed in my GA account?
2. How should the outbound link look like in the above-mentioned situation in which the link isn’t a “real” outbound link? Is it something like this:
3. Should the redirect php file contain any GA code in order to make EventTracking work?
Thanks,
Chee
Sorry, I think comment was converted into rich text format. Here is the code for question #2 again:
<a href=”http://www.mysite.com/offers/offer-name.php” onClick=”javascript: pageTracker._trackPageview(’http://www.mysite.com/eventtracking/external/offer-name’);”
Thanks,
Chee
[...] Re: tinyurl .. no more! Hi Cindy, This may help: Track Redirects in Analytics - How to Track a Redirect in Analytics (Javascript & 301 Redirects) [...]
Hi,
i tried doing the javascript redirect and the google analytics, but the tracking has not been consistent (out of 8 tests, only 4 got tracked). It looks as if the time it takes for the script to contact google analytics is too slow so the redirect javascript does the redirect before the hit is recorded on google.
_uacct = “UA-5*****-*”;
urchinTracker();
i pasted what i have on the redirect page.
is there anything i can do to keep the redirect tracking consistent?
Thanks
i noticed the entire paste did not display.
after the google analytics script, i have a second script, which is the javascript redirect.
window.location = “http://www.website.com”
they are both in their own script tags with the GA script before and the redirect after.
thanks
jc
[...] 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 [...]
Great post here. Thanks for sharing. One question though.
I am using a vanity url in an email campaign that looks like this: http://www.mysite.com/joinme?utm_source=google&utm_medium=cpc&utm_campaign=Content
This vanity url redirects to this page: http://www.mysite.com/register.jsp
The problem is, when someone clicks on the vanity url and goes to http://www.mysite.com/register.jsp, none of the UTM tags in the tagged vanity url are present. They’re missing, so nothing is getting tracked. All I see in the address field is http://www.mysite.com/register.jsp.
Also, if this same vanity URL is being used on my Web site, will the UTM tags appear in the URL if someone clicks on the link from the Web site?
What do I do?
Thanks.
I just made a post about how to do this.
http://petermoorman.com/how-to-track-java-script-redirects-through-google-analtics
Great post. I would strongly recommend against using the campaign parameters and instead set the custom variable to identify redirects. Using campaign variables means that you may not be able to track search, email, display, social, etc. campaigns that are sending traffic to the original (redirect FROM) page.
Hopefully some info on a new post I have helps:



Hi Chris, thanks for your interesting post. I have the following questions which I hope you can help me out with:
1. How do I track which outbound links (anchor text link, image link etc.) on my exit page leads the visitor to leave my site?
2. So far I have only used GA to track the number of visitors to my site. Now I would like to track the number of conversions (sales of affiliate offers) using GA. How is the conversion tracking possible when I can’t place the GA codes on the success page of the affiliate offer?
3. This is somewhat related to question #2. I use a header redirect in for example /offer-name.php to redirect the visitor to the offer. Is javascript redirect as you mentioned in your post the better way to track conversion, if tracking affiliate offer as described in question #2 is possible at all?
Thanks,
Chee