The skills we teach deliver real ROI.

How to Build a Google Analytics Tracking Code

by Traci Lester, Digital Marketing Specialist – ASPE, Inc.

What is a Google Analytics Tracking Code?

Tracking codes can be known by several different names including custom campaigns and Urchen Tracking Model (UTM) codes. They are web addresses with custom parameters that communicate to Google Analytics very specific data about how people are interacting with your content and calls to action. These custom tracking codes and the information they collect help analyze specific traffic that results from banner ads, email newsletters, social media content, catalogs, brochures, printed QR codes and more.

For a long time, a large percentage of the traffic to our site was tagged as “Direct” traffic in Google Analytics.  For those of you who do not know what direct traffic is, it’s the number visits to your site from people who typed in the complete web address in their browser OR it is referral traffic coming from somewhere you are unable to track.  Once our team started using UTM tracking codes, we were able to significantly cut down on the number of untrackable visits being tagged as direct traffic and directly correlate those visits to marketing efforts.

You cannot, however, use Google Analytics tracking codes to analyze clicks to an external site – only your site. You can track how many people click and follow that link using external events coding, but once they leave your site, you lose track of them. For instance, our company has a YouTube channel where we post interviews with our instructors, footage from our public training courses, informational videos about our courses, and educational videos about subjects in which we are experts.  We use social media to promote those videos, but we cannot put custom parameters around those links taking visitors to our YouTube channel. We do not own YouTube, therefore, we cannot track visits to our YouTube channel inside Google Analytics with Google Analytics tracking codes. However, we can post those videos to our blog or another internal page on our site, add parameters to those URLs and tweet or share those links. That we can track. There is one caveat to this:  If you are a YouTube Partner and your participate in paying for advertising and sponsored videos on YouTube, there is a way to sync your YouTube traffic and your Google Analytics data.

How to Create a Google Analytics Tracking Code

To create a UTM tracking code, parameters are added to the end of an existing URL.  There are five possible parameters that can be set for each tacking code:

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

You do not have to use all of these parameters and in most cases you will only need to use source, medium and campaign.  Therefore, those are the three I am going to cover in this post.


The medium is the broadest of the parameters you’ll be using. Medium tells us how the URL was presented to the user. For instance, was it something you posted on your Facebook wall, was it printed on a handout at an event or was it a link your sales team sent to a client.


A little more specific than medium is source.  Source tells us where the user was then they clicked on your link, where they found the link, or who sent it to them. If the link was printed on an event handout, the source might be the name of the event.  If it was a link a sales rep sent to a client, the source might be the name or initials of the sales rep.

For example, as a training organization, we sponsor several professional organizations around the country.  A benefit of this sponsorship normally includes a linked logo on the “Sponsors” page of these organizations’ websites.  The source in these links is normally set to the name of that organization.


Campaign can be used to categorize your custom links and then measure the success of certain channels as a whole. We use campaign to put our links into the following categories:

      • Events
      • Instructors
      • Brochures
      • Catalogs
      • Organizations
      • Enterprise
      • Social

Campaign can also be used to tag specific promotions that might be communicated through several different channels.

I could give you a long, drawn-out explanation of how to actually put together one of these links and explain each special character, but that would be like teaching you times tables when you have a calculator sitting on your desk.  Google provides a SUPER simple tool called the Google Analytics URL Builder that creates the tracking code for you. All you have to do is paste in your original link, identify your medium, source and campaign, and click submit. Voila! The entire Google Analytics tracking code is automatically generated for you.


Google Analytics Tracking Code Best Practices

  • Use Google Analytics tracking codes to measure where referral traffic is coming from and the success (or failure) of specific marketing campaigns.
  • You can only use Google Analytics tracking codes on URLs that you own, not for tracking clicks to external sites.
  • Google Analytics tracking codes are case sensitive. For instance medium=brochure and medium=Brochure would be tracked individually inside Google Analytics.
  • Use a spreadsheet or Google Drive document, especially when working in a team, to keep track of Google Analytics tracking codes being created and the mediums, sources and campaigns being used.
  • Use a link shortening tool such as or create “short links” with 301 redirects on your site. Google Analytics tracking codes can get very long and no one wants to type that in.

Do you still have questions about how and when to use Google Analytics tracking codes? Leave a comment and we’ll keep the conversation going!

Are you looking for more great information on using Google Analytics to track and optimize your site? Check out our hands-on, 3-day Mastering Google Analytics course or click here to receive more information on ASPE-ROI’s marketing training and services.


Leave a reply