# Free GTM + GA4 Container Template (MIT Licensed) | Thmpsn.digital
> Source: https://thmpsn.digital/posts/gtm-ga4-container-template
Measurement / October 29, 2026

# A Free GTM Container for GA4, With the Setup Steps People Skip

26 tags, 28 triggers, and 15 variables for lead-gen, ecommerce, and content sites. It's MIT licensed, so you can use it anywhere, including on client work.

By [Jonathan Thompson](https://thmpsn.digital/about/jonathan-thompson)

We’ve published the Google Tag Manager container we start client installs from. It’s a single JSON file you import into GTM. It sets up the Google tag, sends GA4 the events most sites need, and comes organized into eight folders so you can see what each tag is for and delete the ones you don’t.

**[Get it on GitHub: thmpsndigital/gtm-ga4-template](https://github.com/thmpsndigital/gtm-ga4-template)**

The repo has the container, a reference for every tag, trigger, and variable, and copy-paste data layer snippets for developers. It’s MIT licensed, so you can use it on client sites, commercial or not.

## What it tracks

The container is built for three kinds of site, and you keep the parts that apply:

- **Lead-gen sites:** form submissions, phone and email clicks, CTA clicks, outbound links, and file downloads.

- **Ecommerce stores**, WooCommerce or Shopify: all 11 of GA4’s recommended ecommerce events, from `view_item_list` through `purchase` and `refund`.

- **Content sites:** scroll depth at 25, 50, 75, and 90%, YouTube video engagement, site search, and 404s.

It also includes Google Consent Mode v2 tags (paused by default), a hostname lookup that sends production and staging traffic to separate GA4 properties, a `?debug=true` URL switch that turns on GA4 DebugView without GTM Preview, and `user_id` and `user_type` user properties when your site provides them.

## The events it sends

Event names follow GA4’s recommended events wherever one exists, so the standard reports and the ecommerce funnel work without remapping. The rest use plain snake_case.

EventFires whenNeeds site code?

`page_view`Every page load, with a `content_group`No

`scroll`25, 50, 75, and 90% of the pageNo

`outbound_click`A link to another hostnameNo

`phone_click`, `email_click`A `tel:` or `mailto:` linkNo

`file_download`A link to a PDF, Office file, CSV, ZIP, and similarNo

`cta_click`An element with a CTA classNo

`generate_lead`A native form submission, or a data layer push for AJAX formsOnly for AJAX forms

`video_start`, `video_progress`, `video_complete`An embedded YouTube video starts, passes 25/50/75%, or endsNo

`view_search_results`A site searchYes

`page_not_found`A 404 page loadsYes

`sign_up`A newsletter or account sign-upYes

Ecommerce (11 events)Product views, cart, checkout, purchase, refundYes

The full parameter list for each event is in the [README](https://github.com/thmpsndigital/gtm-ga4-template#events-it-sends).

## How to import it

- Download `container.json` from the repo.

- In GTM, go to **Admin → Import Container** and choose the file.

- Pick a workspace, or create a new one.

- Choose **Merge**, then **Rename conflicting tags**. Merge keeps whatever is already in your container. Overwrite would replace it.

- Replace the `G-XXXXXXXXXX` placeholder with your Measurement ID, and put your own hostnames in the `lu - GA4 ID by Hostname` lookup. It ships with `www.example.com` and `staging.example.com`.

- Edit the `lu - Content Group` lookup to match your URL structure.

- Delete the tags you don’t need. A lead-gen site has no use for the ecommerce folder.

- Preview, check every tag in GTM Preview and GA4 DebugView, then publish.

Load the container with the standard GTM snippet (`GTM-XXXXXX`). A container loaded through `/gtag/js` under a `G-` ID runs only Google-provided tags, which would block the Custom HTML consent tags.

GA4’s Enhanced Measurement already covers scrolls, outbound clicks, file downloads, site search, and video. The template replaces those with tags that send more detail, so turn the matching Enhanced Measurement toggles off in GA4 or you’ll count those events twice. Leave page views and form interactions on.

## The setup steps people skip

Publishing the container is half the job. Three GA4 settings decide whether the data is usable, and none of them happen in GTM.

**Register the custom dimensions.** Any parameter GTM sends that GA4 doesn’t already know about, such as `link_text`, `form_id`, `file_extension`, or `content_group`, is collected but doesn’t appear in reports until you register it under **Admin → Custom definitions**. The README lists all 16 event-scoped parameters and the one user-scoped one (`user_type`). Registration isn’t retroactive, so do it before you publish, not after you go looking for the data.

**Mark your key events.** GA4 doesn’t know which events count as conversions. In **Admin → Events**, mark `generate_lead`, `purchase`, `sign_up`, and `phone_click` as key events, plus `cta_click` if your CTAs are high-value. Until you do, they won’t show up as conversions in GA4, and you have nothing to import into Google Ads.

**Change data retention.** GA4 keeps event-level data for two months by default. Change it to 14 months under **Admin → Data settings → Data retention**. Retention limits how far back explorations, funnel explorations included, can look, and raising it later doesn’t bring back data that has already aged out.

The README’s checklist covers the rest: activating the internal traffic filter (it sits in Testing mode and filters nothing until you do), referral exclusions for payment gateways and booking tools, cross-domain tracking, and linking Search Console.

## Why we built it

Most GA4 installs we’re asked to look at have the same gaps: Enhanced Measurement left on beside custom tags, parameters sent but never registered, a form that fires `generate_lead` twice, and no key events marked. None of it throws an error, so the problem usually surfaces months later, when someone builds a report and the numbers don’t add up.

So we turned the setup into a container and documented the GA4 steps that live outside GTM beside it.

We’re maintaining it, too. It’s the container we start our own installs from, so when we improve our setup, the template gets the same change, and when GA4 or GTM changes how something works, we update it. Watch the repo on GitHub to see changes as they land. If something fails on import, or doesn’t behave as described, [open an issue](https://github.com/thmpsndigital/gtm-ga4-template/issues) and we’ll fix it there.

If you’d rather have someone set up GA4 and GTM for you, or check the setup you already have, [get in touch](https://thmpsn.digital/contact).

**Want yours read the same way?** The 20-minute call includes a live look at how your traffic is being counted. [Book it here](https://thmpsn.digital/contact), or [read the rest](https://thmpsn.digital/posts).