Without Google Tag Manager, tracking code piles up on a WordPress site one paste at a time. A GA4 snippet goes into the theme header and an ads pixel arrives through a plugin. A year later nobody can say which scripts still run or what they send.
That mess costs you in three ways:
- Every new tag needs a code edit, and a typo in a theme file can break the site.
- Your cookie banner has no single place to switch tracking on or off.
- Old tags keep running because nobody is sure what is safe to remove.
Google Tag Manager (GTM) moves every tag into one container. You edit and test the tags in a web interface, then publish each change as a version you can roll back.
The setup we use is small on purpose: one container per site with a handful of tags, and a rule that nothing goes live without a preview. Each part is below, in the order we'd build it. If you'd rather hand the work over, our analytics and tracking service builds this same structure for you.
What Google Tag Manager Does
Google Tag Manager is a free tag management system from Google. You add its container snippet to your site once. After that, every tracking script is set up inside GTM and stays out of your theme.
A container holds 3 kinds of things:
Component | What It Does | Example |
|---|---|---|
Tag | Sends data to a platform | A GA4 event tag that sends |
Trigger | Decides when a tag fires | Fire when Click URL contains |
Variable | Supplies a value to tags and triggers |
|
GTM has no reports of its own. It decides which script runs and when, and Google Analytics 4, Google Ads or another platform stores the data and shows the reports.

The flow is short. A page loads the container, the container fires the tags whose triggers match and each tag sends its data to its own platform.
Do You Need Google Tag Manager?
Not every site does. Google has upgraded the plain Google tag (gtag.js) with features that used to need Tag Manager, including debugging and version control.
Google's own comparison of the Google tag and Tag Manager has the details. A blog that runs GA4 and nothing else can stay on the Google tag.
GTM earns its place when one of these is true:
- The site runs tags from more than one company, such as GA4 next to an advertising pixel.
- You want custom events for forms, buttons or redirect links.
- You have visitors in the EEA, the UK or Switzerland and must pass their consent choices to Google.
- More than one person changes tracking, so you need versions and permissions.
- A store has to send purchase data to analytics and ad platforms.
Our advice is simple. We'd skip GTM on a site with a single analytics tag and add it on the day a second tag or a consent banner arrives.
If you'd rather leave Google's tools altogether, most privacy-first analytics products install with one script and need no tag manager. Our guide to Google Analytics alternatives covers what you gain and lose with them.
Account and Container Structure
Structure is the part people regret later, because moving tags from one account to another is manual work. The rules we follow are short.
- One account per business. The business owns the account and adds an agency or freelancer as a user. An account owned by the agency becomes a problem on the day the contract ends.
- One web container per website. Google's setup guide says the same. A container shared by unrelated sites will fire one site's tags on the other sooner or later.
- At least 2 administrators. Google warns that an account with a single admin can lose access to its tags if that person becomes unavailable.
- Few people with publish rights. Container permissions run Read, Edit, Approve and Publish. Edit is enough for most collaborators, because it lets them build and preview without pushing anything live.
- Staging traffic kept out. A staging copy of the site loads the same container and sends test visits into your live reports. A trigger exception on the staging hostname stops that.
Install Google Tag Manager on WordPress
The first job is the account and the container.
- Go to tagmanager.google.com and click Create Account.
- Enter the business name as the account name and pick your country.
- Enter the site's domain as the container name and choose Web as the container type.
- Accept the terms and note the container ID, which starts with
GTM-.
GTM then gives you 2 pieces of code. The first goes as high in the <head> as possible. The second is a <noscript> fallback that goes right after the opening <body> tag.
On WordPress there are 4 ways to add them. We'd choose by how much page data you want to see inside GTM.
Method | What It Adds | Good Fit For |
|---|---|---|
Site Kit by Google | The container snippet, through its Tag Manager module | A site that already uses Site Kit and needs no extra page data |
GTM4WP | The snippet plus a data layer with post type, categories, author, login status and WooCommerce ecommerce events | Content sites and stores that want WordPress data in GTM |
GTM Kit | The snippet plus data layer events for WooCommerce, Easy Digital Downloads and Contact Form 7 | Stores and sites built on those plugins |
Manual code | Both snippets, printed on the | Developers who want no extra plugin |
Site Kit, GTM4WP and GTM Kit are all free on WordPress.org. For most WordPress sites we'd start with GTM4WP or GTM Kit, because the data layer they add saves custom code later.
Whichever method you pick, only one of them should place the snippet. A snippet added by two plugins, or by a plugin and the theme, loads the container twice and doubles every event.
It is wise to check your caching or performance plugin as well. A setting that delays all JavaScript until the first click or scroll also delays GTM, so a visitor who reads the page and leaves is never counted. We recommend excluding the container script from that delay, or accepting the gap knowingly.
The Tags We Add to Every Container
A new container needs very little. We add the Google tag, check what GA4 already records and then build only the events that are missing.
The Google Tag
The Google tag is the base tag. It loads your GA4 property, sets its cookies and sends the page view and the other automatic events.
- In GTM, open Tags and click New.
- Choose the tag type. In a container Google has upgraded, pick the Google Analytics destination tag. In an older container, the type is called Google Tag. Both take the same Tag ID.
- Enter the Tag ID, which is the
G-ID of your GA4 web data stream. - Set the trigger to Initialization - All Pages.
- Name the tag and save it.
If the site already prints a GA4 snippet from the theme or a plugin, that snippet should be removed in the same release. Two sources of GA4 on one page count every page view twice.
Google is also moving containers to a consolidated setup, shown in GTM as a banner that offers to optimize the container. The upgrade keeps your event tags and triggers and moves the Google tag settings into a Settings tab. We'd accept it in a workspace, check it in preview and then publish.
Events GA4 Already Collects
Before you build any event tag, check what GA4 records without help. With enhanced measurement switched on in the web data stream, the Google tag already sends these:
- Page views
- Scrolls, once per page, when a visitor reaches 90% of the page
- Outbound clicks, meaning clicks on links that lead to another domain
- Site searches
- Video engagement
- File downloads
- Form starts and form submits
Rebuilding any of these in GTM sends the event twice. The tags below fill the gaps that enhanced measurement leaves.
Events We Add in GTM
Event Name | Trigger | Why GA4 Misses It |
|---|---|---|
| Custom Event pushed when the form plugin confirms the message was sent | A lead should count only after the form succeeds, with the form's name attached |
| Click - Just Links, where Click URL contains | Redirect links such as |
| Click - All Elements, matched by a CSS selector | Buttons that keep the visitor on the site are not recorded at all |
| Scroll Depth at 25, 50 and 75 percent | Enhanced measurement reports only the 90% mark |
| Page View, where Page Title contains your 404 title | A 404 arrives as an ordinary page view |
Two GA4 settings finish the job. generate_lead should be marked as a key event, and a parameter such as form_id shows up in reports only after you register it as a custom dimension.
Here is the redirect-link event built from start to finish. The other click events follow the same steps.
- Open Variables, click Configure and enable Click URL and Click Text.
- Create a trigger of the type Just Links. Set it to fire on some link clicks, with the condition Click URL contains
/go/. - Turn on Wait for Tags, so the tag can fire before the browser leaves the page.
- Create a tag of the type Google Analytics: GA4 Event and enter your Measurement ID.
- Set the event name to
affiliate_clickand add 2 parameters:link_urlwith the value{{Click URL}}andlink_textwith{{Click Text}}. - Attach the trigger, save and open preview mode.
Google Ads tags sit on top of this same base. Our Google Ads conversion tracking guide covers the conversion tag and enhanced conversions.
Naming Convention
A container full of tags named "GA4 new" and "test 2" is as hard to audit as the hardcoded scripts it replaced. We name everything by one pattern, so the tag list sorts itself by platform.
Item | Pattern | Example |
|---|---|---|
Tag | Platform - Type - Detail | GA4 - Event - generate_lead |
Trigger | Type - Condition | Click - Just Links - /go/ |
Variable | Prefix - Name | DLV - form_id, Const - GA4 Measurement ID |
Folder | Platform or purpose | GA4, Ads, Consent |
Version | What changed, in plain words | Add lead event to contact form |
GA4 event | Lowercase words joined by underscores |
|
GA4 has its own event naming rules, and they are strict:
- An event name starts with a letter.
- It uses only letters, numbers and underscores, with no spaces.
- It is 40 characters or shorter. Google says Analytics doesn't process a longer name.
- It is case sensitive, so
Generate_Leadandgenerate_leadbecome 2 different events.
Where Google has a recommended event name, such as generate_lead, sign_up or purchase, we use it. GA4 can then fill its built-in dimensions and metrics from the event and its parameters.
Data Layer Basics
The data layer is a JavaScript array on the page that GTM reads. Your site pushes facts into it, such as "a lead form was sent", and GTM turns those facts into triggers and variables.
It is the dependable way to track anything important. A click trigger tied to a CSS class breaks when a theme update renames the class. A data layer event keeps working, because your own code sends it.
A push looks like this:
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'generate_lead',
form_id: 'contact',
form_location: 'footer'
});
</script>The push should run when the form plugin reports success. In GTM, 3 things pick it up:
- A Custom Event trigger with the event name
generate_lead - Data Layer Variables for
form_idandform_location - A GA4 Event tag that sends
generate_leadwith both values as parameters
Contact Form 7 makes a good example, because it announces a sent message with a browser event called wpcf7mailsent. This listener turns that event into a data layer push:
<script>
document.addEventListener('wpcf7mailsent', function (event) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'generate_lead',
form_id: String(event.detail.contactFormId)
});
});
</script>We recommend running it in preview mode against your own form before you publish, because form plugins do change these events over time. If you use another plugin, such as WPForms, swap in the success event from its documentation.
On WordPress you rarely write every push by hand. GTM4WP adds page details such as post type, category and author to the data layer, and both GTM4WP and GTM Kit push ecommerce events for WooCommerce stores.
One rule has no exceptions. Names, email addresses and phone numbers stay out of anything you send to GA4, because Google's Analytics policies forbid personally identifiable information there.
Triggers for Clicks, Forms, Scroll and Outbound Links
Triggers are where most tracking goes wrong, because each type listens for a different thing in the browser. These are the ones we use and the catch with each.
Goal | Trigger Type | Settings | The Catch |
|---|---|---|---|
Link clicks | Click - Just Links | Click URL contains | The built-in Click variables are off until you enable them |
Button clicks | Click - All Elements | Click Element matches a CSS selector such as | A click on an icon or a span inside the button doesn't match |
Form leads | Custom Event, or Element Visibility on the success message | Event name | The Form Submission trigger needs a standard browser submit, which many form plugins don't use |
Scroll depth | Scroll Depth | Vertical Scroll Depths, Percentages: 25, 50, 75 | On a page that fits in one screen, all 3 marks are already in view and fire at once |
Outbound links | None | GA4 enhanced measurement | Only same-domain redirect links need a GTM trigger |
Forms deserve one more note. GTM's Form Submission trigger has a Check Validation option that fires only when the form is successfully sent, but it depends on the browser's own submit event. Many WordPress form plugins send the form with JavaScript and show a message without reloading the page, so the trigger may never fire.
That is why we tie leads to the plugin's success event or to the success message. Both exist only after the form went through.
Links that you place on other sites are a different job. A bio link or a newsletter link is tracked with UTM parameters, which our guide to tracking link clicks with UTM parameters explains.
Consent Mode v2 With a CMP
Google's EU user consent policy covers visitors in the European Economic Area, the UK and Switzerland. If you have those visitors, you must collect consent and pass each visitor's choice to Google. Consent mode is how the Google tag receives that choice.
Version 2 uses 4 consent types:
ad_storage: advertising cookiesad_user_data: sending user data to Google for advertisingad_personalization: personalized advertisinganalytics_storage: analytics cookies
A consent management platform (CMP) shows the banner and reports the choice. In GTM the wiring has 4 parts:
- Add your CMP's tag template from the Community Template Gallery.
- Fire it on the Consent Initialization - All Pages trigger. This trigger runs before every other trigger, so the default consent state exists before any tag loads.
- Leave Google's own tags as they are. GA4, Google Ads and Floodlight tags have built-in consent checks and adjust to the visitor's choice.
- For other vendors' tags, open Advanced Settings and then Consent Settings, and require the matching consent type. An advertising pixel, for example, should require
ad_storage.
The Consent Overview lists every tag's consent setting in one place. It is switched on under Admin, in Container Settings.
Our Google Consent Mode v2 guide compares basic and advanced mode and walks through Cookiebot, OneTrust, iubenda and Complianz.
Google also offers Google tag gateway for advertisers, which serves the Google tag from your own domain and has a guided setup for sites on Cloudflare. It can recover some lost measurement. It changes nothing about consent, and the same visitor choices still apply.
Preview, Debug and Publish
Every change gets a preview before it goes live. Preview mode loads your draft container for you alone, and visitors keep getting the published version while you test.
- Click Preview in the workspace. Tag Assistant opens in a new tab.
- Enter your site's URL and click Connect.
- On the site, do the thing you are tracking: click the link, send the form or scroll the page.
- In Tag Assistant, select the event in the left column and check which tags fired, which didn't and what each variable held.
- Open the Consent tab and confirm the consent state was set before the first tag fired.
- In GA4, open DebugView and confirm the event arrived with its parameters.
When the test passes, click Submit, choose Publish and Create Version and write a version name that says what changed. That name is what you'll look for when a report seems wrong months later.
- One change set per version. A version that adds a pixel, edits 3 triggers and renames variables is hard to roll back cleanly.
- Rollback through Versions. Open Versions, pick the last good version and choose Publish from its Action menu.
- Workspaces for parallel work. A free container allows 3 workspaces at a time: the default one and 2 custom ones.
Server-Side GTM
Server-side tagging adds a second container that runs on a server, usually under your own subdomain. The browser sends its data to that server, and the server forwards it to GA4, Google Ads or other platforms.
It buys you 2 things. Fewer vendor scripts run in the visitor's browser, and you decide which fields each vendor receives.
It is not free. Google's Cloud Run setup guide prices each server at about $45 a month and recommends at least 2 for production. Someone also has to build and maintain it.
We'd skip it for content sites and small lead-generation sites, where the web container does the job. It becomes worth pricing for a store or an advertiser that spends enough on ads for lost conversion data to cost more than the servers. Google tag gateway is the lighter first step.
Performance Cost and What to Keep Out of GTM
GTM does not make scripts free. The container loads asynchronously, so it doesn't block the page from rendering, but every tag inside it still downloads and runs its own JavaScript in the visitor's browser.
What you gain is control. A trigger can load a tag only on the pages that need it, and removing a tag takes one publish.
Google's own guidance is to keep Custom HTML tags and custom JavaScript variables to a minimum and use a built-in template where one exists. The Versions page shows a size indicator for a large container, and Google suggests a cleanup once it passes 70%.
These don't belong in GTM:
- Anything the page needs to work. Menus, sliders, forms and checkout scripts stay in the site. Many ad blockers block the Tag Manager script, and those visitors would lose the feature.
- Static JavaScript libraries. Google says a static file is served more efficiently from your own site or a CDN, where the browser can cache it.
- Scripts that change the page before it paints. An A/B testing snippet loaded through GTM runs late, so visitors can see the original version flash first.
- Tags nobody owns. A pixel for a campaign that ended months ago still loads on every page until someone pauses it.
We recommend a container review every quarter: pause what nobody can explain and delete it a month later if no report misses it. Our WordPress speed optimization guide shows how third-party scripts affect Core Web Vitals such as INP.
FAQs on Google Tag Manager
Is Google Tag Manager free?
Yes. The standard version of Google Tag Manager is free. Tag Manager 360 is the paid enterprise version, which adds unlimited workspaces, approval workflows and zones. A small business or a single store doesn't need it.
What is the difference between Google Tag Manager and Google Analytics?
Google Tag Manager delivers scripts to the page and decides when each one runs. Google Analytics 4 stores the data those scripts send and shows the reports. GA4 can run without GTM, but GTM on its own shows you nothing.
Does Google Tag Manager slow down a website?
The container loads asynchronously, so it doesn't block the page from rendering. The weight comes from the tags you put inside it. A container with a few template tags stays light, and one full of Custom HTML tags does not.
Can I use Site Kit and Google Tag Manager together?
Yes. Site Kit can place the GTM container, and its dashboard reports keep working. It is wise to ensure GA4 loads from one place only. If the Google tag lives in GTM, turn off the GA4 snippet in Site Kit's Analytics settings, or every page view is counted twice.
How do I move from a hardcoded GA4 snippet to GTM without double counting?
We'd build the Google tag in GTM and check it in preview mode first. The hardcoded snippet, or the plugin setting that prints it, should then be removed in the same release that publishes the container. After that, one page view per page load in GA4's Realtime report confirms the switch.
How many containers do I need for several websites?
One web container per website. Sites that belong to the same business can sit under one account. If you manage sites for clients, we recommend a separate account for each client, owned by the client, so access can be removed without moving any tags.
Does Google Tag Manager work when a visitor uses an ad blocker?
Often it doesn't. Many ad blockers and privacy browsers block the Tag Manager script, and when that happens none of the tags inside it run. Your analytics will undercount those visitors, which is one more reason to keep site features out of GTM.
Do I need a developer to use Google Tag Manager?
Not for the basics. The Google tag, click triggers and scroll triggers need no code. Form leads and purchases are different, because the site itself has to announce those events. A developer or a data layer plugin such as GTM4WP or GTM Kit handles that part.
Final Remarks
If your tracking still lives in theme files and plugin settings, you don't have to move it all in one day. This is the order we'd follow:
- The container snippet, installed by one method only
- The Google tag, with the old GA4 snippet removed in the same release
- Consent mode, if you have visitors in the EEA, the UK or Switzerland
- Lead and click events, named by one pattern
Each step ships as its own version after a preview, so a mistake costs you one rollback.
Once the events are reliable, they tell you which pages and buttons bring in leads. Our conversion rate optimization guide shows what to do with those numbers.



