Google Tag Manager: how to organize the tracking codes on your website

  • Home
  • Google Tag Manager: how to organize the tracking codes on your website
Google Tag Manager: how to organize the tracking codes on your website

Google Tag Manager gathers pixels and scripts in one container. And suddenly you can see everything: what runs on the site, what is duplicated and who has access to it. This is especially useful when, over the years, several agencies have pasted their codes into the theme, into plugins and into the footer, and nobody has the full list (I know this picture all too well). Below: the basics of the tool, the inventory, a step-by-step migration and, at the end, a checklist.

What is Google Tag Manager and what does it change in managing tracking codes?

It is a tool for adding tags and managing them without touching the site’s code. According to the description in Tag Manager Help, you install 2 code snippets on every page and configure everything else in the panel. That’s it. A GTM container is a set of tags, triggers, variables and settings assigned to one website or app. It can replace manually pasted Google Ads tags, Google Analytics tags and third-party tools. One account is usually enough for a company, with separate containers under it for the individual sites.

Tags, triggers and variables: three elements you need to understand

The whole GTM configuration comes down to three building blocks. Together they decide what gets sent to external tools, when, and with what data.

  • A tag is a piece of code, e.g. an advertising pixel or a web analytics script.
  • A trigger tells the tag when to fire, e.g. when the thank-you page is displayed after a form is submitted.
  • A variable holds a value used by tags and triggers: the page URL, the ad account ID and so on.

In the interface you will find them in the workspace menu as Tags, Triggers and Variables. Nothing groundbreaking, but it helps to know where to look.

Inventory: how to check which tracking codes are on your site today

The point is to find every place where someone once pasted a script and write it all down. Where to look? Agencies most often leave codes in the theme files (header and footer), in script insertion plugins and in the store settings. And in old, forgotten GTM containers that nobody remembers anymore. For each finding, note down:

  • the name of the tool (ads, analytics, chat, heat map),
  • the owner of the account the data goes to,
  • the purpose this code is supposed to serve,
  • whether anyone still uses it.

Watch out for duplicates. The same pixel pasted manually and added in the container sends events twice, and then everyone wonders where all those conversions came from. Here at web-systems.pl we also run a GTM container, so all marketing scripts go through one place.

How to move pixels and scripts to a GTM container step by step

The migration itself is not complicated: you recreate each tag in the container, test it and only then remove the old version from the site. The order matters.

  1. Create a company account and a container for the site.
  2. Install the two container code snippets on all pages.
  3. Recreate the tags from your inventory list in the panel.
  4. Assign the right trigger to each tag.
  5. Test the configuration in preview mode.
  6. Publish the container version.
  7. Remove the old codes from the theme and plugins.

Google Help recommends moving all tags at once. A partial move will work too, because GTM fires its tags alongside codes pasted outside it. But then it is very easy to end up with a duplicate. It hurts most with conversion tags, which measure what a landing page for a campaign delivers. Here, be especially careful about the order of the steps.

GTM preview mode and versions: how to test changes before publishing

Preview mode shows which tags fired on a given page and why, before the change reaches your visitors. You click Preview, open the site in the connected tab and walk through the user path, e.g. from landing on the site to submitting a form. What do you check? Whether each tag fires only once, on the right trigger and with the correct variable values. Every publication creates a new container version. Describe it, even in a single sentence. Because when something breaks, you simply go back to the previous version and don’t dig around in the site’s code.

Permissions and rules that keep your marketing tags in order

In my opinion, this is the most important part of the whole exercise. Order will last only if the account and the container belong to the company and the agencies get user permissions. Not the other way round. Split the roles deliberately: some people only view the configuration, others edit it, and leave publishing to one or at most two trusted people. Finished working with an agency? Revoke its access right away. A fixed naming convention also helps, e.g. “tool - purpose - event”, plus folders that group tags by vendor.

Tags must respect what the visitor chose in the consent banner. We described how to block them until a decision is made in our post on how to connect a cookie banner and Consent Mode with Google tags. If the tags are meant to support running Google Ads campaigns, a tidy container shortens every configuration change. And if you prefer to keep the data on your own servers, consider implementing Matomo statistics on your site or see what analytics without Google Analytics looks like.

Checklist for tidying up Google Tag Manager

A quick test of whether you have the configuration under control:

  • the company has one GTM account of its own,
  • there is an up-to-date list of all codes on the site,
  • no manually pasted duplicates are left in the theme and plugins,
  • every tag has an owner and a described trigger,
  • changes are tested in preview mode,
  • every container version has a description,
  • permissions are reviewed every quarter,
  • consent is handled before the tags fire.

GTM on its own will not clean anything up. Real control over tracking codes comes only from a container with an owner, written rules and a regular review.

Frequently asked questions

Do you need to remove old codes from the site after installing GTM?

Yes, but only once you are sure their counterparts in the container work. If you leave both versions in place, events and conversions will be counted twice. Remove the codes one at a time and check the tool’s reports after each change.

Who should own the GTM container?

The company. Not the agency. Agencies get permissions to the extent they need for their work. This way, changing a contractor does not mean losing the configuration or the version history.

Can you move tags to Tag Manager gradually?

You can, because GTM fires its tags alongside codes pasted outside it. However, Google recommends moving everything at once, because that makes duplicates easier to avoid. If you go in stages, keep a precise list of what has already gone into the container.

Book a free consultation

Provide your phone number or schedule a meeting