How Does Google Analytics handle 301 and 302 Redirects?

I’ve seen this question a zillion times, so please link the hell out of this so it shows up in search results and helps people (Matt Cutts, please ignore the previous statement, I’m just trying to help people). I also posted this at the Google Analytics help forums and will do a post on Search Engine Land next week, so hopefully one of these will rank and the world will be a happier place.

ONCE AND FOR ALL! LET’S DO THIS! :)

Google Analytics will report the ORIGINAL referrer to the ORIGINAL requested page if a server-side 301 (or 302) redirect is in place.

Let’s shake out an example.

You own mySite.com and have a page called unicorns.html. You decide that you want to make a better page for this, so you make “DOUBLE-unicorns.html”.

Then you realize that you want to remove the original unicorns.html because it is lame compared to your double unicorns page, but you want to make sure that people who linked to that old page see the new, awesome double unicorns page. Because you’re a good, SEO-conscious person, you do a 301 redirect from “/unicorns.html” to “http://www.mySite.com/DOUBLE-unicorns.html”.

OK, breathe…here we go.

Let’s say that the site unicornUniverse.com loved your original page, and had a link on it. Now that your 301 redirect is present, what happens when someone clicks on that link at unicornUniverse.com? What shows up as a referrer?

Yes: unicornUniverse.com is the referrer! And what is your landing page? DOUBLE-unicorns.html is your landing page.

This happens because the browser never actually sees the first file: the server redirects your browser and the field of the DOM that monitors your referrer isn’t updated. This field is referred to by the document.referrer variable, and a quick cheat to check what’s in it is to type the following in your location bar:

javascript:alert(document.referrer);

If you’re a browser ninja, you might have firebug installed, and you can look at the DOM map there to see the same thing.

Let’s take another example:

What if someone searches for “super awesome unicorn page” on Google, just MINUTES after you put your redirect up? Well, Google hasn’t had time to find your redirect and update the URL in their index! OH MY! What will happen?

All is well in the world (almost, see the last paragraph below for what’s not well in the world), because when someone clicks the link to http://www.mySite.com/unicorns.html in the Google search results, they will be 301 redirected to http://www.mySite.com/DOUBLE-unicorns.html. Referrer? google.com (the document.referrer will actually read: http://www.google.com/search?q=super+awesome+unicorn+page — that is how it knows your search engine keywords). And again, DOUBLE-unicorns.html will be the landing page.

So, direct is direct, search is search, referred is referred.

Exceptions:

There are times when a 301 redirect will NOT preserve referrer information, but they are rare. The most common example is when an https page links through a redirect on a non-https page. Again, drop the javascript above into your browser to audit this on your own site if this is a concern. If that script tells you the right referrer information, Google Analytics will be cool as a cucumber.

Also, if you’re trying to do a 301 that isn’t of the server-side variety (I’ve seen some people try to state 301 in HTML or through a JavaScript redirect — don’t ask), you will definitely have problems.

Google’s documentation on this refers to javascript and tracking redirects, and is MISLEADING. It is technically correct, but it is NOT talking about server-side 301/302 redirects. In the isolated case it refers to (which isn’t well explained), it is right.

Lastly, webkit-based browsers (Chrome and Safari among them) have a known problem with opening content in new tabs and windows. If a user right-clicks a link and selects Open in a New Window or Open in a New Tab, referrer data is LOST! MIND BLOWN! But if they simply hold CTRL or command (on a mac) while they click to launch in a new tab, referrer data is preserved. DOUBLE BLOWN!

KEEP IN MIND:

If you are using 301 redirects, make sure they preserve your tracking parameters (utm_source, etc., at the end of your destination URL). Commonly, parameters that may specify display, email, or paid search campaigns may be stripped. What happens here? The URL of the referring site becomes a referrer and your campaign information is lost.

For example:

1) Your email that someone reads on Gmail should be counted as source:”email” medium:”email” campaign:”super email campaign”

if you forget to keep your URL parameters, instead of this visit being attributed to the email campaign, it will count as a referral from google.com! WHAT?!? Yes!

2) You are running a paid search campaign and have the keyword “unicorn site.” You expect source:”google” medium:”cpc” campaign:”generic unicorn terms”

if you forget to keep your URL parameters, instead of the paid search campaign being recorded, this visit will be attributed to NON-PAID search!!! Holy shnikeys!

The last thing to keep in mind is that before 301 destination pages replace your original pages in search engines (or if you use 302 redirects, and the URLs are not replaced in that case), your actual link URL from the engines and your Entry Page will NOT be the same! In the example above, Google linked to http://www.mySite.com/unicorns.html, but the entry page was DOUBLE-unicorns.html. If you’re trying to compare traffic to entry pages with your ranking reports (tisk tisk for running ranking reports!), they will not mesh up if you marry them by URL!

Good luck!


4 Trackbacks

  1. [...] confusion around how analytics tools will react to these changes. I wrote a comprehensive guide to how Google Analytics and Omniture SiteCatalyst treat 301 (and 302) redirects, so if that’s something you’ve been trying to work out, please go take a look and fire [...]

  2. [...] How Does Google Analytics handle 301 and 302 Redirects? [...]

  3. [...] How Does Google Analytics handle 301 and 302 Redirects? Tweet This entry was posted in Webstatistik. Bookmark the permalink. ← Don’t bullshit artiklen af Peter Svarre Flere social medie eksperter, end der er børn i folkeskolen → [...]

  4. [...] Fantastic post by Evan LaPointe: [...]

74 Comments

  1. Oh, and for you Omniture people out there, OMTR handles redirects EXACTLY the same way. Some of their documentation is pure crap. Leave a comment here so I can email you the details and links in their help center if you’d like them.

    Posted May 6, 2010 at 6:30 pm | Permalink
  2. Evan – very mind-blowing indeed about tracking being lost with the right click/new tab action in Chrome.

    I get the part about utm tags on email and cpc for Bing, Yahoo, Amazon, etc. BUT, I’ve recently removed utm tags on my Google AdWords urls because the “auto-tagging” feature is required to accurately import AdWords click and cost data into Analytics.

    Can you address the role Google’s “auto-tagging” plays in the 301 redirect process? Also, will the utm_nooverride=1 tag preserve the original campaign in the event of a redirect?

    Posted May 16, 2010 at 7:30 am | Permalink
  3. Barb,

    Great question.

    For adwords autotagging, you’ll just have to be sure that you preserve the parameter named “gclid.” this is what autotagging uses to identify itself to google analytics.

    As for nooverride, that will behave just like it normally would, as if the redirect were not even there.

    Posted May 16, 2010 at 5:54 pm | Permalink
  4. Hey Evan, I have a client who is having a problem with a mix of 301 and 302 redirects on the same page which is causing Google Analytics to report most of the traffic on the site as referral from a sub-domain. Can you help out? If so, I’ll send you a doc that explains the problem. Please respond to my email address. Thanks.

    Ken

    Posted May 26, 2010 at 3:09 pm | Permalink
  5. Just when I thought unicorns were perfect as they are, you announce DOUBLE unicorns! Can the world get any better? ;-)’

    Anyways, interesting post. I was actually looking for information on how referal traffic from the beta httpS Google would show up in Analytics (would it be under “other”?). But stumbled onto this article. Never gave the 301/302 issue on Analytics much thought before, but it is interesting, and a nice little piece of info to know :)

    Posted June 2, 2010 at 5:30 pm | Permalink
  6. Yep, until you know about double unicorns…ignorance is bliss.

    Not sure if you saw my other post about Google https. It should all count as direct, unless it’s paid search, which will still be paid search if your GCLID/utm parameters persist…

    Posted June 2, 2010 at 6:36 pm | Permalink
  7. Here’s a related question:

    I want a redirect from one domain to another to the show original domain as a referrer. What’s the best way to set that up?

    Posted August 27, 2010 at 6:18 pm | Permalink
  8. Hi

    How can you check to see if things are set up wrong, and how can I check how things are set up wrong.

    On this page http://www.sdu.dk/ing is a 302 redirect to http://www.sdu.dk/om_sdu/fakulteterne/teknik/uddannelse.aspx .

    But how can I know if GA is registering traffic to http://www.sdu.dk/ing ?

    Hope you can help me, thanks in advance.

    Best regards
    Mads Gorm Larsen

    Posted August 28, 2010 at 8:33 am | Permalink
  9. There isn’t any traffic to /ing… that page never loads. A 302 redirect prevents the original page from ever loading. So GA can’t track that page.

    Are you interested in knowing how many of the pageviews on /om_sdu…. originally came from /ing? If so, you can change your 302 redirect rule to add a parameter like ?camefrom=ing. Then you can set a custom variable or look at pageviews for the page with that parameter.

    Your original referrer information is being preserved. For example, if you go to http://bit.ly/8XTc6H and click the link to /ing, you can look at the DOM or type “javascript:alert(document.referrer);” in your location bar to see that Google referred the visit.

    Does that answer your question?

    Posted August 30, 2010 at 9:44 am | Permalink
  10. @John,

    If you’re using a server-side redirect, it will always pass the original referrer, even if you cross domains. One of the big exceptions is if any of the redirects go through https. Nothing can be done about that, except appending the original referrer as a URL parameter and capturing that into the campaign variables or setting a custom variable.

    Here’s a test I set up.

    1. Go to http://www.feedthehead.com/301test.html
    2. This link points to the evanlapointe.com domain
    3. It is 301 redirected to cnn.com
    4. Look at your referrer once you get to cnn.com – it’ll be feedthehead.com, not evanlapointe.com

    Great success!

    Posted August 30, 2010 at 9:53 am | Permalink
  11. Very interesting information, and I appreciate the lighter side of your writing!

    I established 301 redirects for 5 pages 2 months ago, and GA is reporting 4 of the 5 as being referred by my site itself; only one is shown to be referred by Google. I’m considering completely re-designing the site (you’ll see why if you visit), and if/when I do, I would use 301s to redirect to all of the new pages. I used the initial 5 pages as a test to see how it would affect SEO and reporting. No problems with SEO, big problems with reporting.

    Any thoughts?

    Posted January 2, 2011 at 12:11 pm | Permalink
  12. Jacquie,

    Can you give me an example of some of the pages you 301 redirected?

    Posted January 3, 2011 at 11:27 am | Permalink
  13. I’d like to post my reply to your question, Evan, but my response just isn’t posting. I’ve tried 3 times… I doubt this post will make it, but I keep trying…

    Posted January 4, 2011 at 11:19 am | Permalink
  14. OK, last post made it, but when I paste my response here, it doesn’t work. It must be due to the “http” references? I’ll remove them all and try again:

    Thanks Evan —

    From: farmgifts.us/FarmAnimalGifts/Chickens/ChickenTshirts.html
    To: farmgifts.us/FarmAnimalGifts/Chickens/ChickenTshirts.php

    From: farmgifts.us/FarmAnimalGifts/Cows/CowTshirts.html
    To: farmgifts.us/FarmAnimalGifts/Cows/CowTshirts.php

    From: farmgifts.us/FarmAnimalGifts/Horses/HorseTshirts.html
    To: farmgifts.us/FarmAnimalGifts/Horses/HorseTshirts.php

    from: farmgifts.us/FarmAnimalGifts/Pigs/PigTshirts.html
    To: farmgifts.us/FarmAnimalGifts/Pigs/PigTshirts.php

    From: farmgifts.us/FarmAnimalGifts/Sheep/SheepTShirts.html
    To: farmgifts.us/FarmAnimalGifts/Sheep/SheepTShirts.php

    Here’s a screenshot showing the GA traffic report for the past 30 days:
    http://www.tractorama.us/images/RedirectTrafficSources.gif

    The pig tshirt page source comes from Google, so that seems to be working. But the cow, horse, sheep and chicken pages show FarmGifts.us as the source.

    Thank you.

    Posted January 4, 2011 at 11:21 am | Permalink
  15. Jacquie,

    It looks to me like these redirects are working fine. I am getting good referral data in the DOM, so the problem may be slow or missing analytics code on another page of your site that has a link to these pages. Instead of looking at referring domain or source, take a look instead at the actual referral path and it’ll tell you which pages on your own domain are referring traffic to itself.

    Posted January 4, 2011 at 3:58 pm | Permalink
  16. Here’s a demo page I set up for you to take a look:

    http://atlantaanalytics.com/farmgifts-test/farmgifts-link-test.html

    Click through on those links and then check document.referrer. All systems go. The culprit is likely your own site and missing analytics code or slow page load time, allowing a user to navigate to a new page before analytics fired on the previous page.

    Posted January 4, 2011 at 4:07 pm | Permalink
  17. Very interesting. I use a template for each page, so the same GA code is on every page. I’ll check out your demo, and follow your suggestions here. Thank you, I really appreciate the guidance!

    Posted January 4, 2011 at 5:43 pm | Permalink
  18. I don’t know how to check document.referrer. I see you instruct @John to check the referrer at cnn.com, too, but I don’t know what this means! Tried a Google search on the term, but came up empty handed! Thanks.

    Posted January 8, 2011 at 9:51 pm | Permalink
  19. One simple way will be to type “javascript:alert(document.referrer);” into your location bar and hit enter. You’ll get a pop up window that tells you the value. Make a bookmark and you’ll have it handy for future use!

    Posted January 10, 2011 at 10:34 am | Permalink
  20. @evanlapointe:
    OK, I think I’m getting it now. I see this is a means to test the referring page/source. This approach is new to me. I really appreciate the instruction!

    Posted January 10, 2011 at 7:49 pm | Permalink
  21. Thanks a ton, saved me hours. Especially the javascript:alert(document.referrer); trick is awesome :-)

    Posted March 21, 2011 at 8:21 am | Permalink
  22. Chris

    Ditto here. The Javascript alert tip is a keeper. Thanks for the good info. Clears up some confusion for me.

    Posted April 30, 2011 at 11:50 am | Permalink
  23. Joe Robison

    So my yacht website has a banner ad on a weather site. When users click on the banner it takes them to our yacht website homepage but the back of the homepage url has tracking parameters (/?utm_source=weathersite&utm_medium=banner…etc) on it that shows the visit was referred by the banner ad. I want to capture this data in analytics and redirect the url with tracking parameters to our canonical url without tracking parameters. If I do this, will it still show the banner ad website as the referrer in google analytics, or will it show the url with tracking parameters as the referrer?

    Thanks for the help, amazing article!

    Posted May 4, 2011 at 7:11 pm | Permalink
  24. Joe,

    Is there any particular reason you’d like to do the redirect? Is it just so the user doesn’t see the parameters? If so, they won’t mind, and I’d just recommend keeping it simple.

    If it’s for another reason, let’s talk about the implications:
    If you do a 301 redirect and don’t preserve the utm parameters, you’re going to see referrals from the sites where your display ads are appearing. These will be classified under referrals, not as campaigns. So, if your banner shows up on someone’s blog, you’ll see superYachtBlog.com as a referrer, with no additional details.
    You have the option of using a javascript redirect or meta refresh on the landing page, instead. This would allow Google Analytics to trigger on the landing page and then quickly send the user to the next page, after a short delay. This would preserve the original campaign data and would accomplish what you want, but you’d have to add a delay to be sure analytics had enough time to fire. This isn’t a very elegant solution, but may accomplish what you’re looking to do.

    Hope this helps!

    Posted May 5, 2011 at 1:13 pm | Permalink
  25. Joe Robison

    @evanlapointe:

    Thanks Evan that does help a lot.

    The main reason is that we don’t want the user to bookmark or share the url with the tracking parameters because it would skew the data, but this might be getting to nit-picky.

    We do want to preserve the tracking parameters for the campaign so that we have the banner ad listed under campaigns. Those are two good options, but I think we will just leave it be as you recommended, and just implement a rel=canonical to prevent duplicate content. Thanks for your help!

    Posted May 5, 2011 at 6:36 pm | Permalink
  26. Happy to help.

    Just FYI, due to a nuance in how google Analytics handles referrers, if your visitor does bookmark and comes back to the site, both the conversion and visit are attributed to the previous referrer, in this case the campaign. Many people already know this about the conversion, that the last campaign gets credit, but few people realize that direct traffic is credited to the previous referrer.

    I’m working with their team on a potential fix for this.

    Posted May 6, 2011 at 8:14 am | Permalink
  27. Hi

    If you arrive from Google by typing car insurance and then clicking on tdinsurance.com, then the referrer information is captured properly. If you start a car quote, you will notice there are redirects (not sure what), and I feel that you wont be able to associate google and the keyword to the success event of completing a quote. Is this the case?

    thanks

    Posted June 8, 2011 at 4:24 pm | Permalink
  28. jim

    @evanlapointe:
    I’d like to get those links emailed if you have them, we’ve run into the same kind of thoughts about Omniture ourselves

    Posted June 22, 2011 at 12:34 pm | Permalink
  29. Good post. Learnt a lot.

    Posted July 7, 2011 at 10:20 am | Permalink
  30. Maddie

    Thanks so much for this post, definitely learned a lot. But I also had a question about whether or not the browser would ever be able to be aware of the redirects. Basically, i’m trying to figure out if it is possible to track the redirects a certain website goes through. For instance, if you clicked the link on unicornUniverse.com would you ever be able to know that it tried to go to unicorns.html before it landed on DOUBLE-unicorns.com? Any help would be much appreciated!

    Posted July 14, 2011 at 3:41 pm | Permalink
  31. Maddie:

    The answer is “not really.” The browser won’t really have any way of seeing and storing this redirect information in a way you could access.

    If you are looking to check the redirects on a page-by-page basis, I’d recommend using this tool, instead: http://www.internetofficer.com/seo-tool/redirect-check/

    If you’re trying, however, to put this information into your analytics tool, doing this via the browser and javascript is a tree that doesn’t respond to barking :)

    Posted July 14, 2011 at 4:48 pm | Permalink
  32. Kyle

    Great post – all kinds of stuff I haven’t thought about before.

    I have a website that redirects mobile users to a separate domain via a script on the page, but I’m worried this is affecting analytics negatively. If a mobile visitor pulls up the homepage and is redirected to the other domain, does this count as a visit to the homepage before the redirect, and if so, will it also count as a bounce?

    Thanks!

    Posted July 18, 2011 at 1:01 pm | Permalink
  33. Is there any way to keep track of both the original referrer and the page that is redirecting? So, we have a page, http://www.helpingpeople.org that simply redirects to our main website. We want to know how many people are using the http://www.helpingpeople.org domain to get to our site, but we also want to keep getting our current referrer results. Is this possible?

    Posted July 25, 2011 at 4:22 pm | Permalink
  34. I just read your interesting article in search of a solution for the following problem:
    we have a serverside 301 redirect from http://www.malerweg.de to http://www.saechsische-schweiz.de/cgi-bin/malerweg, but malerweg.de doesn’t appear as a referer site at all. Do you have an idea why not?

    Posted September 30, 2011 at 6:16 am | Permalink
  35. Since you are using a 301 redirect, you will never see malerweg.de as a referrer (that page never loads). The whole point of a server-side redirect is to prevent the first page from loading. It’s like calling a package delivery service and telling them to deliver to a different address. The package never went to the first address, so if you said “where is this package coming from?” (what is the referrer), you would be asking where the package was sent from, not where it was originally supposed to be sent to.

    Hope that helps!

    Posted September 30, 2011 at 9:26 am | Permalink
  36. Pk

    Hello, what if I want to preserve unicorns.html as the referrer?
    So that unicorns.html is the refferer to DOUBLE-unicorns.htm instead of unicornUniverse.com?

    I don’t want unicorns.html to know that they came from unicornUniverse.com. unicorns.html should see that the referrer is DOUBLE-unicorns.htm.

    How can I do that?

    Posted September 30, 2011 at 5:40 pm | Permalink
  37. Is this because you are using a vanity URL? If you want to preserve it, you can either not use a 301 redirect (use a meta refresh or javascript redirect, instead), or you can pass URL parameters with the 301 redirect to either populate campaign data or give some custom javascript a name to digest and overwrite the referrer.

    Posted October 3, 2011 at 9:53 am | Permalink
  38. Hi Evan, excellent article – thank you so much! It’s a little over my head, so I’m wondering if you can help me out? I am redirecting http://90daychallengevernon.com to http://challengevernon.myvi.net and am trying to figure out how to track it. I use getclicky and would like to do it through there somehow, but will use GA if that’s the only way. How would I get the tracking code at http://90daychallengevernon.com when I don’t actually have that set up as a site? Hope that’s not too confusing of a question :) Thanks so much!

    Posted November 6, 2011 at 1:54 am | Permalink
  39. Your only option in this case, Sue, is to have the redirect at 90daychallenge… append some URL parameters to identify that it came from the redirect. You have the choice of either appending campaign URL parameters (which will over-write your original traffic source to 90daychallenge), or using a new URL parameter like ?urlsrc=90daychallenge that will show up in your content reports.

    You should be able to use either clicky or GA to get the data you seek, but I would recommend going with the second approach so you can see the original traffic source to your vanity URL.

    Posted November 6, 2011 at 9:57 pm | Permalink
  40. kevin

    Hi there,
    I got a website let say, http://www.aaa.com.au. In IIS, this site’s bindings were set to http://www.aaa.com.au, http://aaa.com.au, http://aaa.com and http://www.aaa.com. In my GA reports, the referrer shown http://aaa.com

    Thinking that bindings could be the issue, I then created redirects (301) such as all bindings are pointing (redirect + parameters -$V$Q) to http://www.aaa.com.au/.

    I still got http://aaa.com as referrer…I am clueless…

    Thanks for helps !

    Posted November 8, 2011 at 12:54 am | Permalink
  41. Kevin,

    I’m not exactly sure what’s happening. Have you verified these redirects with a third-party redirect checker? You could also be getting some legacy referral data coming in. Is the volume of these referrals significantly smaller now, or is it about the same as before?

    Posted November 8, 2011 at 9:34 am | Permalink
  42. kevin

    @evanlapointe:

    Hi Evan,

    thanks for your prompt reply ! I actually used http://www.internetofficer.com/seo-tool/redirect-check/ in order to check the redirects and all seems fine (301, correct redirecting URL, passed parameters…). Not sure if that’s what you meant by ‘verified these redirects’.

    Besides and maybe interestingly, the volume was pretty high in October but only between the 10th and 16th). Then, I compared the volume of these referrals after the redirects to the one couple of months ago -before the redirects- and it’s almost same. http://aaa.com was shown a referral site and is still. Seems like, even the redirects do not have any effects on that volume.

    So many questions…

    Are my redirects correctly set ? I would say yes.
    What happened between the 10th and 16th of October ? Can it be because people type directly in Google search the keywords for that site ? Can it be because of people accessing the site through a newsletter ?
    Why http://aaa.com is still shown in the reports as referral site ?

    Once again thanks for your help Evan !

    Posted November 8, 2011 at 6:21 pm | Permalink
  43. Yep, you used the right thing to check your redirects. I might need some more detail to take a closer look at this case. Please email me. My contact information is on evanlapointe.com

    Posted November 8, 2011 at 6:43 pm | Permalink
  44. David

    Thanks for the time you’ve taken to explain things here. Unfortunately, I am not getting clarity to what I am trying to do. I am launching a radio ad campaign. In doing so, I’d like to set up a new domain name used exclusively for the radio ads. I would forward that domain to my main site. I’d like to do this to measure exactly how well the radio ad is working, based on how many hits I get as a result of people going to the forwarded domain. My questions are,
    - do I use site forwarding or 301 redirecting?
    - Will GA capture this information?

    Posted December 28, 2011 at 11:01 am | Permalink
  45. You will want to set your 301 redirect up to include URL parameters to tell Google Analytics or your tool of choice that it is part of your radio campaign.

    http://www.vanityDomain.com

    redirects to

    http://www.realDomain.com/page.html?utm_source=vanityDomain.com&utm_medium=radio&utm_campaign=radio+promo+192

    Posted December 28, 2011 at 11:28 am | Permalink
  46. Evan, thanks for this write-up! This was something I always thought was true in my gut, but hadn’t actually confirmed until now.

    Posted January 19, 2012 at 5:44 pm | Permalink
  47. Yesenia

    Thanks for article. I thought your explanation was clear to me until I got to the “Keep in mind” point. I got confused by your “KEEP IN MIND: If you are using 301 redirects, make sure they preserve your tracking parameters (utm_source, etc., at the end of your destination URL)….”

    I use manual utm in all my emails as a best practice, so I just want to be sure that what I’ve been doing (setting up 301 redirects in old pages is still passing referrer information)

    I thought I only needed to setup a simple 301 on the server side and that will pass the referrer information to the new page (from any source: search, referrals, campaigns, etc). For example:

    original link: http://www.site.com/page1.aspx
    new page: http://www.site.com/new-page1.aspx to replace old URL
    301 redirection (on server side) in place on http://www.site.com/page1.aspx to go to http://www.site.com/new-page1.aspx (no extra parameters)

    If the old link (page1.aspx) is found on search engines, the referrer information would pass to new-page1.aspx as “organic – engineX”
    If the old link was used in an email with extra utm variables: http://www.site.com/page1.aspx?utm_source=marketing&utm_medium=email&utm_campaign=newsletter+sep+2011, the referrer information would pass to new-page1.aspx as “email – marketing – newsletter sep 2011″

    How do I make “sure to preserve tracking parameters”? Do I need to add extra settings on the 301 redirection for email links to work?

    I appreciate your feedback on this.

    Posted January 19, 2012 at 7:15 pm | Permalink
  48. You may have to set up the redirect to preserve parameters if it isn’t already. Keep in mind that document.referrer (what tells the browser what page referred to the current page) is NOT where Google Analytics (or most analytics tools like WebTrends and SiteCatalyst) get campaign data. The campaign is determined by reading a URL parameter. If that parameter isn’t present, the tool will use document.referrer. An example of where that would be bad is if someone clicked on an email ad from their Gmail account. If your campaign params are present, that visit will count as an email campaign visit. If they are missing, the referrer will be google.com.

    You can test this easily by just typing some fake parameters on the end of the page that will be redirected, like http://www.site.com/page.html?testparam=test. See if that goes to your next page and preserves the parameter “testparam”. If not, you’ll have to change your settings.

    Changing these settings depends entirely on your server (Apache, IIS, …), so you’ll just want to do a Google search for “preserve url parameters 301 redirect [servertype]“.

    Posted January 23, 2012 at 9:57 am | Permalink
  49. Lee

    Evan,
    Congrats on showing up #1 for this. I wish I could just put “so please link the hell out of this so it shows up in search results and helps people” at the top of every page and rank. :)

    I’ve read over all the comments and have a decent idea how to solve my problem but would appreciate some clarity.

    I have a client that wants to use a vanity URL for marketing materials and a more SEO friendly URL for search engines. They’ll be using a 301 redirect from http://www.somesite.com/vanity-url to http://www.somesite.com/seo-url.

    If I want to be able to track people that come directly to the vanity URL I will need to 301 redirect /vanity-url to /seo-url?utm_source=vanitry-url. I should get the data I need as well as not hurting any SEO (b/c Google recognizes parameters), right?

    On another related note to the above article, how is everything affected now with “secured search” in Google since it uses https, or does that even matter?

    Posted February 21, 2012 at 11:09 pm | Permalink
  50. Haha, thanks! Great strategy, huh?

    Sure, in this case you’re going to want to populate at least utm_source, utm_medium and utm_campaign. If you configure the redirect to add these three, you’ll be all set. Now, you do want to try to keep Google away from this vanity URL, because Google treats URL parameters as part of the URL. You do have the option of having GA read these campaign parameters after an anchor (#), rather than standard query params after ‘?’.

    It is rare for Google to index a page with utm parameters, but we see it all the time (check out the White House page in these results). It’s not enough to worry about: it will probably be counted as duplicate content and discarded (no, this isn’t as bad/scary as it sounds).

    Posted February 22, 2012 at 12:27 am | Permalink
  51. Forgot to answer your second question:

    Secure search will prevent the search keyword from being seen for organic searches. Feel free to email me if you have any other questions!

    Posted February 22, 2012 at 12:28 am | Permalink
  52. Lee

    So it seems as you would 301 redirect /vanity-url to /seo-url#utm_source=vanity&utm_medium=offlinemarketing&utm_campaign=offlinemarketing.

    The “#” should help with any possible duplicate content issues, I can also add these parameters into GWT and ignore them.

    Also, it seems as though your personal site redirects here now, whats your preferred email address? Feel free to reply to mine if you prefer. I definitely have questions here and there that I would love your insights on, as opposed to guessing the solution sometimes from what I can find on the big ol world wide web.

    Posted February 23, 2012 at 12:40 am | Permalink
  53. Yep, that’s right. And since this is an anchor, you shouldn’t have to do anything in GWT, as anchors are ignored.

    You will need to add _setAllowAnchor(true) to your GA page snippet to ensure GA looks in the right place. This must come before the initial call to _trackPageview.

    Posted February 23, 2012 at 11:10 am | Permalink
  54. Modi

    Hi,

    Nice post but I have a rather more complicated question which has to do with international sites.

    Let’s assume the site http://www.mysite.com consists of several subfolders, all targeting different markets. For instance:
    http://www.mysite.com/us
    http://www.mysite.com/uk

    Also imagine that 301 redirection takes place based on IP detection. A US-based user typing http://www.mysite.com will be redirected to http://www.mysite.com/us and a UK-based user will be redirected to http://www.mysite.com/uk.

    Having analytics set up for http://www.mysite.com, http://www.mysite.com/us and http://www.mysite.com/uk where are those visits going to appear and how are they going to be reported? Would the US visit only reported under http://www.mysite.com/us and the UK one only under http://www.mysite.com/uk ? Would these visits also appear in the analytics profile for http://www.mysite.com?

    Posted April 20, 2012 at 6:12 am | Permalink
  55. Do you have separate profiles tracking each translation, or do you have a single profile that is filtered into sub-profiles?

    Assuming it’s the first of the two choices, you are going to see nothing for http://www.mysite.com unless there are pages in that profile that are getting pageviews. Using an IP-based redirect, the user’s first pageview will be on the localization for their country, so that will be their landing page as long as the redirect is server-side, as it is in the scenario you’re describing.

    Does this begin to help?

    Posted April 20, 2012 at 2:35 pm | Permalink
  56. Dave

    Hi, thanks for the post.

    I am wondering if anyone has any creative ideas on how to track (capture as much information as possible) the linking out from an offline application to 3rd party websites? One idea I have had is to link to a site which automatically re-directs to the 3rd party site and do the tracking on this “middle-man” site.. The issue here is that I cannot run the analytics code on the destination site as I don’t own the domain. I also need the tracking code to run on the “middle man” site and therefore (I think) I need to do the re-direct on the page as opposed to at the server. Do you have any ideas on how to, 1: ensure the analytics code runs and 2: make sure it is as seamless/quick as possible.

    Thanks for any help/ideas

    Does anyone have any other ideas on how to do this, or on how to work around the delay?

    Posted June 19, 2012 at 5:52 am | Permalink
  57. Awesome post and amazing responses to the gazillion personal questions!

    My question is very basic. I am just migrating from an HTML static site to WordPress. I have a few pages that tend to be where people land via Google searches. What I want to know is will my server side 301 redirects for those pages continue building the page rank for the original addresses or will I be starting over with the new addresses?

    Example – original static page:
    http://roadslesstraveled.us/Budget.html

    My new WordPress page will be something like (not there yet):
    http://roadslesstraveled.us/rv-budget/

    So when I do my 301 redirect for this page from the old address to the new one, will the old address continue to increase in rank as people hit it from Google searches looking for http://roadslesstraveled.us/Budget.html, or will the effect of the page’s popularity be muted because folks clicking on my revised budget page from inside my site will be going directly to the new address http://roadslesstraveled.us/rv-budget/ instead?

    Thank you so much.

    Posted July 31, 2012 at 12:45 pm | Permalink
  58. Yep, you will accumulate page rank, however there is a dampening factor that may slightly erode the total possible credit (vs. if the links were direct). It isn’t enough to matter, in most cases, but it is there.

    Posted July 31, 2012 at 5:29 pm | Permalink
  59. Brian

    I’m working on a client’s site and notice in Google Analytics they have a default.asp page that’s receiving the most pageviews of all the pages on the site. The only thing is that this page doesn’t seem to actually exist on the site. I’m guessing it’s referring to the home page based on the traffic and title tag but there’s a 301 redirect in place to point from http://www.rootdomain.com/default.asp to http://www.rootdomain.com/

    So I’m confused as to why GA would show all of the traffic going to default.asp instead of to / since there’s a 301 redirect in place.

    Any ideas?

    Posted August 25, 2012 at 2:18 pm | Permalink
  60. Brian,

    Great question! This is likely due to a setting in Google Analytics, actually. If you go into your web property configuration, you can specify the name of a default page. That probably explains why you’re seeing this.

    Posted August 27, 2012 at 9:56 am | Permalink
  61. Great article. I am going to add it to the googleanayticstest.com website as a reference.

    Posted August 31, 2012 at 10:19 am | Permalink
  62. Brian

    @evanlapointe: Hey Evan, I really appreciate you answering my question. Would you mind clarifying where I would find that setting?

    Posted September 1, 2012 at 10:15 pm | Permalink
  63. Brian

    Okay, I figured out where that setting is. It’s in Profile Settings in the Admin. Thanks for your help and the great article Evan.

    Posted September 4, 2012 at 10:34 am | Permalink
  64. SO i got a friend who just did a 301 redirect to my t shirt shop.

    However, none of his traffic that he is sending me is showing up as his domain…

    it still shows up as a search….unless it is direct.

    this is clarifying your concept of search is search, direct is direct, right?

    any way to see what 301s gave me those search traffic hits?

    Posted September 5, 2012 at 7:47 pm | Permalink
  65. Hi there are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and set up my own.
    Do you require any html coding knowledge to make your own blog?
    Any help would be greatly appreciated!

    Posted September 24, 2012 at 12:27 am | Permalink
  66. Tom

    Hi
    Good post, still timely today. You wrote:There are times when a 301 redirect will NOT preserve referrer information, but they are rare. The most common example is when an https page links through a redirect on a non-https page.

    Is the opposite also true – a non-https page lnking to a https page through a redirect?

    Posted November 5, 2012 at 11:07 pm | Permalink
  67. @Tom

    Great question. The behavior is actually independent of whether a redirect is in place. Links from https to http drop referrer info. The other way around, that’s not the case. You can always test using the document.referrer method mentioned above, using a site that has the desired scenario in place.

    Posted November 6, 2012 at 2:24 pm | Permalink
  68. @evanlapointe: can you send me the documentation from Omniture help center regarding how 301s/302s are treated? I’d really appreciate it!

    Posted November 16, 2012 at 5:52 pm | Permalink
  69. Sorry, it’s behind a login in their help center. If you search for 301 redirects, you should be able to find it.

    Posted November 19, 2012 at 2:19 pm | Permalink
  70. Great web site. Plenty of helpful information here.
    I am sending it to a few friends ans also sharing in delicious.
    And of course, thanks for your sweat!

    Posted December 27, 2012 at 11:06 am | Permalink
  71. Great post! We are linking to this great post on our website.
    Keep up the good writing.

    Posted January 9, 2013 at 2:31 pm | Permalink
  72. Christine

    I’m having issues with parameters being stripped and loosing Analytics data. In most cases the only common denominator is a redirect but it won’t only not show the data correctly in Google Analytics it takes the user to a “oops we’re sorry” page which is a huge problem.
    For example http://www.website.com/shampoo is fine but if a param is added http://www.website.com/shampoo?utm_test=123 it will go to an error page. So essentially that’s where we’re sending traffic to for those pages-client is NOT happy.
    We have our SEO side pushing for 301 redirects (vs 302) which is fine for their efforts but on the paid side the only fix I can think of to remedy the issue is to get a list of every 301 redirect and change the URLs in our campaigns to match. Considering there are hundreds campaigns is very time consuming and not efficient.
    Any insight here or potential fixes? ANY help is appreciated!

    PS We use Marin for URL tracking not Google’s auto tagging

    Posted January 12, 2013 at 2:02 pm | Permalink
  73. Yeah, sounds like the site isn’t very friendly with URL parameters because of how it’s built. Google analytics allows you to use an anchor (#) instead of URL parameters to set the utm_ parameters, so you may want to explore that. You’ll need to allow anchor (check their documentation for most recent help on that) and then you can write your URLs in a way that GA will see but won’t upset your CMS. In this case, a 301 redirect probably won’t do anything (nor a 302 or any other kind). Not sure why they’re bringing that up, because it doesn’t sound like it has anything to do with the issue at hand.

    Posted January 14, 2013 at 1:11 pm | Permalink
  74. rob

    What if you put in AdWords url A that redirects the user, based on their searchphrase, to url B (on the same domain). How will analytics handle that kind of redirects?

    Posted February 20, 2013 at 12:06 pm | Permalink