How to Build a Google Analytics Tracking Code
Need more input? As an optimizer who is regularly looking to learn more about how my recipients are interacting with content, I find myself regularly consuming analytics reports filled with Google Analytics tracking code data like Johnny Number 5 eats the Encyclopedia Britannica in the above clip from the 1986 gem Short Circuit.
Google Analytics tracking codes — also know as custom campaigns or UTM codes — are custom tracking parameters that communicate to Google Analytics granular information about how your referral traffic is interacting with your calls to action. To implement a UTM tracking code simply add your desired parameters to the end of the URL you want to track insights for, like this:
UTM tracking codes can help you analyze traffic from banner ads, email newsletters, social media content, and any other campaign that links people to a property that you own (such as your website or your blog). You cannot use UTM tracking to analyze clicks to external websites, like YouTube or Link-To-Related-Content.com. To track click activity on links that send people to properties you don’t own, Bitly is a great free resource.
How To Put Together a Google Analytics Tracking Code
There are five possible parameters you can set for each UTM tracking code: Source, Medium, Campaign, Content and Term. You don’t have to use all of them. For this blog post I am going to show you show to create a UTM tracking code for a link that directs people from a blog post to a page on my website. To keep it simple, I am only going to discuss the parameters needed for this scenario — Source, Medium and Campaign.
Note: When and how to use Term and Content parameters is really a whole separate blog post; leave a comment if you are interested in seeing us write about it.
The Medium (&utm_Medium) is the most broad parameter and tells Google Analytics — big picture — how to classify the medium by which your link was presented to the user. For example, was the link presented in a Facebook wall post? Then the Medium might be “viral” because the link you posted to your Facebook wall is now spreading virally all over the Internet and, accordingly, was delivered via a “viral” medium. (If viral is too abstract for you, “social” could also work.) Was the link transmitted to the end user via an email newsletter? Then your Medium might be “email,” or even more specifically, “ConstantContact” or “CheetahMail” to identify the service that delivered your newsletter. In our example above, our link was a blog post, so we used &utm_medium=viral.
Getting one step more specific from Medium, the Source (&utm_Source=) tells Google Analytics where the click came from, where the person was when they clicked the link. In our example above (utm_source=blog) the person clicked on a link that was posted to my blog (so the Medium is “viral,” and the Source is “blog.”). Other Source options might include Twitter, Facebook or newsletter (Medium equals “email” and Source equals “newsletter”).
The Campaign parameter (&utm_Campaign=) is one step even more specific than Source, and the parameter where you can really start to get granular with your tracking. The Campaign is how you identify the specifics of a link, from the details of where it goes all the way down to the color and size of the call to action. In the example above I used &utm_campaign=CRO-JThompson-image because I wanted to identify which of my silos encouraged the most clicks, the longest time on site, and — at the other end of the spectrum — the most site exits. I also wanted to collect data to help me determine which of my authors are being read the most, and if an image call-to-action perform better than a text call to action. If this link was a banner ad I might have included the dimensions of the banner (for instance 320 or 160) to help determine which banner size encourages more clicks. If I wanted to test how well a link to free content performs versus how well a link to paid content performs I might have included “free” or “paid” as Campaign parameters.
Six Essential Google Analytics Tracking Code Details
- Every UTM tracking code starts with a question mark. For example: ?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.
- 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 (&). 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.
- Since the Google Analytics URL builder makes it easy for any of your team members to create and assign UTM tracking codes it is critical to have a discussion about UTM parameter conventions before anyone on your team starts creating UTM codes willy-nilly. I highly recommend creating a spreadsheet or other living document (a Google Drive spreadsheet works great) that clearly outlines conventions for Source, Medium, and Campaign. (If you are using Content and Term parameters regularly, make sure to add conventions for those parameters as well.) You may even consider taking your spreadsheet to the next level to establish a record of every link posted and its associated Campaign allocations. While a spreadsheet that documents every link your company pushes out is a larger commitment, these resources become invaluable as associates join and leave your team.
Note: If you’re crafty you’ve noticed the links in this blog post have not been amended to include Google Analytics UTMs. This is because the Bruce Clay, Inc. content team is currently developing our analysis goals and tracking conventions. Since I am a data-hungry Johnny Number 5 monster I have been using Bitly as my personal one-man-band interim tracking convention because I can’t survive a minute without data. I do not recommend this as it’s not scalable long-term.
- UTM codes are case sensitive so Google Analytics will collect data for potatoes and Potatoes as two separate reports. This means, 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.
- Hyphens allow Google Analytics to understand each word individually; underscores are considered alphanumeric characters and connect words to make phrases (see dashes vs. underscores for more detail). For instance: sandals-coupon versus sandals_coupon. If you are building UTM codes for a newsletter send it might make sense to use an underscore to connect your newsletter identifier with the release date of the newsletter — for instance, DealerUpdates_2013July09-colorado. In this example you will be able to find data in Google Analytics for the specific term “DealerUpdates_2013July09” which will tell you exactly how that specific dealer updates newsletter that was sent out on July 9, 2013 performed. You are also able to analyze how every email sent to your Colorado demographic performed, but because “DealerUpdates_2013July09”and “Colorado” are separated by a hyphen the Colorado data will not be exclusive to the July 9 email.
- Worth noting again, you must own a URL in order to attach UTM tracking 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 external properties like Facebook.com or Other-Website.com.
Why Use Tracking Codes?
I consistently use Google Analytics tracking codes to measure where my referral traffic is coming from, which of my initiatives are meeting traffic goals, how my target markets prefer to receive communication, and the ebb and flow of industry based on seasonality.
They give you a granular snapshot of your referral 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 specific ROI data.
Are you a Johnny Number 5? How have Google Analytics UTM codes made your life easier?