How to Install Google Tag Manager on Any Website – 2025

Spread the love


Marketing teams used to wait days or weeks for developers to add or remove tracking code. One sprint later, something else needed to ship, and the list of pixel changes kept growing. Tag management solved that bottleneck.

Google Tag Manager places one container snippet on your site. Inside that container you configure tags, triggers, and variables. You publish changes from a friendly interface, with version control and preview, without touching the site code again for most routine tracking tasks.

This guide explains what GTM is, why it matters, and how to set it up properly the first time. It includes a step-by-step walkthrough, best practices, and common mistakes to avoid. By the end, you will be ready to ship clean analytics and marketing tags with confidence.

Follow these steps to get GTM live on HTML sites, WordPress, Wix, Shopify, or most CMS platforms.

Table of Contents

1) Prerequisites

  1. A Google account you can use for your business.
  2. Access to your site’s template or a place to inject code in the global head and body areas.
  3. Your site URL, for example waftr.com.

2) Create your GTM account and container

  1. Go to tagmanager.google.com and sign in.
    Create GTM Account
  2. Click Create Account.
    • Account Name can be your company name.GTM Account and COntainer
    • Pick your Country.
  3. Under Container Setup:
    • Container Name should be easy to recognize. Using your domain is best, for example waftr.com.
    • Choose Target platform as Web.
      Choose Web Container
  4. Click Create, review the Terms of Service, and accept. If you operate in the EU, also accept the Data Processing Terms.

    Accept Privacy policy

You will now see the Install Google Tag Manager dialog with two snippets.

GTM Snippet with Script and no script tags

3) Add the GTM snippets to your site

Head snippet

Copy the script and place it as high as possible inside the on every page.




Body snippet

Copy the noscript iframe and paste it immediately after the opening tag on every page. This provides limited coverage when JavaScript is disabled and is part of Google’s recommended install.




Make it sitewide

  • Ensure both snippets load on all pages, not only the homepage.
  • If your site uses templates, put the head snippet in the global header and the noscript snippet directly after the opening body in the base layout.
  • Avoid running multiple GTM containers on the same page unless you have a clear reason.

4) Platform notes

Raw HTML or custom frameworks

  • Edit your main layout file.
  • Paste the head snippet inside and the noscript iframe right after .
  • Rebuild or redeploy.

WordPress

Pick one of these approaches:

  • Theme files. Appearance → Theme File Editor → header.php. Add the head snippet before the closing . Add the noscript snippet at the very top of header.php if your theme opens there, or in footer.php only if the body opens in header and you can place it immediately after. Use a child theme so updates do not overwrite changes.
  • Code injection plugin. Use a reputable plugin that provides “Head” and “Body” insertion fields and place the snippets accordingly.

Wix, Squarespace, Webflow, and most CMS

  • Open the site settings and look for Custom Code, Head code, or Analytics integrations.
  • Paste the head snippet in the Head field and the noscript snippet in a field that injects immediately after if the platform provides it. If the CMS only offers a Head field, keep the head snippet there and check the vendor documentation for adding the noscript alternative.

Shopify

  • Online Store → Themes → Edit code.
  • In theme.liquid, place the head snippet before and the noscript iframe directly after .

5) Verify your installation

Using Tag Assistant Preview

  1. In GTM, click Preview.
  2. Enter your site URL and click Connect.
  3. Your site opens in a new tab with Tag Assistant. You should see your container ID, for example GTM-XXXXXXX, and a green Connected status.

From the Install dialog

  • In the same Install dialog you can paste your URL in the Test your website field. A green check mark confirms the container is loading.

    Test GTM Container

Quick checks if it does not connect

  • Confirm the container ID in your page source matches the one in GTM.
  • Clear CDN or server caches.
  • Disable ad blockers while testing.
  • Make sure both snippets appear on every template and there are no duplicate containers.

6) What to do next

  • Start with essential tags such as Google Analytics 4, then use Preview to test and Submit to publish a version.
  • If you operate under GDPR or similar laws, plan your Consent Mode and cookie banner before deploying marketing tags.

That is the complete, fact-checked section for “Steps to implement Google Tag Manager.” If you want, I can tailor short platform-specific substeps for your exact CMS and add screenshots callouts that match the images you uploaded.

GTM Core Concepts

  • Tags are scripts you want to execute. Examples: GA4 Configuration, GA4 Event, Google Ads Conversion, Floodlight, HTML, Image.
  • Triggers define when a tag fires. Examples: page view, click, form submit, custom event, timer, element visibility.
  • Variables store values that tags and triggers use. Examples: built-in click variables, URL parameters, data layer values, lookup tables, custom JavaScript.

Quick mental model

Think of GTM as “if this then fire that, using these details.”

  • If a user clicks the Pricing button on any page, then fire a GA4 event called click_pricing, using the button text and page path as parameters.

How GTM Fits Into Your Stack

  • GTM Web runs in the browser. This is what most teams start with.
  • GTM Server runs in a server container and proxies vendor endpoints. It improves control and can help with performance and privacy. Start with Web, plan for Server later if needed.
  • GTM and GA4 work together. GA4 collects events and parameters. GTM controls when and how events are sent.

Working With Triggers

Trigger type Typical use Notes
Page View Fire base tags Choose Initialization, DOM Ready, or Window Loaded based on tag requirements.
Click – All Elements or Just Links Track button or link clicks Scope with conditions to avoid noisy data.
Form Submission Lead forms Some modern forms need a custom event or element visibility instead.
Custom Event Data layer driven events Ideal for clean, reliable tracking from your app code.
Element Visibility CTAs that appear after scroll or lazy content Set a threshold and observe once or multiple times.
Scroll Depth Engagement metrics Use sparingly, pick meaningful thresholds.
Timer Sampling or periodic checks Useful for heartbeat events or delayed pixels.
History Change Single page apps Fire page view events without full reloads.
YouTube Video Video engagement Built-in video trigger supports start, progress, and complete.

Tip: choose the earliest safe timing. For example, most analytics tags can fire at DOM Ready. Some pixels need full Window Loaded if they depend on images or other resources.


Variables You Will Use Often

  • Data Layer Variable pulls values from dataLayer. Most robust path for event data.
  • Click variables provide text, ID, classes, and URL for clicked elements.
  • URL variables extract components such as hostname, path, query parameters, hash.
  • First Party Cookie variable reads values your site sets for attribution or session logic.
  • Lookup Table maps one value to another. Perfect for standardizing event names or channel names.
  • Regex Table for more complex mapping and sanitization.
  • Custom JavaScript variable returns a computed value. Keep these short, well commented, and unit tested where possible.

Best Practices To Run GTM Like A Pro

  • Separate Workspaces per project or sprint. Merge and resolve conflicts intentionally.
  • Use Folders to group tags, triggers, and variables by feature area.
  • Add detailed Notes on tags and triggers that describe what, why, and owner.
  • Protect production with Publishing Permissions and optional approvals.
  • Keep a shared tracking plan that lists events, parameters, and business definitions.
  • Document consent behavior for each tag and review quarterly.
  • Back up container versions regularly. Export JSON after major releases.

Common Mistakes To Avoid

  • Installing container code only on part of the site. It must be global.
  • Firing GA4 page_view from multiple places. Pick a single controlled source.
  • Tracking everything with click listeners instead of using clean data layer events.
  • Ignoring consent states. Many vendors provide consent flags or blocking conditions. Use them.
  • Overusing Custom HTML without security review. Prefer vendor templates or native tag types.
  • Publishing without Preview. Always test with Tag Assistant and GA4 DebugView.


Share this content:

I am a passionate blogger with extensive experience in web design. As a seasoned YouTube SEO expert, I have helped numerous creators optimize their content for maximum visibility.

Leave a Comment