How to Add Google Tag Manager to Your CMS

Tracking user behavior accurately is essential for understanding how your website performs. One of the most efficient ways to manage tracking tools like Google Analytics, Meta Pixel, and conversion tags is by using Google Tag Manager.

This guide explains what Google Tag Manager is, why it matters, and how to add it to the most common CMS platforms.

What Is Google Tag Manager?

Google Tag Manager (GTM for short), is a free tool that allows you to manage and deploy marketing and analytics tags on your website without editing code every time.

Instead of hard coding tracking scripts directly into your site, you add GTM once. After that, all tracking updates are handled inside the GTM interface.

Key benefits

  • Faster tracking updates without developer help
  • Reduced risk of broken site code
  • Centralized control for all marketing tags

Built in version control and testing tools

Before You Start

You will need:

  1. A Google Tag Manager account and container created

How to create a Google Tag Manager account:

  1. Go to https://tagmanager.google.com
  2. Sign in to your Google Account. (If you don’t have one, you need to create one for your business.)
  3. In Tag Manager select Create Account (top right). 

  1. In the Account Setup section, follow these steps:
    1. Enter an account name.
    2. Select the country location for the account.
    3. Create a container 
  1. Admin access to your CMS (Wordpress/ Shopify/ Wix/ Squarespace/ etc.)

  2. Your GTM Container ID, which looks like GTM-XXXXXXX

Step 1: Copy Your Google Tag Manager Code

Once your container is created, Google Tag Manager provides two code snippets:

  • One script for the <head> section

  • One noscript snippet for the <body>

  • Keep these codes handy as you’ll need to copy and paste them into your sites. These must be added exactly as provided to ensure proper tracking.

How to get these codes:

  1. In GTM, go back to the “Admin” section.
  2. Click on “Install Google Tag Manager.”

Step 2: Add Google Tag Manager to Your CMS

Below are the most common CMS platforms and how to add GTM to each.

WordPress

Option 1: Using a Plugin (Recommended)

  1. Install a plugin such as Insert Headers and Footers or a dedicated GTM plugin

  2. Paste the GTM head script into the header section

  3. Paste the noscript code into the body section if supported

  4. Save changes and publish

Option 2: Editing Theme Files 

  1. Log in to your WordPress website. Make sure that your site is publicly accessible (your site isn't in maintenance mode or only accessible through a password).
  2. In the left side Navigation panel of your site dashboard, click Appearance
  1. Under Appearance, click Theme File Editor
  1. On the right side panel click Theme Header (header.php) under Theme Files
  1. Paste your Tag snippet at the bottom of the code editor
  1. Click Update File and make sure you see a banner “File edited successfully”.

If you change your WordPress theme, you must repeat this process again as the header.php might be overwritten by manual changes. Hence a plugin is safer.

Shopify

Create a Google Tag Manager Custom Pixel (especially if you are using upgraded checkout)

From Jan 2026 onwards, checkout.liquid will be deprecated hence you will require a custom pixel to be created. 

  1. Copy the code block that belongs in the head section of a page.
  1. Remove the HTML tags from the code block. For example, <script></script>.
  2. Insert the remaining code into a new Shopify Custom Pixel.
    • From your Shopify admin, go to Settings > Customer events.
    • Give your pixel a unique name. If you enter the name of a custom pixel that already exists, then you'll be prompted to give your pixel a different name.
    • Click Add pixel to open the event editor.
    • Optional: In the Customer privacy section, select the Permission and Data sale settings that you want to adjust. Learn more about managing app pixel customer privacy.
    • Paste your custom javascript pixel code into the Code window.
    • Click Save. If you're ready to connect your custom pixel now, then you can click Connect pixel to start tracking your events.
  3. Subscribe to customer events and push to GTM’s dataLayer.
  4. To review how the code should display, refer to the example Google Tag Manager custom pixel.
  5. Configure Google Tag Manager to accept events from your Custom Pixel.

Optional: If you have existing dataLayer.push(event) calls in your checkout.liquid file, then replace it with analytics.publish().

Wix

  1. Open your Wix dashboard
  2. Go to Marketing Integrations in your site's dashboard. 
  3. Click Connect under Google Tag Manager. 
  1. Click Add Google Tag Manager. 
  2. Enter your Google Tag Manager ID. 
  3. Click Save. 

Squarespace

  1. Log into your Squarespace account and go to Website > Pages > Website Tools > Code Injection
  1. Paste the <head> Google Tag Manager code snippet into the “Header” box.
  2. Paste the <body> code into the “Footer” box.
  1. Click “Save.”

Step 3: Test Your Installation

After installing Google Tag Manager, always verify that it works.

  1. In GTM, go back to the “Admin” section.
  2. Click on “Install Google Tag Manager.”
  1. Enter your website URL and click “Test.”
  1. GTM will notify you if the snippet has been successfully installed.

Common Mistakes to Avoid

  • Adding GTM code twice
  • Installing GTM through both a plugin and manual code
  • Publishing tags without testing
  • Using the wrong container ID

These issues can lead to duplicate data or broken tracking.

Final Thoughts

Adding Google Tag Manager to your CMS is a one time setup that unlocks long term flexibility for tracking and marketing. Once installed, future updates can be made without touching your website code again.

← Back to Previous Page