How to Hide Google Analytics UTM Parameters Using Google Tag Manager

Google Analytics UTM parameters are a very handy way to track your online marketing efforts. They’re used to capture important reporting data and they help you figure out which posts, banners or emails bring the most traffic and customers to your website.

Although pretty much all digital marketers should be using Google Analytics UTM parameters, we’ve seen that many of them are still not doing it. There are probably a couple of reasons for this.

  1. Marketers are not aware of the benefits of using Google Analytics UTM parameters.
  2. There are so many different marketing channels and adding those parameters is sometimes forgotten.
  3. Marketers believe that the long URLs scare the users away and they won’t click on the links when they see the strange website URLs with parameters. (Pretty much make an URL less trustworthy.)
Hide long UTM parameters
Who would want to click on this long link? 🤔


In the following tutorial, we will focus on the third reason and show you how to hide the UTM parameters with Google Tag Manager, so that you could still keep using them.

Why should you hide any Google Analytics UTM parameters?

In some cases, you’d really like to track the performance of different links, but don’t want to attach the “ugly” UTM parameters to the end of the URLs. Let’s go through some of the following examples to get a better picture.

1. LinkedIn Profile Page

It’s useful to know how many people click on the link on your company page on LinkedIn so that you can separate this traffic from the rest.

At the same time, you probably don’t wish to see those ugly Google Analytics UTM parameters at the end of your company’s website address.

Short URL, no UTM parameters

2. E-mail Sales Letter

Would you like to be a hardcore data-driven sales person who knows exactly how much your specific lead knows about your business and your services before you make a call?

Email UTM parameters

If you attach the Google Analytics UTM parameters to the end of this website URL, you can analyze the user journey later with tools like Google Analytics and HotJar. After that you can know exactly what a specific person knows about your business and your services before you call her or send another email.

But I guess that in a lot of cases, you wouldn’t want to drive your potential customer to an URL like this:

https://holini.com/?utm_source=signature&utm_medium=email&utm_campaign=Taavi

3. Facebook Profile Page

How would you know the number of people who click on the link on your Facebook profile page?

And how could you separate this traffic from the rest?

Facebook UTM parameters

These are just some of the quick examples from a variety of places where you normally wouldn’t use any UTM parameters.

How to hide the UTM parameters?

You can use simple URL fragments and some Google Tag Manager tricks to hide the UTM parameters and still keep tracking different traffic sources with Google Analytics. For this, you can use a feature in Google Tag Manager, called the Lookup Table.

This is probably the easiest way to do it.

So how can you turn your long URLs with Google Analytics UTM parameters like this…

https://holini.com/?utm_source=linkedin&utm_medium=social&utm_campaign=profile+page

into short and sweet web links that can look something like this (and still track your traffic source)?

https://holini.com/#agency

Step 1

First of all, you need to have Google Tag Manager installed on your website to make this happen. If you’d like to learn more about Google Tag Manager, you should take a look at this amazing Google Tag Manager tutorial for beginners.

While this tool allows users with even minimal technical experience to start creating tags, triggers and variables in a matter of minutes, the installation itself may require an upfront effort and close collaboration with your web development or IT team.

Simo Ahava’s post called Tag Management Does Not Make IT Redundant pointed out 10 suggestions for making the deployment and the use of tag management systems more manageable for both the marketers and the IT department. Highly recommended reading if you’re either a developer or a marketer who’s taking the first steps towards becoming a tag management ninja.

Bear with me. It’s not THAT difficult. We’ve got you covered!

Step 2

  1. In Google Tag Manager, go to the Variables section in the left hand menu.
  2. Create a new ‘User-Defined Variable’ in Google Tag Manager and for the ‘Variable Type’ choose: ‘URL’.  (Variables > User-Defined Variables > New > URL)
  3. In the configuration settings, choose the ‘Component Type’ to be ‘Fragment’.
  4. Give a name to your new variable that you will remember, like ‘URL – Fragment’.

    I recommend reading the Google Tag Manager Naming Strategies to Organize Your Container article written by Zee Drakhshandeh to learn more about the naming strategies.

  5. Here’s how it looks like in Google Tag Manager:

URL Fragment in Tag Manager

Step 3

Now, you’ll need to create three Lookup Table Variables in Google Tag Manager – one for utm_source, one for utm_medium, and one for utm_campaign. Then you’ll need to choose the URL fragment as the input variable for each of the Lookup Tables and match it with the values for the source, medium, and campaign that you would like to send to your Google Analytics property.

A step-by-step guide

Let’s go through an example and create a custom link for your Sales Letter, LinkedIn and Facebook profile pages.



Set up a Lookup Table for different Sources

  1. Create a new ‘User-Defined Variable’ in the Google Tag Manager and for the ‘Variable Type’ choose: ‘Lookup Table’. (Variables > User-Defined Variables > New > Lookup Table)
  2. Choose the {{URL – Fragment}} as the ‘Input Value’ in the configuration settings.
  3. Give a name to your new variable that you will remember, like ‘Lookup – URL – Fragment – Source’. 
  4. Now, you’ll need to choose the input variable that the Lookup Table will reference to match the appropriate value
    • If the fragment of the page URL is agency, then return the respective ‘Output’linkedin
    • If the fragment of the page URL is 1, then return the respective ‘Output’signature
    • If the fragment of the page URL is services, then return the respective ‘Output’facebook

Lookup Table - Source

Set up a Lookup Table for different Mediums

  1. Create a new ‘User-Defined Variable’ in the Google Tag Manager and for the ‘Variable Type’ choose: ‘Lookup Table’. (Variables > User-Defined Variables > New > Lookup Table)
  2. Choose the {{URL – Fragment}} as the ‘Input Value’ in the configuration settings.
  3. Give a name to your new variable that you will remember, like ‘Lookup – URL – Fragment – Medium’. 
  4. Now, you’ll need to choose the input variable that the Lookup Table will reference to match the appropriate value:
    • If the fragment of the page URL is agency, then return the respective ‘Output’social
    • If the fragment of the page URL is 1, then return the respective ‘Output’email
    • If the fragment of the page URL is services, then return the respective ‘Output’social

Lookup Table - Medium

Set up a Lookup Table for different Campaign Names

  1. Create a new ‘User-Defined Variable’ in the Google Tag Manager and for the ‘Variable Type’ choose: ‘Lookup Table’. (Variables > User-Defined Variables > New > Lookup Table)
  2. Choose the {{URL – Fragment}} as the ‘Input Value’ in the configuration settings.
  3. Give a name to your new variable that you will remember, like Lookup – URL – Fragment – Campaign Name’.
  4. Now, you’ll need to choose the input variable that the Lookup Table will reference to match the appropriate value:
    • If the fragment of the page URL is agency, then return the respective ‘Output’profile page
    • If the fragment of the page URL is 1, then return the respective ‘Output’Taavi
    • If the fragment of the page URL is services, then return the respective ‘Output’ – profile page

Lookup Table - Campaign

Step 4

The final setup piece is to send the output of your Lookup Tables into Google Analytics. You can use your generic Universal Analytics Page View tag that is already set up in Google Tag Manager.

  1. Open your Google Analytics ‘Page View’ tag.
  2. Expand the ‘More settings’ menu, then the ‘Fields to Set’ menu, and click ‘+Add Field’.
  3. Enter the following three ‘Field Names’ with the values of the three corresponding Lookup Tables:
    • campaignSource – {{Lookup – URL – Fragment – Source}}
    • campaignMedium – {{Lookup – URL – Fragment – Medium}}
    • campaignName – {{Lookup – URL – Fragment – Campaign Name}}

The values will now be sent to Google Analytics just as if you were using the UTM parameters: utm_source, utm_medium and utm_campaign.

Here’s how it looks like in the Google Tag Manager:

Google Tag Manager Pageview Tag

Step 5

Now it’s time to test if everything you’ve done works properly:

  • Enable the ‘Preview Mode’. Click on the arrow next to the ‘Publish’ button and select ‘Preview’.
  • Load your web page with ‘#agency’ appended to the end of your URL, like this: https://yourdomain.com/#agency
  • Then, using Google Tag Manager’s Preview Mode, open the ‘Page View’ tag and look through the ‘Variables’ menu.
  • You should see the ‘Lookup – URL – Fragment – Campaign Name’, ‘Lookup – URL – Fragment – Medium’ and ‘Lookup – URL – Fragment – Source’ variables fire with ‘profile page’, ‘social’ and ‘linkedin’ as values (‘agency’ comes after the hashtag in your URL).

Take a look at the screenshot:

GTM Preview Mode

You should also check your Real-Time Traffic Sources report to see which mediums and sources referred the users who are on your site right now. You should see yourself in this report as well.

Here are a couple of examples

LinkedIn profile page

LinkedIn UTM parameters

E-mail Sales Letter

E-Mail UTM parameters

Facebook profile page

Facebook UTM parameters

Things to keep in mind

  • You can have hundreds of rows in your Lookup Table and it’s still very fast.
  • The Lookup Table is an exact match only in Google Tag Manager. To use partial matches you’d need to either modify the strings before the Lookup Table accesses them, i.e. create a Custom JavaScript Variable which strips the elements down.
  • Always test your changes before you publish.

Why are URL shorteners not always a good solution?

Even though using shorteners (e.g bit.ly) is a good way to hide tracking information and make URLs shorter, they still do not seem be 100% trustworthy and there are a lot of reasons why I prefer not to use them.

Things to keep in mind when using URL shorteners

  • URL shorteners record click data, Google Analytics records hits, sessions, and users. Technically, those tools are not going to show the same data because they are tracking different things.
  • Always attach your Google Analytics UTM parameters to the end of the URL before you drop it in your URL shortener. If you’re not doing this, all of your short links are feeding zero useful data, especially if people are coming to your site from mobile apps, desktop email clients or non-HTML documents.

In some cases, you also might want to put UTM tags on 301 redirects.

Final Thoughts

URL fragments are much more acceptable and trustworthy than UTM parameters and shortened URLs.

I believe that it’s not too much hassle to go to Google Tag Manager before publishing a new link and adding some values to your Lookup Tables. Especially, if those are the links that you want to track without showing Google Analytics UTM parameters.

The inspiration for this post came from the articles written by well-known GTM practitioners:

Hopefully you learned something new. Feel free to share any other feedback on Twitter @holini or in the comments section below. 

9 Comments. Leave new

  • my redirect table is dropping the appended GTM input

    Do you have a resource tip on how to keep the tracking parameter on the redirect? or my options? i can possibly create (…/#agency) that redirect to the long URL with tracking but then that defeats the purpose of the lookup table…right?

    thanks in advance

  • I’ve understood the basics but I am unable to understand the name of input and output.
    First of all, is it possible to totally hide? Just to say that input is left blank. Is it meaningful?
    Secondly, let’s say I imagine I have n campaigns made with x medium and y sources, how should I manage for a right naming?

    Moreover, what’s input and what’s output? The parameter after utm_campaign when I use UTM is output? If so, may I leave the input blank or set something like a number.

    What does it happen whether:
    – 1= linkedin
    – 2= facebook
    – 3 = instagram

    1=e-mail
    2= social
    3= blog

    1= client1
    2= client2
    and so on….

    how should I manage client1, social and facebook #111?

    Thanks

    • Hi,

      If you’d like to totally hide, you should put UTM tags on 301 redirects.
      Only the utm_source parameters is required but I highly recommend using all 3 parameters (source, medium and campaign).

      Your example: Client1, social, facebook.com

      Now, you should update all your lookup tables:

      Lookup – URL – Fragment – Campaign Name
      1 -> Client1 (input -> output)

      Lookup – URL – Fragment – Medium
      1 -> social

      Lookup – URL – Fragment – Source
      1 -> facebook.com

      URL that you should use: yourdomain.com/#1 that is equal to yourdomain.com/?utm_source=facebook.com&utm_medium=social&utm_campaign=Client1

      Hope this helps.

  • Hi Taavi,

    I’ve set up my tags as instructed (you explained it very well), and I see that they are all firing correctly when I used GTM Preview mode.

    However, I’m now trying to see how that translates to Analytics. I’m not actually sure if GA is displaying the Source/Medium/Campaign according to the fragments I’ve created. How would I go about testing that? I’m looking at the Realtime reports, and the Acquisition reports, but I can’t see that the UTM parameters are being tracked. They only show up in reports when I use the full UTM URL.

    • Hi. Sorry for the late response.

      You don’t need to create a custom report. You should see those Source/Medium/Campaign parameter values in your Acquisition reports and also in your Real-Time report.

      Make sure you haven’t created any filters that might prevent this data from being processed by Google Analytics. In addition, make sure your fragment remains at the end of the URL when the page is loaded.

      Recommend reading this article about UTM parameters to learn more about debugging: https://holini.com/utm-parameters/

      What’s the URL of you website? (I will double-check your tracking quickly)

    • Great question Palexk, I came across this as well and what’s not explicitly explained here is with Step 4, how using “fields to set” on pageview overrides default parameters for that hit (this is a good thing, you want this to happen). I was puzzled by this myself, and after some research on “fields to set”, campaignName, campaignSource, and campaignMedium are the field names that GTM recognizes to replace with the custom Campaign, Source and Mediums and sends it along with that pageview hit.

      Lunametrics talks about it here: https://www.lunametrics.com/blog/2016/09/27/fields-set-google-tag-manager/

  • […] How to Hide Google Analytics UTM Parameters Using Google Tag Manager […]

  • […] 1) You can use simple URL fragments and some GTM tricks to hide the UTM parameters and still keep tracking different traffic sources with Google Analytics. All you need to do is use a feature in Google Tag Manager called the Lookup Table. You can read more about it here. […]

You must be logged in to post a comment.
58 Shares
Share
Share
Pocket
Buffer
Tweet