How and why to use Google Tag Manager with WordPress and Shifter

Daniel Olson | October 11, 2018

Google Tag Manager (GTM) is a recent addition to Google’s Marketing Platform. This adds to the growing number of products that Google offers for everyone from developers, bloggers, marketing partners and more to use to get better metrics and gain more insight into their applications and websites.

What makes Google Tag Manager a great companion for any WordPress site and in particular, any WordPress site on Shifter is how it was designed to work.

Key Features of Google Tag Manager

One script to rule them all: Add one tracking code form Google Tag manager and that’s it. If you need to add a new tracking code from Mautic, or Google Analytics you don’t need to modify your website at all, just log into GTM and add everything there.

Version Control: With each script, you add GTM will track those changes and only make them live when you publish a new version of your GTM container. Note: GTM Containers are what they call where all the tags are stored.

Collaborate with teams: Say you are running a business and you need to partner with a marketing firm that frequently changes scripts and tags. You can add one tag to your site and within GTM give them the access they need without modifying your WordPress code.

Multiple Environments: Yep, you can split up development, staging, and production now! Say you are working locally and need to test your scripts. GTM offers features to split up those environments so you never get mixed data.

To get a full scope of how awesome Google Tag Manager is, check out their site and get started with your migration from basic copy and paste scripts to one convenient tag you can manage from your Google Account.

Why use Google Tag Manager on Shifter with WordPress?

Shifter generates to a create completely static version of your WordPress site. With every change to your code such as a new tracking script, you’ll need to generate a new version. Using Google Tag Manager on Shifter you only need to do this once.

When that first Google Tag is added, any additional tags or edits can be managed directly through your Google Account. No logging back into WordPress and no updates to your code are necessary.

Google Tag Manager gives WordPress users and WordPress sites on Shifter the flexibility and control they need to make rapid changes at a moments notice.

Getting started with GTM

You’ll need a Google Account to create an account and container with GTM. As mentioned earlier, containers within GTM are the place that “contains” all your various tags and scripts. That’s naming at it’s finest.

Head over to https://tagmanager.google.com to create an account and container if you don’t already have one. We’ve named our account that will manage our account and container, Shifter GTM.

Pro tip: If you are managing these for clients or you are working on multiple projects, you can either create a GTM account for each client or project and containers within them. It’s like having two layers of permissions so you can maintain control over who can access what at every level.

Adding GTM to WordPress

Start by creating a new site. In our case, we created a demo site called Shifter GTM.

Next, navigate to the Plugin page within WordPress and search for “Google Tag Manager”. There are plenty of options to choose from and for this example, we are going to use DuracellTomi’s Google Tag Manager for WordPress.

What’s great about this plugin is it’s simple to get started with or you can spend time digging into its rich set of features. We are not going to deep dive into the plugin features itself but rather focus on setting up GTM with WordPress on Shifter.

Here is the Google Tag Manager for WordPress Settings. The first screen you’ll see after activation will ask for a Google Tag Manager ID.

By now you should have completed the following:

  1. Installed DuracellTomi’s Google Tag Manager for WordPress
  2. Created a Google Tag Manager Container

Start by locating the ID that GTM has assigned to your container. You’ll need to copy and paste this container ID from GTM into your WordPress site.

That’s it! Once you have set up the WordPress GTM plugin with your container ID you can generate a new Artifact and head back to the Google Tag Manager to add the scripts you need.

Adding GTM Tags to WordPress

With those steps complete, GTM is now connected to your WordPress site. Now, from within Google Tag Manager, you can search and add scripts available from within Google such as Analytics, 3rd party scripts or custom ones too. For this demo, we are adding a simple Hello World, example.

Start by clicking Add New Tag. This will open the tag panel where you can select the tag you need and how that tag is triggered.

The tag we are adding is just an example HTML tag and the trigger we are going to have it fire on is All Pages. Depending on your application or particular tag needs you can set this to fire only on a particular page when a user agrees to some action, and more. As a developer, you can get very granular with how that’s handled.

Publishing Your GTM Tags

After adding or modifying GTM Tags, they are not immediately available on your WordPress site. You must first publish them.

This feature is great in case you have multiple tags that need to go live all at once, or you need to roll back changes. It’s also handy to track activity when working with 3rd party vendors or marketing firms.

Testing your GTM Tags with Tag Assistant and Chrome

Testing can be a pain if you don’t know how to test efficiency. The best way to test your Google Tags is with Tag Assistant extension for Chrome.

This is a free extension created by Google that can detect when a GTM Tag is present on a site and can show you what tags are available. It will also give you insights into what may be wrong if you have not installed your scripts or GTM itself, correctly.

What’s next for GTM, WordPress, and Shifter?

That’s up to you! How you can use GTM with WordPress on Shifter is endless. It’s fully compatible and works great even when servicing your static pages over our global CDN.

Let us know how you are using Google Tag Manager and WordPress. This is something we were really excited to share with the community and who knows, maybe we’ll get to present it at an upcoming WordCamp or Meetup!

Ready to take your site to the next level?

Shifter is the solution for fast, maintenance-free WordPress websites.