Get Free Quote
« Millennials ❤️... | Blog home | How Well Do You... »
November 2, 2016

How to Build a Google Analytics Tracking Code

  • Print Friendly

Need more input?


Like Johnny Number 5 eats the Encyclopedia Britannica in the above clip from the 1986 gem “Short Circuit,” as optimizers we are constantly looking for more input.

Google Analytics tracking codes are one way we can track how recipients are interacting with our content.

Also known as UTM codes, tracking parameters or custom campaigns, Google Analytics tracking codes are custom tracking parameters that communicate granular information about how visitors interacted with your calls to action to arrive at your owned properties.

This guide describes:

Jump to each section with the links above … or dive in now.

build a tracking code

When to Use a Tracking Code

Use UTM tracking codes to see how traffic came to your owned web properties from across the web.

Use a tracking parameter any time you link to a URL on a domain or app you own. You will get the tracking data in Google Analytics for verified domains.

You can use UTM tracking parameters when linking to your owned property from any location: banner ads, email newsletters, social media content, and any other campaign that links people to a property that you own and manage in Google Analytics.

You cannot use UTM tracking to analyze clicks to third-party websites, like YouTube.com or Wikipedia.org. To track click activity on links that send people to properties you don’t own, Bitly is a great resource — and it’s free.

How to Format a UTM Tracking Code

To implement a UTM tracking code, add your parameters to the end of the URL you want to track for insights.

Here’s an example URL with UTM. In this example, the link is posted to Facebook.

http://www.bruceclay.com/blog/amplify-seo-employee-advocacy/?utm_source=facebook&utm_medium=social&utm_campaign=liveblog

Part 1: URL of the page you’re linking to with a “?” at the end

Part 2: utm_source=

Part 3: utm_medium=

Part 4: utm_campaign=

UTM_Source=Awesome Google Analytics tracking code parameter

Bruce Clay, Inc. does not recommend or condone using “awesome” as a Google Analytics UTM code parameter. (But we may or may not find it amusing.)

How to Put Together a Google Analytics Tracking Code

There are five possible parameters you can set for each UTM tracking code:

  1. Source
  2. Medium
  3. Campaign
  4. Content
  5. Term

You should always use the Source, Medium and Campaign parameters; Content and Term are optional and primarily used for paid advertising. Google goes into detail about each parameter type in its support page here.

To keep this guide simple, we will only discuss how to use the three required parameters: utm_source, utm_medium and utm_campaign.

Source

Google defines the Source parameter as such:

utm_source: Identify the advertiser, site, publication, etc. that is sending traffic to your property, for example: google, newsletter4, billboard.

Common Source parameter data used within the BCI content and social media department include blog, newsletter, facebook and twitter.

Medium

Google defines the Medium parameter as such:

utm_medium: The advertising or marketing medium, for example: cpc, banner, email newsletter.

Medium conveys the big picture — how to classify the medium by which your link was presented to the user.

Campaign

Google defines the Campaign parameter as such:

utm_campaign: The individual campaign name, slogan, promo code, etc. for a product.

The Campaign parameter is even more specific than Source, and the parameter where you can really start to get granular with your tracking.

The Campaign parameter gives you the power to identify the specifics of a link placement, all the way down to the color and size of the call to action, if desired.

To illustrate, here are four of the most recent Campaign parameters we’ve used in content marketing efforts:

utm_campaign=smm: The content we publish to the blog may serve to deepen our expert, authority content supporting our silos, or content themes. For example, I linked to the last post on Snapchat marketing for millennials with the Campaign parameter “smm” so that I can see how popular our social media marketing content is.

utm_campaign=toolset61upgrade: With the release of SEOToolSet 6.1, we engaged in a campaign to invite SEOToolSet Lite subscribers to try the newest tools release. Links from our engagement email campaign contain this Campaign parameter.

utm_campaign=liveblog: Our conference liveblogging is a campaign. We invest in sending livebloggers to major digital marketing conferences with the goal of driving traffic to the site. Understanding when we’re getting traffic from liveblog content is key to evaluating this investment.

utm_campaign=seonewsletter-101816: We publish the SEO Newsletter monthly. The campaign “seonewsletter” tells us that traffic to the site is drawn by newsletter content. The date tells us what edition of the newsetter they clicked to see.

Tools for Building UTMs

You’re going to get pretty good at hand-typing a UTM pretty fast after you’ve done it a few times.

But if you’d rather use a tool to create the UTM for you, keep these handy.

7 Essentials Guidelines for Formatting Google Analytics Tracking Codes

1. Every UTM tracking code starts with a question mark (?utm_). This question mark tells Google Analytics where your link URL ends and your tracking starts.

If you don’t include the question mark, Google will think your link is http://www.yourwebsite.com/your-cro-landing-page-articleutm_source which, as an alteration of the URL permalink, will result in a 404 error. The question mark is important.

2. There are five possible parameters you can set for each UTM tracking code: Source, Medium, Campaign, Content and Term.

The parameters you choose to use are strung together in one sentence (no spaces) and separated by ampersands (&).

3. It doesn’t matter what order you list your parameters in, but your first parameter must start with a question mark and all the following parameters must start with ampersands.

The “&” tells Google Analytics where one parameter ends and the next begins.

If you forget the ampersand and write your code like ”&utm_medium=viralutm_campaign=” Google Analytics will think that your Medium is “viralutm_campaign=” which, as you can imagine, will skew your Medium and Campaign data pretty badly.

4. The best practice is to use dashes to separate words in a UTM parameter.

If you end up using spaces, Google Analytics will fill in the spaces with the percent sign or plus sign.

Dashes are preferred to underscores, although both work. For the backstory, see Matt Cutts’ behind-the-scenes explanation: dashes vs. underscores.

5. UTMs are case sensitive. Keep it simple. Stick with lowercase.

UTM codes are case sensitive so Google Analytics will collect data for potatoes and Potatoes as two separate reports.

Since Google Analytics does not have the human sensibility to tell you that there is a capitalized version of your Campaign floating around somewhere in your referral traffic data, you may be analyzing incomplete data if your team isn’t careful about capitalization.

6. You must own the destination of a URL in order collect data from attaching a UTM to it.

In other words, you can only use UTM tracking to assigned parameters to links that go to your properties — your website, your blog, your app, etc. You cannot use UTM tracking to analyze clicks that go to properties you don’t own, like your page on Facebook.com or your store on Amazon.com.

7. And finally, it is critical to have a discussion about UTM parameter conventions before anyone on your team starts creating UTM codes willy-nilly.

The Google Analytics URL builder makes it easy for your team to stay in sync when creating and propagating UTM tracking codes. Create a spreadsheet or other living document (a Google Drive spreadsheet works great) that clearly outlines internal conventions and consistent parameters.

The last thing you want is your campaign data split among variations, caused by issues as simple as pluralization or capitalization. You may be analyzing incomplete data if your team isn’t consistent. It’s good to have team-wide ground rules that everyone is aware of. For example, “stick with lowercase” is a good rule of thumb.

Why Use Tracking Codes?

Use Google Analytics tracking codes to measure where referral traffic is coming from, which initiatives are meeting traffic goals, how target markets prefer to receive communication, and the ebb and flow of an industry based on seasonality.

Are you a Johnny Number 5? UTMs give you a granular snapshot of your traffic, how your consumers (and potential-consumers) are interacting with the calls to action you’re putting out there, and they are a great way to quench an unrelenting need for ROI data.


Let us help you drive and track traffic to your website from organic search, paid search, content marketing and social media. BCI’s strategic services are tailor-made to match your business goals and audience. Let’s talk more about growing revenue through digital marketing.


This post was originally published on May 16, 2013, and updated on Nov. 2, 2016.

  • Print Friendly




27 responses to “How to Build a Google Analytics Tracking Code”

  1. eric hou writes:

    Someone told me if you are doing crazy SEO, you had better get rid of Google products. Gmail, Analytics, etc. because google will analysis your data to determine whether you are spam or not. This is interesting.

  2. Assaf writes:

    Hi,
    You might want to try the URL Builder Chrome extension that does all of that and much more – pre configured tag sets, bitly, fetching current URL automatically and more.
    https://chrome.google.com/webstore/detail/google-analytics-url-buil/gaidpiakchgkapdgbnoglpnbccdepnpk

  3. Chelsea Adams writes:

    Assaf,

    I like that this Analytics Builder Chrome extension allows you to establish “Quick Sets.” We want to track too many Campaign variables for this function to be helpful for us, but this could be a great time-saving tool for a small company looking to track something straightforward, like, “How well do my posts at [x] time work vs. my posts at [y] time.” For example, [x] time vs. [y] time company could set up two Quick Sets like this –>

    Quickset name: Facebook 12pm: Source=Facebook; Medium=Social; Campaign=post_12pm and
    Quickset name: Facebook 8am: Source=Facebook; Medium=Social; Campaign=post_8am

    Then any team member can use the Quick Set to easily generate a daily UTM for their 8am post. I can dig it.

    All that said…. I can’t help but call your comment out as a learning experience: Good comment marketing efforts, Assaf! :)

    I point that out not to be a jerk, but because this comment is a really good example of content marketing: The product owner found content that is related to his product and then subtly offered his product as a pointed solution to a problem.

    This strategy is an art that needs finesse; and there’s a thin line between ‘adding to the conversation’ and ‘trying to sell someone a raincoat at a cocktail party like Morty Seinfeld’ but, when done well, joining a blog conversation to offer your product as a helpful solution really can help. Proof is in the pudding — I downloaded this extension. And now I am talking about it..!

  4. Assaf writes:

    I’m speechless :-)

  5. Franson Nazareth writes:

    I’m a blogger myself and I found your post to be very interesting and unique. Good job on the post, and I’ve just became subscribed to your blog. Hope you do the same for me.

  6. Isha with Magento multi vendor extensions writes:

    I read all the articles you post definitely I am new to this niche but I gained some valuable tips from you,Thank you :)

  7. Richa writes:

    Thank you explaining this soo nicely. Building Google analytics tracking code really very helpful.

  8. Fulpy Shopping writes:

    Google analytics is really easy and inexpensive tool. However, by each passing day, tracking of Organic Search keywords has got really difficult! Not Found keywords percentage has increased considerably. Google webmasters tools is a much better option.

  9. Joe Gallant writes:

    Really helpful article – thanks Chelsea and Virginia!

    Knowing your link tracking and using it correctly are staples of digital marketing success.

    One tip that might save confusion – if you’re adding tracking to a URL that already has query parameters, which are generally preceded by a question mark (?), you may find that you need to start your tracking with an ampersand (&) instead of another question mark. It is my understanding and experience that it depends on the way the site in question decodes the URL, so to use a second question mark may cause a 404 error or similar.

    As with anything, test it before you go live! Of course, if you’re worried about your testing skewing the results, be sure to exclude your IP address in Google Analytics with a filter!

  10. Joe Gallant writes:

    One last point – I had to go and find this article I recently came across.

    Alan Skorkin gives an extremely detailed breakdown of the different parts of a URL – well worth a read!
    http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/

  11. Arpan Aravandekar writes:

    This is what iwas looking for in my project. Thanks For sharing.
    Cheers

  12. Sachin writes:

    I am reviewing all my blogs as there is slow traffic now and this seems to be timely for me. Thanks for this Tracking Code post, its of uber help.

  13. Shiva writes:

    Hey Chelsea Adams,

    I’m Glad that I visited to this website because I got something to learn for oh this was huge but was really interesting as this is a new topic for me.

    As UTM codes are the inner part of Google Analytics which is most important for anyone it’s like engine of the car which is crucial to get tracked of your website data turning it into insights.

    This is very important class for me and the links you provided are very useful too the utm builder, chrome extension and campaign parameters.

    Well I need to bookmark this link because their is so much information left for me.

    Thanks a lot for share Chelsea.

  14. SEO writes:

    The URL builder helps you add parameters to URLs you use in custom web-based or email ad campaigns.

  15. Pastile Potenta writes:

    Thank you explaining this soo nicely. Building Google analytics tracking code really very helpful.

  16. Sadhan Pal writes:

    Thanks a lot for this meaningful article. I’ve learned a lot of things. But I have a question, does Google Analytics working properly cause other counters show different result for the same blog. Why?

  17. Virginia Nussey writes:

    Hi Sadhan. Thanks for your question. I’m not sure I understand it. If you have a moment to clarify, please do. Thanks.

  18. Sadhan Pal writes:

    Sorry, probably I couldn’t clear to you.
    I mean, other counters app like supercounters.com or hitstat.com that are used to count pageviews of a blog shows the different result from Google Analytics. The amount of daily pageviews are shown different in different counter for the same blog, why?
    Are you clear?

  19. Virginia Nussey writes:

    Yes, I understand your question now. I pinged Sr. SEO Analyst Ryan Spiegl for an answer for you, Sadhan.

    “We know that there is some nomenclature confusion regarding use of Page Views and Page Visits, and who can say if every service uses the same taxonomy. One visitor, for instance, can create several page views within a visit, so this might be where the discrepancy lies.

    Another possibility is disparity if the tracking code for GA fires and the other one doesn’t. GA’s tracking code may be at the bottom of the page code but the other’s code may be in the top/header; in this case, quick bounces or changes during load will start to bifurcate numbers.

    To top it off, even Clicks in GSC and Visits/Views in GA don’t line up. Systems like these introduce to many variables to match well. Even between two tracking systems, there are disparities like GA and Omniture.”

    That’s a long answer for you, but we hope it helps!

  20. mandy writes:

    Hi – I am wondering at what point I add this new information to the file name –

    is it at creation – (which would mean i would have to create more than one file of the same page)

    or is it at the point of adding it to social media (like adding the extra bit at the end when you put a url in the facebook post) – which would seem more likely –

    Sorry to be a bit backwards – no one else seems confused by this

    other than that – very useful – thanks

  21. Virginia Nussey writes:

    Mandy, thanks for your comment. The UTM goes at the end of the URL when you’re linking. It could be a hyperlink on a blog post, in a web page, in an email or in a social media post. If you’re copying and pasting a link to a property you own, use a URL with a UTM.

  22. Shiva writes:

    I am pretty new this topic. I am confused with this topic.
    what is UTM in GA. How can I use it for my website?

  23. Virginia Nussey writes:

    Sounds like we need to expand on how to view the campaign tracking in GA better, Shiva. We’ll add that to the queue. Thanks for your comment.

  24. Melvin Foster writes:

    Can you show any example with some video as i don’t know how to do it . I will be grateful to you.

  25. Alexis Gil writes:

    You have convinced me that Tracking Codes are useful. Thanks a lot for posting!

  26. David Cornish writes:

    Fantastic article, I really enjoyed reading it.

    I have been online full time for many years yet I still got very useful info from this which then tells me others will also get great benefit.

  27. Sadhan Pal writes:

    Thanks a lot @Virginia Nussey for your answer. I’ve understood clearly.

Leave a reply



Get Started
Learn SEO

Subscribe to Blog Updates

Get email notifications when we publish new blog posts, usually two to three times a week.

  

a monthly digest keeping digital marketers in the know with SEO, SEM, social media and content marketing hot topics, live events, corporate shuffles, and deserved kudos.

We respect your privacy and never share your email address

Free Executives Guide To SEO
By continuing to use the site, you agree to the use of cookies. AcceptDo Not Accept
css.php