Data Analytics

Hiding UTM Tracking Params: A Guide with Google Tag Manager

Google Analytics 4 (GA4) is a powerful tool for tracking user behavior and campaign performance. UTM parameters are essential for understanding traffic sources, mediums, and campaigns, but their long and unattractive URLs can sometimes discourage users from clicking. In this blog, we’ll show you how to hide UTM parameters in GA4 using Google Tag Manager (GTM) while maintaining accurate campaign tracking.

Why Hide UTM Parameters in GA4?

Here are some scenarios where hiding UTM parameters can improve user experience:

  1. Social Media Profiles
  2. Long URLs like https://www.starluxetech.com/?utm_source=linkedin&utm_medium=social&utm_campaign=profile might look unprofessional. A cleaner alternative such as https://www.starluxetech.com/#agency is more inviting.

  3. Email Campaigns
  4. While UTM parameters provide valuable insights, URLs like https://example.com/?utm_source=email&utm_medium=email&utm_campaign=newsletter might seem untrustworthy in emails. Clean URLs look more polished and reliable.

  5. Sales Funnels
  6. Tracking campaign data is vital, but exposing UTM parameters can clutter URLs and disrupt the user journey. Clean URLs allow a seamless experience without sacrificing data.

Step-by-Step Guide to Hide UTM Parameters for GA4

Step 1: Install Google Tag Manager

  • Ensure Google Tag Manager is installed on your website. If it’s not, collaborate with your developer or refer to GTM setup tutorials to get started.
  • Step 2: Create a URL Fragment Variable

  • In GTM, navigate to the Variables section.
  • Create a new User-Defined Variable and select the URL type.
  • Under Component Type, select Fragment.
  • Name this variable, e.g., SL - fragment URL.

Step 3: Set Up Lookup Table Variables

Lookup Table for Source

  • Variable Name: SL - Lookup - URL - Fragment - Source.
  • Input: Fragments like #email, #linkedin.
  • Output: Campaign sources like email, linkedin.

Lookup Table for Medium

  • Variable Name: SL - Lookup - URL - Fragment - Medium.
  • Input: Same fragments.
  • Output: Mediums like email, social.

Lookup Table for Campaign

  • Variable Name: SL - Lookup - URL - Fragment - Campaign Name.
  • Input: Same fragments.
  • Output: Campaign names like newsletter, profile.

Step 4: Send Parameters as GA4 Events

In GTM, create a GA4 Event Tag:

  • Go to Tags > New > GA4 Event.
  • Configure the tag to send campaign data to GA4.

Map the Lookup Variables to GA4 Parameters:

Event Name: Use something descriptive like custom_campaign.

Parameters:

  • source: {{Lookup – Fragment – Source}}
  • medium: {{Lookup – Fragment – Medium}}
  • campaign: {{Lookup – Fragment – Campaign}}

This setup ensures GA4 receives the hidden UTM parameter values as custom event data.

Step 5: Test Your Setup

  • Enable GTM’s Preview Mode.
  • Visit a URL like https://example.com/#linkedin.
  • Open the Variables tab in the Preview Mode to verify that your lookup variables (source, medium, and campaign) populate correctly.
  • Check GA4’s DebugView to confirm the event is sent with the correct parameter values.

Examples of Clean URLs with Tracking in GA4

LinkedIn Profile

  • URL: https://example.com/#agency
  • Parameters Sent: source=linkedin, medium=social, campaign=profile.

Email Campaign

  • URL: https://example.com/#1
  • Parameters Sent: source=email, medium=email, campaign=newsletter.

Facebook Page

  • URL: https://example.com/#facebook
  • Parameters Sent: source=facebook, medium=social, campaign=profile.

Conclusion

Hiding UTM parameters with Google Tag Manager in GA4 keeps URLs clean and professional while retaining accurate tracking. It’s a simple way to enhance user experience and maintain campaign insights.