Skip to content
English - United Kingdom
  • There are no suggestions because the search field is empty.

UTM tracking on sales page

Setup UTM tracking through google tag manager, for tracking membership marketing conversion

1. How the "UTM Cookie" Logic Works

Normally, GA4 looks at the URL parameters when a user lands on the site. If the user leaves and returns via a direct link, the original "Source" might be lost in certain reports. By storing UTMs in a first-party cookie, you can manually grab them later—even if the URL is "clean."

The Workflow

  1. Capture: A script reads utm_source, utm_medium, etc., from the URL.

  2. Storage: These values are saved into a cookie (e.g., _my_utm_data).

  3. Extraction: Google Tag Manager (GTM) reads that cookie.

  4. Reporting: GTM sends those values to GA4 as User Properties or Event Parameters.

 

2. Setting Up the Cookie Capture

If you don't already have a developer setting the cookie, you can use a Custom HTML Tag in Google Tag Manager to "set" the cookie whenever UTMs are present in the URL. 

// A simple snippet to grab UTMs and save them for 30 days
var urlParams = new URLSearchParams(window.location.search);
var utms = ['utm_source', 'utm_medium', 'utm_campaign'];
var cookieData = {};

utms.forEach(function(utm) {
    if (urlParams.has(utm)) {
        cookieData[utm] = urlParams.get(utm);
    }
});

if (Object.keys(cookieData).length > 0) {
    var d = new Date();
    d.setTime(d.getTime() + (30*24*60*60*1000)); // 30 days
    document.cookie = "stored_utms=" + JSON.stringify(cookieData) + ";expires=" + d.toUTCString() + ";path=/";
}

 

3. Pulling Cookie Data into GA4

Once the cookie exists, you need to tell GA4 to look at it.

  1. Create a Variable in GTM: * Type: 1st Party Cookie Variable.

    • Cookie Name: stored_utms (or whatever you named it).

  2. Create a Data Layer Variable (Optional): If your cookie is a JSON string, use a small custom JavaScript variable to parse out the specific value (e.g., just the utm_source).

  3. Update your GA4 Configuration Tag:

    • Under User Properties, add a row.

    • Property Name: original_source

    • Value:

 

4. Viewing the Data in GA4

Because you are sending these as User Properties, you can now see them in the Explore section of GA4.

Requirement

Action in GA4

Registration

Go to Admin > Custom Definitions and register your User Property (e.g., original_source).

Analysis

Create a "Free-form" exploration.

Comparison

Use your custom UTM property as a dimension to see which source leads to the highest Lifetime Value (LTV).

 

Why do this instead of standard GA4 tracking?

  • Cookie Persistence: Standard GA4 attribution can sometimes be overwritten by a newer "referral." Your custom cookie acts as a "First Touch" record.

  • Form Fills: You can easily grab the cookie value and inject it into hidden fields on your lead forms, syncing your marketing data directly with your CRM (like Salesforce or HubSpot).

A quick heads-up: Ensure your Privacy Policy and Cookie Banner are updated to reflect this. Since you're storing tracking data in a functional cookie, users in certain jurisdictions (like the EU) need to opt-in first!