Google Tag Manager (GTM): How to Track Your Website Without Touching the Code

Google Tag Manager (GTM): How to Track Your Website Without Touching the Code

Peter Gáborík
Published
10 min read
Google Tag ManagerGTMWeb analytics
Share this article:

Google Tag Manager (GTM) is a free Google tool that lets you manage all of your website's tracking and marketing code in one place. You add the GTM container code to your site once, and from then on you add, test and publish tags (Google Analytics 4, the Facebook pixel, Google Ads conversion tracking) in a web interface, without a developer editing the source code.

In short:

  • Google Tag Manager is free; the paid Tag Manager 360 is aimed at large organisations.
  • You add two short snippets to your site: one in the page head, the other straight after the opening of the body.
  • GTM is built on three concepts: the tag (what is sent), the trigger (when it is sent) and the variable (which value is sent).
  • Check every change in preview mode first, then publish a new container version.

What Google Tag Manager is and what a GTM container is

Google Tag Manager is a tag management system. A tag is a piece of code that sends data to another system, such as Google Analytics. Without GTM, a developer adds every one of these snippets to the website template. With GTM, only one snippet sits on the site, the container, and everything else is managed at tagmanager.google.com.

A GTM container is the bundle of all tags, triggers and variables for one website or app. It has its own ID starting with "GTM-". The structure is simple: an account (usually one company) holds one or more containers. Besides web containers, there are containers for iOS and Android apps, AMP pages and a server container.

Why use Google Tag Manager

  • Marketing doesn't wait for a developer. You add a new conversion or click tracking yourself, without changing the website template.
  • One place for all tracking code. You can see what runs on the site, who changed what and when.
  • Versions and rollback. Every publish creates a container version you can go back to.
  • Ready-made templates. The Community Template Gallery offers third-party tags (Meta, cookie banners) with no coding.

When don't you need GTM? If GA4 is the only tool on your site and you plan nothing else, adding the Google tag directly is enough. GTM pays off as soon as you track conversions for ads or use more than one tool.

Tags, triggers and variables: how GTM works

ConceptWhat it doesExample
Tagcode that sends data to another systemGoogle tag for GA4, Google Ads conversion, Meta pixel
Triggerlistens for an event and decides when a tag firesview of the /thank-you page, button click, form submission
Variableplaceholder for a value that changespage URL, button text, order value

GTM provides built-in variables (Page URL, Click Text and others). A typical setup: the "Google Ads conversion" tag fires when the trigger detects a page view with /thank-you in the URL.

How to install the Google Tag Manager container

  1. 1Create an account and a container at tagmanager.google.com and choose Web as the target platform. Use a company Google account, not someone's personal email.
  2. 2Copy the installation code. GTM shows two code blocks containing your container ID.
  3. 3Add both blocks to the site. The first goes as high in the page head as possible, the second (noscript) immediately after the opening body tag. The code must be on every page, so add it to the shared site template.
  4. 4Verify the installation in preview mode (see below). If Tag Assistant connects to your site, the container is working.

WordPress: you don't need to paste the code by hand. The Site Kit by Google plugin sets up Tag Manager with no code editing. The GTM4WP plugin also pushes page data into the data layer and supports GA4-format e-commerce tracking for WooCommerce.

The same container code can also be used to verify your site in Google Search Console, provided you have Publish or Admin permission in GTM.

Setting up GA4 through Google Tag Manager

Google Analytics 4 tracking in GTM has two parts:

  1. 1The Google tag with the GA4 tag ID (it starts with "G-"). Set the trigger to Initialization – All Initialization Events. This tag measures page views and automatically collected events.
  2. 2Event tags (Google Analytics: GA4 Event) for actions GA4 doesn't capture on its own: a specific form submission, a click on a phone number, an add to cart. You enter the measurement ID, the event name (for example generate_lead) and any parameters. The trigger is a click, a form submission or a custom event from the data layer.

Use Google's recommended event names so GA4 fills its reports automatically. What to do with the data next is covered in our Google Analytics 4 guide.

The Facebook pixel (Meta pixel) through Google Tag Manager

The Facebook pixel (now the Meta pixel) is a JavaScript snippet from Meta that records what people arriving from Facebook and Instagram ads do on your website. Meta uses it to measure conversions and optimise campaigns. To set it up in GTM:

  1. 1Copy the pixel ID in Meta Events Manager.
  2. 2Create a tag in GTM, either from the Meta pixel template in the Community Template Gallery or as a Custom HTML tag containing the pixel base code from Events Manager.
  3. 3Fire the base code on all pages. It sends the PageView event by itself.
  4. 4For conversions, add separate tags with standard events such as Lead, Contact, AddToCart or Purchase. For purchases, also send the value and currency parameters.
  5. 5Check in GTM preview and in Events Manager that the events arrive, then publish the container.

The Conversions API is an add-on that sends the same events to Meta directly from your server, so it depends less on the browser; when it runs alongside the pixel, event deduplication has to be set up.

In Google Ads, create a conversion action and copy the Conversion ID and Conversion Label from the Tag Manager instructions. The Conversion ID is the same for the whole account, while the label differs for each conversion action. Then in GTM:

  • add a Conversion Linker tag and fire it on all pages; Google lists it as a prerequisite for conversion tracking,
  • create a Google Ads Conversion Tracking tag with the ID and label,
  • for orders, fill in the conversion value, transaction ID and currency code; if the value field is left empty, GTM sends a value of 0,
  • use the thank-you page or a successful form submission event as the trigger.

How to build the campaigns themselves is covered in our Google Ads guide. If you also advertise in the Czech Republic through Sklik, the ad platform of the Czech search engine Seznam.cz, note that Seznam introduced a new tracking system called Seznam Event Measurement (SEM) in June 2026; it replaces the old conversion and retargeting codes and can be deployed in GTM with a community template.

Preview mode and publishing versions

Changes in GTM don't affect your site until you publish them. The process:

  1. 1In the workspace, click Preview. Tag Assistant opens; enter your site's address and click Connect.
  2. 2Go through the scenarios you track on the site (a form submission, a purchase). Tag Assistant shows which tags fired, in what order and with what data.
  3. 3When everything checks out, click Submit, choose to publish and create a version, give the version a name and description (for example "Meta pixel – Lead") and publish.

The debug interface only appears in your own browser; site visitors won't notice anything.

The dataLayer in brief

The data layer (dataLayer) is an object through which your website passes GTM information that isn't visible in the page code: an order value, a form type or a login status. It is created before the container code, and the site sends data to it with dataLayer.push, for example dataLayer.push({'event': 'enquiry_submitted'}). In GTM you respond to such an event with a Custom Event trigger.

For online shops the data layer is essential: GTM has no other reliable source for basket contents and purchase value. Plugins such as GTM4WP for WooCommerce can populate it in the GA4 format.

In the EU, analytics and advertising tags may only fire in line with the visitor's consent; the background is explained in our glossary entry on GDPR and personal data protection. GTM has consent settings on every tag and a consent overview for the whole container; you connect your cookie banner using its provider's template from the Community Template Gallery. Consent signals are then passed to Google services through Consent Mode.

Server-side GTM (a server container) moves data processing from the browser to a server in your own Google Cloud project or another environment, giving you more control over what is sent to third parties, at the cost of hosting and a more demanding setup.

The most common Google Tag Manager mistakes

  • GTM installed twice (manually and through a plugin), or GA4 added both directly and through GTM: duplicated page views and conversions.
  • A conversion tag firing on every page instead of only on the thank-you page.
  • A missing Conversion Linker for Google Ads.
  • Tags without consent settings that fire before the visitor makes a choice in the cookie banner.
  • Dozens of old tags nobody uses. They slow the site down (see website speed) and increase the risk of errors.

When to hand tracking over to a specialist

You can handle a basic GTM and GA4 installation yourself with this guide. Consider a specialist when you track an online shop with a data layer, run Google Ads and Meta ads at the same time, or your GA4 numbers don't match your ad platforms. At Weboptim we set up conversion tracking as part of our PPC campaign management, because campaigns can't be steered by cost per lead or order without reliable data. You can describe your situation to us via the contact form.

Frequently asked questions

What is GTM?
GTM stands for Google Tag Manager, a free Google tool for managing a website's tracking and marketing code. The container code is added to the site once, and tags such as Google Analytics 4, the Facebook pixel or Google Ads conversion tracking are then added, tested and published in a web interface without editing the source code.
Is Google Tag Manager free?
Yes, the standard Google Tag Manager is free. The paid Tag Manager 360 is aimed at large organisations: it offers unlimited workspaces (the free version has three) and support with SLAs from Google and its partners, and Google does not publish its price. For small and medium-sized businesses the free version is usually enough.
What is the difference between Google Tag Manager and Google Analytics?
Google Tag Manager manages and fires code on your website, while Google Analytics collects, stores and reports on data. GTM has no traffic reports of its own; it deploys the GA4 tag, which sends data to Google Analytics. GTM can also handle other tools, such as Google Ads or Meta.
How do I add the Facebook pixel through GTM?
Copy the pixel ID in Meta Events Manager, then create a tag in GTM from the Meta pixel template in the Community Template Gallery or as a Custom HTML tag with the pixel base code, firing on all pages. For conversions, add tags with standard events such as Lead or Purchase, check them in preview mode and publish the container.
Where should the Google Tag Manager code go?
The first part of the code goes as high in the page head as possible and the second part (noscript) immediately after the opening body tag, on every page of the site. On WordPress you can use the Site Kit by Google or GTM4WP plugin instead of pasting the code manually. Check the installation in preview mode with Tag Assistant.
Why haven't my GTM changes appeared on the website?
Most often because they haven't been published. Changes in a workspace only go live after you click Submit and publish a new container version. Other common causes: the trigger condition isn't met, the tag is waiting for cookie consent, or the site uses a different container from the one you are editing.
Peter Gáborík

Written by

Peter Gáborík

Project Manager – AI, Automation & SEO

Project manager and founder of Weboptim. Builds growth strategies around SEO, automation and AI; in online marketing since 2017.

Tips that save time – once a month

One e-mail a month: a new guide, the automation of the month and one number from practice. No spam.