Free Google Tag Manager templates
Five custom templates for the GA4 and consent problems Marc Alexander fixes most often. Free to use, with built-in tests and a guide for each.
The templates.
AI Assistant Traffic
Tells you when a visit came from ChatGPT, Perplexity, Gemini, Copilot, Claude or another AI assistant, from the referrer or the utm_source the assistant added. Send it to GA4 as a custom dimension.
Payment Referral Cleaner
Stops Klarna, Clearpay, PayPal, Stripe and 3-D Secure pages being credited with sales. It returns true for GA4's ignore_referrer setting when a customer comes back from a payment page.
Duplicate Purchase Guard
Spots an order ID already seen on an earlier page view, so a refreshed thank-you page doesn't send the purchase twice to GA4, Google Ads or Meta.
Consent Check
Checks a page for a missing or late Consent Mode default, and for analytics or advertising cookies set without consent. Run it in Preview mode after clicking Reject all.
IP Address Redaction
Shortens the visitor's IP address in a server container before Google Ads tags receive it, with an option to pass it in full only with advertising consent.
Marc updates the lists of AI assistants and payment domains as they change, so download again now and then for the latest.
How to add a template.
- Download the template file
- In Tag Manager, open Templates, then click New under Variable Templates, or Tag Templates for the Consent Check
- Click the three dots at the top right, choose Import, and pick the file
- Click Save, then create a variable or tag from the template
- Test it in Preview before you publish
IP Address Redaction goes in a server container, under the same menus. Each template also includes its tests, which you can run from the template editor.
Questions.
Are the templates free to use?
Yes, on any site, including client work. They're released under the Apache License 2.0. If you share a changed copy, keep the licence notice in it.
What can the templates access?
Each one asks only for the permissions it needs, and Tag Manager lists them when you import it. None of them sends data to Metric Owl or anyone else. They read things such as the referrer, a cookie or the consent state, and return a value for your own tags.
Will they be in the Community Template Gallery?
That's the plan, so you can add them from inside Tag Manager. Until then, download them here. This page will link to each one once it's listed.
Can Marc set them up for me?
Yes. They come from the problems Marc fixes in a GA4 mini audit and a Consent Mode v2 setup, and he can install and test them as part of either.
Last updated
Talk to Marc about it.
Tell Marc what's happening with your tracking. The quickest place to start is usually a GA4 mini audit: a prioritised list of what's broken and what to fix first.
Mini audit from £175.
Prefer to talk first? Choose "20-minute intro call" in the form.
Or email [email protected].