How To: Implement Google Tag Manager in WordPress

Posted: June 23, 2017 at 4:19 pm, Last Updated: November 14, 2017 at 12:11 pm

Introduction

There are many ways to implement Google Tag Manager in WordPress:

  • you could use one of the many WordPress plugins that handle GTM integration specifically (we recommend DuracellTomi’s Google Tag Manager for WordPress),
  • you could use a general-purpose WordPress scripting plugin (such as Header and Footer Scripts) to add the scripts to your website, or
  • you could edit your WordPress template file(s) to include the GTM script manually (usually in the header.php file).

We recommend using a GTM specifc WordPress plugin, specifically DuracellTomi’s Google Tag Manager for WordPress, as it has a large install base and is frequently updated and well-maintained.

Implementing GTM in WordPress Using the Recommended Plugin

Step 1: Install the WordPress Plug-in

Install DuracellTomi’s Google Tag Manager for WordPress in your WordPress instance. Depending on your hosting set-up you may need help from your development staff or Mason’s ITS department to get the plugin installed.

Step 2: Activate the Plugin

In your WordPress instance, go to the plugins page, and activate the newly-installed plugin.

Step 3: Configure the Plugin

In your WordPress instance, go to the plugins page, and click on the settings link for the plugin. There are only a couple settings to configure.

Step 3A: Enter Your GTM ID

First, you will have to provide your Google Tag Manager container ID for the GTM container you want to use on your website. That setting is on the default page of the plugin’s settings section (the “General” tab):

Step 3B: Enable GTM to Avoid Tracking Logged-In Users

Second, you want to instruct the plugin to let GTM know if a user is logged-in. On the plugin’s setting page, click on the “Basic Data” tab, then click on the “Visitors” sub-tab. Then, check the box next to “Logged in status”. This will provide the login status of the user (whether they are logged-in or not) to GTM. Note that this won’t automatically avoid racking logged-in users; it merely provides the log-in status to GTM so that GTM can use this information to decide whether to track logged-in users. Your GTM container will have to be configured to look for this status and prevent tracking. The standard Mason GTM container is set-up to do this by default.