Send UTM Grabber Data to GA4 with Google Tag Manager
UTM attribution overview
UTM Grabber saves each visitor's UTMs and click IDs in first-party cookies, and keeps them while the visitor browses your site and when they come back later. GA4 only sees the source of the current visit. This guide sends UTM Grabber's saved values to GA4 with your lead event, so GA4 can report on the campaign that brought the lead, including the first one.
Google Tag Manager reads the values directly from UTM Grabber's cookies. This works on cached pages and with page speed plugins that delay scripts, and it needs no code on your site.
You need: UTM Grabber on your site, a Google Tag Manager container on your site, and a GA4 property.
1. Create a cookie variable for each value
In Google Tag Manager, go to Variables. Under User-Defined Variables, click New, then Variable Configuration.
- Choose 1st Party Cookie as the variable type.
- In Cookie Name, type the UTM Grabber cookie name, for example
utm_source. - Select URI-decode cookie. UTM Grabber saves values URL-encoded, so without this, "Google Ads" shows as "Google%20Ads".
- Name the variable, for example
HandL - utm_source, and save it.
Do this for each value you want in GA4. We recommend:
| Cookie name | What it holds |
|---|---|
utm_source, utm_medium, utm_campaign | The latest campaign |
first_utm_source, first_utm_medium, first_utm_campaign | The first campaign that brought the visitor |
traffic_source | The traffic type: Paid, Organic, Social, Referral, Direct or Other |
gclid | The Google Ads click ID |
2. Create a trigger for your lead
Fire the event only when a lead is complete. If you already have a trigger for your lead conversion, use it. If not, go to Triggers, click New, then Trigger Configuration, and create one of these:
- Thank-you page: choose Page View as the trigger type. Select Some Page Views, then set Page URL, contains, and the address of your thank-you page, for example
thank-you. - Form event: choose Custom Event as the trigger type, and type the event name that your form plugin pushes to the dataLayer.
Name the trigger, for example Lead - thank-you page, and save it.
3. Create the GA4 event tag
- In Measurement ID, enter your GA4 ID, which starts with
G-. In GA4, you find it under Admin > Data collection and modification > Data streams, in your web stream. - In Event Name, type
generate_lead. - Open Event Parameters and add one parameter for each variable from step 1. Type the parameter name, then click the variable icon next to the value and choose the variable. Use names that start with
handl_, so they do not mix with GA4's own campaign fields:
| Parameter name | Value |
|---|---|
handl_source | {{HandL - utm_source}} |
handl_medium | {{HandL - utm_medium}} |
handl_campaign | {{HandL - utm_campaign}} |
handl_first_source | {{HandL - first_utm_source}} |
handl_first_medium | {{HandL - first_utm_medium}} |
handl_first_campaign | {{HandL - first_utm_campaign}} |
handl_traffic_source | {{HandL - traffic_source}} |
handl_gclid | {{HandL - gclid}} |
Then click Triggering, choose the trigger from step 2, name the tag, for example GA4 - generate_lead, and save it.
4. Register the parameters in GA4
GA4 only shows event parameters in reports after you register them as custom dimensions.
- In GA4, go to Admin > Data display > Custom definitions. On the Custom dimensions tab, click Create custom dimensions.
- In Dimension name, type a name, for example
HandL first source. Set Scope to Event. In Event parameter, type the parameter name from step 3, for examplehandl_first_source. Save it. - Do this for each parameter.
- Go to Admin > Data display > Events, open the Key events tab, click New key event, type
generate_lead, and save it.
5. Test
- In Google Tag Manager, click Preview and enter your site address with test UTMs, for example
https://yoursite.com/?utm_source=test&utm_medium=test&utm_campaign=gtm_test. Google Tag Assistant opens your site in a new tab. - Browse to another page, then complete a test lead.
- In Google Tag Assistant, select the event of your lead, open the
GA4 - generate_leadtag, and check that eachhandl_parameter has the test value. - In GA4, go to Admin > Data display > DebugView, and check that
generate_leadappears with itshandl_parameters. - In Google Tag Manager, click Submit, then Publish.
The custom dimensions show in GA4 reports 24 to 48 hours after the data is sent. They only show data from leads after this setup.
Notes
- Use
%20for spaces in your UTM links, not+. A+stays in the saved value, sosat+imageryshows as "sat+imagery" in GA4. - GA4 cuts parameter values after 100 characters. Keep long values, such as full page URLs, out of the parameters.
- If you use a consent banner, UTM Grabber only saves cookies after the visitor accepts, so the
handl_parameters are empty for visitors who decline.