How to Create & Use UTM Tracking Code for Google Analytics

Business

If you own a website and you promote it, do you know which campaign is your most successful? UTM links can help with that.

By Ahmed khalifa

If you own a website and you promote it, do you know which campaign is your most successful?

Sure, you can check out the source of your traffic in Google Analytics. But wouldn't it be helpful if you had a deeper insight of your traffic?

You may have received an influx of traffic from your newsletter, but what if you want to know which link on your newsletter has generated more engagement on your site?

Or you have gained traffic via Twitter, but you want to check whether it's your daily tweets or a specific tweet that has brought you conversions on your site.

If you really want to get down and dirty with your traffic, you need to start using UTM tracking code to create custom URLs for your campaigns.

What is UTM Tracking?

UTM stands for 'Urchin Tracking Module' and is also known as UTM code, UTM tags, UTM link, UTM tracking and several others.

To make it even more confusing, it is also known as 'campaign tagging'.

But UTM tracking (yeah, let's go with this one...for now) is the tag that you add the end of a specific URL. And when someone clicks on that URL, those tags are then sent back to Google Analytics for tracking purposes.

When a visitor goes to a site which has Google Analytics tracking code installed, it can capture a lot of data via the cookies:

  • source – where the visitor came from
  • medium – is it organic traffic, CPC, referral, direct, social, etc
  • what browser they are using
  • what country are they accessing from
  • the screen resolution of your device
  • etc

Much of the data is useful and tends to be fine as it is. And if you have GA tracking on your site, you will be able to see that data and more right now.

But if you want to go to another level, you can overwrite this data by using your own custom tags via UTM parameters.

A simple example of what it looks like alongside your URL is below:

https://www.example.com/blog-post/?utm_source=google&utm_medium=cpc&utm_campaign=blog+post+promotion&utm_term=how+to+xyz

https://www.example.com/new-shiny-product/?utm_source=newsletter&utm_medium=email&utm_campaign=product+launch&utm_content=image+link

All the UTM tags start with utm_ followed by the property name. In the above example, you can see 3 of them:

  • utm_source
  • utm_medium
  • utm_campaign

Those three above are perhaps the most essential tags, but there are other tags you can add:

  • utm_term
  • utm_content

Why Should You Use UTM Tags?

As well as having extra data about your visitors and measuring your success, there are many other reasons why you should tag your URLs:

  • it will be nicely categorised and consolidated within the campaign reports of Google Analytics (under Acquisition > Campaigns)
  • URLs within banners ads might get categorised as referral traffic instead of,  e.g. paid traffic or banner ads
  • if you are not using auto-tagging on Google AdWords, traffic medium might not appear as 'cpc'
  • if you are running multiple paid adverts, they might get lumped in together as one campaign
  • email campaigns tend to be either under-reported or completely screw up your data if you don't tag the links pointing to your site
  • you can create unique tracking metrics: e.g. using 'affiliate' traffic instead 'referral' so that you will know which of your affiliates is the most successful
  • make your campaign reports on GA less chaotic and better track the success of your campaigns
  • track the same piece of content or campaign across multiple marketing channels

The Definitions of Each Parameter

As I said earlier, the top 3 values you should use are 'source', 'medium' and 'campaign', as you can get away with not using 'term' and 'content'.

But one of the most common mistakes is confusing medium with source, and vice versa. If you get this wrong, it can have a major impact on your GA reports.

So, no pressure.

So let's start off with understanding the differences between utm_source and utm_medium.

Gif of Yummly using UTM tracking the wrong way
You don't want your data to be clogged up like a traffic jam – Photo by Pedro Gandra on Unsplash

UTM_Source Definition

Where did your visitor find your URL? The source of your traffic will help you to find out, and if you visit Acquisition > All Traffic > Source/Medium, you can see the sites where your visitors have found your URL.

Or if you visit Behaviour > Site Content > Landing Pages, click on Secondary Dimension, search for 'Source' and click on it, you can see the landing pages and where your visitors have come from to find that URL.

Most of the time, it is pretty self-explanatory. But be aware of anything that might interrupt your definition of source.

You may have noticed that t.co in your list of source. That is Twitter's link wrapper, where all links sent through Twitter and Direct Messages will be shortened to t.co, and it will appear as t.co in Google Analytics too.

But if you tag your source with 'twitter.com' or utm_source=twitter.com, then it will fix that for you and keep it consistent.

UTM_Medium Definition

If the source is more specific, think of medium as its more generic partner.

Below are just some of the examples of good mediums that you can use (be warned that it doesn't mean you have to use it. Not everyone needs all the mediums listed):

  • social
  • email
  • banner
  • cpc
  • affiliate
  • ebook
  • partner
  • display
  • paid social

It is very common to see users getting mixed up with between source and medium; more so than getting confused with campaign name below.

However, this is potentially the most important parameter to get right.

You can have different sources like facebook, FB, facebook.com, etc. in your Analytics, which is messy. But if they happen to be categorised under 'social' medium, then it makes thing a little bit easier.

If not, there will be knock-on effects to other reports.

UTM_Campaign Definition

It's simple; this is the name of your campaign.

Even though it's simple, it's still not utilised to its maximum potential.

If you have been promoting multiple campaigns across various platforms, it would be challenging to consolidate all the metrics together in one place, unless you use a very sophisticated form of Regex (or Regular Expressions).

Related Article: A Beginner's Guide on How to Use Regular Expression Effectively?

But if you have used utm_campaign, it will make your life so much easier.

When using this parameter:

  • avoid making it too narrow, e.g. email
  • avoid using names which should be reserved for other parameters like source or medium (like 'email)
  • don't make it too difficult to understand
  • it's better to be consistent: e.g. it would be better to keep it consistent and useful by naming a campaign 'daily+newsletter' instead of '3+dec+newsletter', '4+Dec+newsletter', '5+dec+newsletter'

 

UTM_Term Definition

An optional but useful if you have any paid search campaigns as this is the place where you will write down what keywords you are bidding on.

I've mentioned earlier that if you have been using auto-tagging within Google AdWords (which is recommended), you do not need to use this value.

But for other search engines, you may need to manually set the utm_term (and potentially other parameters) as it will inflate your organic search data instead of paid search data.

UTM_Content Definition

This is also an optional tag, but it can help to provide useful details about your campaigns, not just for paid search campaigns but any campaigns.

For example, you may be running an affiliate campaign on an external site, but there are two different banners pointing to the same URL on your site. So you can differentiate the two by adding utm_content=sidebar and utm_content=header to the respective links.

For your newsletter, you may have two links to your blog post; one in the text and one in the image. But you can differentiate the two using utm_content, e.g. 'image+link' and 'text+link.'

How to Generate Your Own Custom UTM Tracking Code Using Google's Free Campaign URL Builder?

If you want to manually type in your custom URL for your campaign tracking, that's fine.

But the other option is to use Google's UTM code generator called 'Campaign URL Builder' and fill in the relevant fields.

  • Website URL - what is the site, page or landing page that you want your visitors to visit?
  • Campaign Source - what is the source of your traffic, e.g. google, twitter.com, facebook.com, newsletter or other referrals
  • Campaign Medium - what is the medium of that source of traffic? email, cpc, social
  • Campaign Name - if you are doing a strategic product promotion or campaign, what would you call it, e.g. 20percentspringsale
  • Campaign Term - mainly for paid search, this is to identify what keywords are you using and bidding for (not required if you are using the auto-tagging feature within AdWords and it's connected with GA)
  • Campaign Content - this is optional but useful if you want additional details about your campaigns, e.g. sidebar vs header banners, A/B tests, banner size, etc.

A 3rd option is to use the free UTM Chrome extension like UTM.io - Google Analytics URL Builder, which creates,  saves and auto-populates the UTM parameters and saves your most recent parameters used as preset, which saves you time.

How to View Custom Campaigns in Google Analytics

Once you have added your UTM codes and promoted your pages, it's time to see the fruits of your labour on Google Analytics.

And there are several ways you can do that.

To view your campaign on GA, go to your main website profile, click on Acquisition > All Traffic > Source/Medium.

From there, you should already see some of the tagging in place (provided that your visitors have clicked on the URLs).

The Downside of Using UTM Tracking Codes

There is one stubborn side to using UTM codes.

If a visitor has found your link (which is tagged with a UTM) on Twitter, copied and pasted the whole URL onto Facebook, and someone else clicked on it there...it would still be classed as a visitor from Twitter.

One solution is to remove the UTM codes from the URL after you have shared.

But if this clean URL is then shared on platforms which give you incorrect data, it will eventually give you misleading information on GA.

And since copying & pasting the entire URL is a common practice for everyone, it's something that can't be helped. But it's not something that should deter you from using it.

If anything, the positive far outweigh the negatives as it will help to clean up your GA data, provide further insights and gives you a better idea of how well your campaign is performing.

It's not 100% perfect, but it's better than what you are doing right now.

Examples of UTM Codes Gone Wrong

If you have been using tracking campaigns but realised that it's not the right way, now would be the time to fix it.

And have no fear, there are many large and small sites out there that misuse it:

  1. [Within the tweet below]

Ooof. pic.twitter.com/xvKXiTgnSZ

— Yehoshua Coren, Esq. PhD. MDiv. (@AnalyticsNinja) December 15, 2017

What's wrong with this & how to fix it?

  • you have the same sources of traffic split into ten different sources. The source of traffic for all of them should be 'facebook.com'
  • various mediums are used – social-ad, cpc, referral, facebook, social and (not set). Again, having 1 or 2, like 'social' and 'paid+social' makes more sense
  • it will screw up your "Channels" data as it will appear as (Other)

2. Yummly tracking as Yummly

Popular food website Yummly, which provides personalised recipe recommendations, is a major culprit.

When choosing a recipe and looking for directions on how to cook it, it will take you to the source of the recipes, which tends to be a blog post.

Unfortunately, they use terrible form campaign tracking when linking to other food bloggers:

https://www.example.com/chicken-recipe/?utm_campaign=yummly&utm_medium=yummly&utm_source=yummly

Gif of Yummly using UTM tracking the wrong way

What's wrong with this & how to fix it?

  • Google does not recognise 'yummly' as a source of traffic and medium
  • as a result, the Channels will see an increase of (Other) traffic
  • calling the campaign 'yummly' is very generic and doesn't offer any information about what campaign is run
  • you don't want to use the same value (i.e. yummly) for all parameters
  • they do not need to apply tracking within the external links. A better choice of way to track clicks would be to use 'Event Tracking.'

3. Even more examples of UTM gone bad are available

The amazing Annielytics, who knows much more about Google Analytics than I do and is one of my favourite GA experts, has listed some more scary examples of how not to use UTM tracking.

Annie also shares some brilliant advice on how to make the most out of Google Analytics on her site.

UTM Tagging Best Practices to Follow

So just to round up on best practices when applying campaign tracking on Google Analytics:

  • be consistent with your naming: e.g. facebook.com and facebook are two separate values
  • be consistent with case sensitivity. As a rule of thumb, keep it all lower case, e.g. social, email
  • have you noticed that I have been using plus '+' signs instead of spaces? Doing this will enable the campaign to appear as spaces on GA: e.g. 20+percent+off+promo will appear as '20 percent off promo'
  • be descriptive with your campaign name, e.g. 'spring+sale' instead of 'sale'
  • you can shorten the data-rich URLs using bit.ly or Google Link Shortener, and the data will still transmit to GA
  • be aware that the UTM parameters will be visible in the visitors' browsers. So don't use values that you don't want others to see
  • keep a spreadsheet template of your UTM parameters so that you know what to use (create a Google Doc)
  • never ever use UTM tracking within your own internal links. This will screw up your GA data in a big way

---

Google Analytics can be powerful for your business, but only if you have the accurate data (naturally).

By following these steps, it will go a long way to making sure that you can make the right decisions based on the data that is presented to you on GA.

Have you been struggling with UTM-related tasks? Do you require more information about how to track your campaigns? Or have you had success with your tracking?

Do leave a comment below.