Google Analytics Campaign Tracking Pt. 1: Link Tagging
November 10, 2006 by Justin CutroniWhat is Link Tagging?
To track your marketing campaigns Google Analytics uses a technology called link tagging. This provides a fine level of detail about marketing efforts. The data we gather from link tagging helps us make informed business decisions about our marketing spend.
With link tagging, we add additional information to the destination URL used in an ad. The technical name for this additional information is the query string. Here’s an example:
http://www.epikone.com/landing_page.php?utm_campaign=fall-sale
&utm_medium=banner&utm_source=boston.com&utm_content=text-only
*** NOTE: I moved some text to a second line for readability ***
Everything after the question mark is called the query string. Within the query string we have a number of parameters. Each parameter is separated by an ampersand (&). Pulling apart the above query string we find the following parameters:
utm_campaign=fall-sale
utm_medium=banner
utm_source=boston.com
utm_content=text-only
Each parameter can be further divided into two parts; a variable (the text on the left side of the equals sign) and a value (the text on the right side of the equal sign). Let’s break the above parameters into variable - value pairs:
| Parameter | Variable | Value |
| utm_campaign=fall-sale | utm_campaign | fall-sale |
| utm_medium=banner | utm_medium | banner |
| utm_source=boston.com | utm_source | boston.com |
| utm_content=text-only | utm_content | text-only |
Ok, stick with me. We’ve gone from a query string, to parameters, to variables and values. Now, let’s start to explain what all of this means. What are the variables and values? I’ll start by explaining the variables:
| Variable | Meaning |
| utm_campaign | The name of the campaign. Think of this as a bucket. It holds all of our marketing activities. For example, we may be buying some keywords on Google, running some banner ads and sending out an email all to advertise our winter ski sale. However, these three activities are all part of a bigger marketing campaign, our ‘Winter Ski Sale’. |
| utm_medium | I like to think of the medium as the mechanism, or how the message is delivered to the recipient (i.e. email, banner, CPC, etc). What is the ‘distribution method’ that is used to get our message out to our clients? |
| utm_source | Think of utm_source as the ‘who’. Who are you partnering with to push your message. If you’re tagging CPC links the source may be Google, Yahoo! or MSN. This could also be the name of a service that will be pushing banner ads for you. |
| utm_content | The version of the ad (used for A/B testing). You can identify two versions of the same ad using this variable. |
| utm_term | The search term purchased (if you’re buying keywords). This is not always used and is NOT included in the above example. |
It’s important to note that you do not always need to use every variable. The core variables are utm_campaign, utm_source and utm_medium. You should always use those three. With Campaign, Medium and Source you’ll reap the most benefit from Google Analytics.
Just to recap, link tagging is the process of adding additional information to the destination URLs we use in our ads. This additional information consists of variables and values.
Here’s the really cool part, the values. The value for each variable is a piece of business information that will end up in Google Analytics. Let me clarify that, you’re actually taking information that is specific to your business, like the name of a marketing campaign, and placing it in Google Analytics. GA will display it, exactly as it is typed, in a series of reports called the Marketing Campaign Results (see Part 3 of this series). This is extremely powerful because you can look at your analytics data through the lens of your business.
So now we know everything about what link tagging is, but what happens after we tag our links?
When someone clicks on a tagged link Google Analytics, using the urchin.js JavaScript, stores all the values in a cookie on the visitor’s machine. That way we can track the traffic generated by each marketing campaign. When a visitor completes one of our goals we can view the marketing activity that drove them to the site.
It’s important to understand that the cookie will persist until 2038. It’s also important to understand that the cookie will be updated with other information. For details about how Google Analytics stores various referral information please see the following post: How Does Google Analytics Track Conversion Referrals?
How to Tag Your Links
The process of Link Tagging is simple. Start by identifying the information that you need to place in the variables. You need to identify the campaigns, mediums and sources that you use in your marketing activities and place it in your destination URLs. Then modify your destination URLs to include the new variables and values.
How do you do that? You can use any text editor, the Google Analytics URL Builder or the special tool I discuss in Part 2 of this series. I’m partial to the special tool :)
Remember, if you’re placing links to your site in cyber-space, you should be tagging them.
Subscribe:









40 Responses to “Google Analytics Campaign Tracking Pt. 1: Link Tagging”
I have been thoroughly impressed with all the hints, tips and tricks available in this blog. Thank you so much, this was sorely needed.
I did have a question though. Is there a way to find out query string parameters from a referral? Meaning that http://www.somesite.com/forum.php may be the referral, but I really would like to see what the request scope parameters were as well, as the URL was most likely http://www.somesite.com/forum.php?post=xyz&foo=bar.
I look forward to your reply.
Best Wishes.
By Georg on Dec 11, 2006
Hi Georg,
Unfortunately GA will not capture the query string variables in a referral URI.
Thanks for reading and thanks for the positive feedback.
Justin
By Justin on Dec 12, 2006
This documentation is so much more complete and thorough than anything Google provides for this subject.
By Steven on Jul 2, 2007
Hi Steven,
Thanks so much for the comment. Honestly, that’s why I do this :) I’m trying to dump everything I know into a book that is written in the same tone and style as the blog. Hopefully that will be out soon (the next few months) and will be very affordable (about $10).
Thanks for reading and the kind words.
Justin
By Justin on Jul 2, 2007
Hi Justin,
great article! I had planned a link planned to monitor some newsletter campains and it works great but I got stucked with the ugly-url problem: the querystring definitely ruins the well formed url, hit the usability because the url became longer that the browser input (copy problem by non experience users) and finally sometimes the user copy and paste it around (email, blog, etc..) spreading a false referer.
I’m testing how I can avoid that; I found a solution using the urchinTracker but require a (non tracked) redirect so it’s not optimal.. any ideas?
Thank you in advance.
Regards,
daniele
By Daniele on Sep 20, 2007
Hi Danielle,
You can’t really use urchinTracker() to identify referrals. The reason is that urchinTracker() creates pageviews while referral information is visit information.
It sounds like you need to use vanity URLs with a redirect that automatically adds the campaign tracking query string parameters.
Hope that helps and thanks for reading the blog!
Justin
By Justin on Sep 26, 2007
Hi Justin,
thank you for the reply. Of course urchinTracker use is not-so-good: I can read the referer as pageviews but of course this is a weak solution because it losts the ability to segment and cross the data in the analytics way.
Redirect seems the most logical way but it has to be done in client side (and I don’t like that) and then you have to worry about counting two times the second views, so you have to implement a way to sniff the redirect and omit tracking it.
By the way I have to *remove* the querystring, not add it. The problem is not the compless link on the mail (often hidden) but the url that stay in the browser url location after the user click on it.
By Daniele on Sep 28, 2007
>>Unfortunately GA will not capture the query string variables in a referral URI.
Sure they can, but you have to setup a custom filter. Google it and you’ll find it. I set it up a while back. The only pain is when you go to referrals and then your custom variable, the GA page doesn’t have links and long links are cut off so you have to view source and copy and paste to visit any site.
Why doesn’t google clue into this obvious need???
And why don’t they compress the js code, it’s so obvious too, no one is reading it.
By ziggy on Oct 8, 2007
If I tag a link without the source, will the referring domain register
in the reporting data?
For example,
http://www.mysite.com/?utm_medium=banner1&utm_campaign=promo1
Instead of,
http://www.mysite.com/?utm_source=external&utm_medium=banner1&utm_campaign=promo1
The reason I want to do this is that I may not know who the source is
(I’m passing the code around in a viral campaign), and I’d rather GA
“automatically” pick up the domain/source, but where I can still
customize the medium and campaign tags so I know which banners are being clicked and how often.
By Joe on Oct 23, 2007
Hi Joe,
If you leave off the utm_source variable then the GA tracking code will automatically identify the link as a referral. It will override the values that you enter for campaign and medium.
Is it possible for you to add some JS to the link you provide? If you could dynamically add document.location to the utm_source variable then you can get the data that you want. The key is to add some script that does document.write(’utm_source=’+document.location) or something like it.
Hope that helps and let me know if it works.
Thanks for reading the blog and thanks for the question.
Justin
By Justin on Oct 23, 2007
Thanks, I got that to work… kinda. For others, I posted the code below.
But when I go into GA, I get 0 for visits. Literally, the # 0 shows up. I’m not sure how that’s possible! But I don’t think it’s particular to this javascript approach. I’ve seen other instances for normal tagged links where the visit count is 0. Is this a “first visit” thing, or is the code not catching properly?
Thanks,
Joe
The javascript code I used:
document.write(”“);
By Joe on Oct 28, 2007
I am not sure if this is possible but can we pass anything unique to a particular page, as argument to urchinTracker()?
My requirement actually is that I want to check which the username/userId visited a particular page…
Is it possible in GA?
By Kapeel Mopkar on Nov 1, 2007
Hi Kapeel,
Whatever value you pass to urchinTracker() will become a pageview. But be careful. It is against the GA TOS to send any PII to Google Analytics.
Justin
By Justin on Nov 1, 2007
GA does not seem to track all visits correctly when the utm_X parameters are sent along with POST data.
works often, but not always. Possibly the Internet Explorer 6 fails to comply here… any ideas?
By Chris on Nov 15, 2007
I noticed that google uses the campaign names from the adwords account when auto-tagging is on. Since we track other campaigns, we have been using the utm_campaign field to identify engine, campaign and adgroup, and then parse the data in excel. We would like to do this with google as well (since there is now way to pull a report out of GA with all adgroups (have to drill down into each campaign.
I know that you CAN tag Google with the GA parameters, but do we have to then turn off autotagging? Even if we do this, will GA replace the campaign names it currently grabs with the utm_campaign values we set?
Thanks,
Chris
By Chris on Nov 16, 2007
Hi Chris,
I havenot heard of that problem. Also, I’m not sure why you would need to pass the campaign tracking parameters via a POST. The campaign parameters are only meant to be present on the initial landing page. Then the values are stored as cookies on the visitor’s machine.
If you’re talking about cross domain tracking then it’s probable that the third party site is stripping off the query string parameters.
Thanks for the question sand thanks for reading.
Justin
By Justin on Nov 17, 2007
Hey Chris,
To answer your second question, YES. If you want to manually tag your AdWords links then you must turn off auto tagging. Once you turn off auto tagging and manually tag your links, GA will pull in the value that you specify in utm_campaign.
Thanks for the question.
Justin
By Justin on Nov 17, 2007
thanks for the great writeup. very clear. I think I understand how GA will track clicks on a given campaign. I recently started a website & am looking to sell banner ad space on the site. Can I use GA to track the ads that I run on my site? Can I track impressions of the banners using GA tagging or can it only track clicks?
If not, is there something you can recommend for tracking the ad’s impressions?
By Vic on Nov 28, 2007
Hi Vic,
To track banner impressions you’ll need to hack something together using urchinTracker. You’ll need to create a pageview every time an ad is displayed. You can learn about urchinTracker in this series of posts.
A better solution will be to use event tracking when that feature is released.
Thanks for reading,
Justin
By Justin Cutroni on Dec 2, 2007
Anyone else who’s using GA event tracking to track banner impressions, I’d love to hear how you are doing it too. I’d really like to compare GA analytics figures versus my ad management solution to get a feel for the differences.
By Tim Archambault on Dec 7, 2007
Hi Tim,
I think a lot of people are going to use event tracking to track ad impressions. Because the event data model is so flexible you should be able to track a substantial amount of data.
Thanks for reading and thanks for the comment.
By Justin Cutroni on Dec 7, 2007
Hi Tim
We currently have a number of banners set up on affiliate sites. Im hoping to be able to set up funnels from each of these to track the amount of custom from each of these. We are unable to add the tracking code to the actual page but could add this to the banner. Is this as simple as simply adding the tracking code to each of the banners?
Also congratulations on the help you’re providing it’s a great help and is much appreciated.
By Nick on Jan 7, 2008
Can someone clarify if GA sometimes does not pick up certain utm_xxx variables, even if they are in the links I’m using?
We are usng redirects from “friendly” URL’s (mydomain.com/VALUE) to the long URL with both the utm query string, plus some other aspx parameters of our own.
GA seems to pick up the utm_source, but NOT the medium and campaign values.
Can anyone explain?
By Rich on Jan 15, 2008
Hi Justin;
I wonder what the “best” approach would be to track referrals from shopping comparison engines such as Nextag or shopping.com. I can tag the landing page URLs. This is what I am using:
campaign: NexTag
medium: shopping engine
source: product_id
Of course if I have lots of products I end up with lots of sources in GA. Or should “NexTag” be the source?
There may be no right or wrong here, so am just wondering what approach other people are using.
Many thanks,
Michael
By Michael Whitaker on Jan 18, 2008
Rich,
Not sure there is an easy solution to the problem that you describe. It could be that your server is using a delimiter other than the ampersand. I would check the cookies on your machine. Navigate to the landing page and after it redirect you look at the cookies. You should see a cookie named _utmz and it should contain all of your link tagging values.
Hope that helps and thanks for reading.
Justin
By Justin Cutroni on Jan 20, 2008
Hi Michael,
First, always a pleasure to hear from you.
I like the approach that you’re taking with the affiliate tracking. You’re capturing all of the data in a logical way.
I really think that the best practice is capturing the data in a structure that works with the GA reporting. You’ve done that very well.
With that said I think there a couple of small tweaks you could potentially use.
First, if this is an ongoing marketing campaign, that you want to group with other ongoing marketing activities, you may want to change the utm_campaign value.
Second, you may be able to take advantage of the utm_content parameter to capture even more information. But this depends on the shopping engine and the data they let you track.
Again, you’ve got a great setup, and if it’s workig for you I would not change a thing.
Thanks for reading,
Justin
By Justin Cutroni on Jan 20, 2008