Close this search box.

Setting Up Google Tag Manager on Your WordPress Site (Intermediate)

8 min read


Note: This article is the third in our series aimed at helping you master Google Analytics and Google Tag Manager for WordPress sites. If you’re new to this series, we recommend starting with our first article, “Introduction to Google Analytics and Google Tag Manager,” and the second one, “Installing Google Analytics on Your WordPress Site,” to build a strong foundation.

Goal: By the end of this article, you will be able to set up Google Tag Manager on your WordPress site and understand its basic functionalities.

In the digital world, effectively managing your website’s tracking codes and marketing tags is crucial for accurate data collection and analysis. Google Tag Manager (GTM) simplifies this process by allowing you to manage these tags without editing your site’s code. This is particularly useful for WordPress users, as it streamlines tag management and enhances site performance. This article will guide you through creating a GTM account, integrating it with your WordPress site, and exploring its basic functionalities.

Let’s dive into the world of efficient tag management with Google Tag Manager.

Creating a Google Tag Manager Account

Setting up a Google Tag Manager account is the first step in harnessing this powerful tool for your WordPress site.

Sign Up for GTM:

    • Visit the Google Tag Manager website.
    • Sign in with your Google account or create one if you don’t already have it.
    • Click on ‘Create Account’ and follow the setup process.

Creating a Container:

    • During the setup, you’ll be prompted to create a ‘container’ for your website. A container in GTM holds all the tags for a specific website or mobile app.
    • Name your container (usually your website name) and select ‘Web’ as the container type.

Account and Container Configuration:

    • Complete the account setup by configuring your container with your website details.

Container ID:

    • After creating the container, you’ll be given a GTM container ID, which is crucial for integrating GTM with your WordPress site.

In the next section, we’ll cover how to add this GTM container to your WordPress site, both manually and using a plugin for ease of integration.

Integrating GTM with WordPress

Once you have your Google Tag Manager account and container set up, the next step is to integrate it with your WordPress site. There are two main methods to do this: manually adding the GTM code to your site or using a WordPress plugin.

Manually Adding GTM to Your WordPress Site

  • Access Your GTM Container Code: In your GTM account, go to your container’s workspace and find the container code snippets. There are two parts of the code: one that needs to be placed in the <head> section and another that goes immediately after the opening <body> tag of your website.
  • Edit Your WordPress Theme Files:
    • Navigate to ‘Appearance’ > ‘Theme Editor’ in your WordPress dashboard.
    • Carefully edit the ‘header.php’ file to insert the first part of the GTM code right after the opening <head> tag.
    • Similarly, insert the second part of the code right after the opening <body> tag in the ‘header.php’ file or in the ‘index.php’ file, depending on your theme structure.
    • Save the changes.

Using WordPress Plugins for GTM Integration

  1. Selecting the Right Plugin:

    • As we said in the previous article, WPCode is a convenient choice. This plugin simplifies the process of adding custom code, like GTM tracking code, without needing to edit website files directly. It’s important to note that we have no affiliation with WPCode.
  2. Installation and Activation:

    • In your WordPress dashboard, go to ‘Plugins’ > ‘Add New.’ Search for WPCode, then install and activate it.
  3. Configuring WPCode for GTM:

    • After activating WPCode, access its settings to insert your GTM tracking code. Your GTM Tag can be obtained from your Google tagmanager account, under the Admin section’s ‘Install Google Tag Manager’ area.
    • Create a new code snippet in WPCode for the header (as advised by Google for GTM code). Paste your GTM script and ensure it’s set to run across your entire site.
    • Create a new code snippet in WPCode for the body (as advised by Google for GTM code). Paste your GTM script and ensure it’s set to run across your entire site.

Using WPCode offers a user-friendly, no-code solution for integrating GTM into your WordPress site. This approach is particularly useful for those who prefer to avoid direct code edits, ensuring seamless and efficient GTM integration for enhanced site analytics. Remember, our mention of WPCode is purely for instructional purposes, and we are not affiliated with this plugin.

Both methods are effective, but using a plugin can be more user-friendly, especially for those less comfortable editing theme files directly.

In the next section, we’ll look at how to verify that GTM is correctly tracking your WordPress site and discuss some initial configuration settings in GTM.

Verifying GTM Installation

After adding the GTM code to your site, either manually or via a plugin, it’s important to ensure it’s working correctly:

  • Use the ‘Preview’ mode in Google Tag Manager to test and debug your tags.
  • Alternatively, you can use tools like Google Tag Assistant to verify that the GTM container is firing correctly on your site.

Once you have Google Tag Manager installed and verified on your WordPress site, you can start using its functionalities to manage and deploy tags efficiently. In the next section, we’ll explore the basic functions of Google Tag Manager and how to set up your first tags.

Basic Functions of Google Tag Manager

Understanding the core components of Google Tag Manager is key to effectively managing your website’s tags. Let’s break down these components and guide you through setting up your first tags.

Core Components of GTM

  • Tags: Tags are snippets of code or tracking pixels from third-party tools. Examples include Google Analytics tracking code, AdWords conversion tracking, or Facebook pixel.
  • Triggers: Triggers in GTM determine when and how tags are executed. For example, you can set a trigger to fire a tag when a user clicks a specific button or visits a particular page.
  • Variables: Variables are used to store and retrieve data that can be used in tags and triggers. They can be predefined (like ‘Page URL’) or user-defined to suit specific needs.

Setting Up Your First Tags

Adding a Google Analytics Pageview Tag:

    • Go to your GTM Dashboard and select your container.
    • Click ‘New Tag’ and choose ‘Google Analytics: GA4 Event’ as the tag type.
    • For the Measurement ID, use the Google Analytics Measurement ID (from your GA account).
    • Enter the Event Name you want.
    • Under triggering, select ‘All Pages’ to track page views across your entire site.
    • Give a name to your tag and click Save.

Testing and Publishing Your Tag:

    • Use GTM’s ‘Preview’ mode to test the tag on your site. This mode allows you to see if the tag fires correctly as you navigate your site.
    • Once verified, click ‘Submit’ to publish your tag to the live site.

Other Tag Examples:

    • Consider adding other basic tags like AdWords conversion tracking or a Facebook pixel, following similar steps but selecting the appropriate tag type.

By understanding these basic functions and setting up your first tags, you are beginning to unlock the full potential of Google Tag Manager for your WordPress site. This tool not only makes managing your tags easier but also significantly enhances your site’s data collection capabilities.

In the conclusion, we’ll summarise the key points of this article and hint at the advanced capabilities of GTM that we’ll explore in future articles of this series.


Recap of Setting Up Google Tag Manager

You’ve now successfully embarked on your journey with Google Tag Manager (GTM) for your WordPress site. By creating a GTM account, integrating it with your site, and understanding its core functionalities, you’ve laid the groundwork for advanced and efficient tag management. This setup not only streamlines the process of adding tags like Google Analytics to your site but also opens up a world of possibilities for tracking various user interactions and website performance metrics.

Encouragement to Explore GTM

With the basic setup complete, we encourage you to explore the capabilities of GTM further. Experiment with different types of tags, triggers, and variables. The flexibility of GTM allows you to tailor your tracking needs specifically to your site, offering insights that can drive significant improvements in your online strategy.

Looking Ahead

As you grow more comfortable with GTM, remember that this tool offers much more than just basic tag management. In the upcoming articles in this series, we will delve deeper into the advanced features of GTM. We’ll explore specific types of tags for tracking conversions, site engagement, and more. Additionally, we’ll look at how to utilise GTM for A/B testing and other advanced analytics strategies.

Thank you for following along in this third installment of our series. Stay tuned for more insights and practical tips to enhance your website’s analytics and tracking capabilities with Google Tag Manager.

Receive the latest news

Subscribe To Our Weekly Newsletter

Get notified about new articles

Unlock your online potential with a tailored SEO strategy. Elevate your rankings, drive organic traffic, and empower your
In this post


Leave a Comment

Your email address will not be published. Required fields are marked *

more insights

Receive the latest news

Subscribe To Our Weekly Newsletter

Get notified about new articles