...

How to Install and Setup Google Tag Manager in WordPress

170

Are you looking to setup Google Tag Manager in WordPress? Not sure if you need Google Tag Manager on your WordPress site? Don’t worry. In this article, we will show you how to properly install and setup Google Tag Manager in WordPress and explain the benefits.

What is Google Tag Manager?

Google Tag Manager

Often website owners need to add multiple code snippets to track their conversions, traffic, and gather other analytical data.

With Google Tag manager you can easily add and manage all of these scripts from a single dashboard.

There are built-in tag templates for Google Analytics, Adwords, DoubleClick, etc. Tag manager also works with several third party analytics and tracking platforms.

Apart from that, you can use custom HTML to add your own tracking or any other code that you want to add.

This saves you the time of adding and removing tags from your code and rather manage it from an easy dashboard. Not to mention, all of these scripts are loaded in one script.

Having said that, lets get started with Google Tag Manager.

For the sake of this article, we will show you how to add Google Analytics to your site using Google Tag Manager.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

Getting Started

It’s important to note that this guide is for self hosted WordPress.org sites (see the difference between WordPress.com and WordPress.org). If you don’t have a WordPress site, then please see our WordPress installation guide to create one.

First you will need to create a Google Analytics account for your website if you haven’t already done so. You can follow the instructions in our how to install Google Analytics in WordPress tutorial.

Follow the steps mentioned in the “how to signup for Google Analytics” section. Stop when you get the tracking code. Instead of adding tracking code directly in WordPress, we will be using the tag manager to do that.

Setting Up Google Tag Manager

Now that we are ready to add Google Analytics, the next step is to setup Google Tag Manager.

Visit the Google Tag Manager website and sign up using the same Google account you used with Google Analytics.

After login you will come to the add new account page. Simply provide a name for your account and click on the continue button.

Creating Google Tag Manager account

Now you need to add a container to your account. A container could be a website or an app on iOS or Android platforms. In this case we will use the web.

You can use your site’s domain for the container name. You can add multiple containers for each account. Once you’re done click on the create button to continue.

Creating a container

Google Tag Manager will now create your account with the container, and you will see your container dashboard. It would look something like this:

Container dashboard

Now your Google Tag Manager account is ready, so the next step is to add a new tag. You can do this by clicking on create new tag.

First you will have to choose a tag product. Currently there are 20+ integration templates available.

We will choose Google Analytics for now, but you can always add more tags and choose different products according to your needs. You can even click on custom HTML to add any other custom code snippets.

Choose Google Analytics as product for your tag

Once you choose Google Analytics, you will be asked to select between Universal Analytics or Classic Analytics. Choose universal analytics, and you will be asked to provide your analytics tracking ID.

This tracking ID is a special code that allows Google to identify your site. You can obtain this ID by logging into your Google Analytics account and visiting the Admin tab.

Select the account and property for your site and then click on tracking info to expand it. You will see the tracking code link.

Finding your Google Analytics tracking ID

Clicking on tracking code will bring you to the tracking code page and will also reveal your UA tracking ID.

UA tracking id in Google Analytics

Copy your UA tracking ID and paste it in Google Tag Manager. Under track type choose Page View and then click on the continue button.

Add tracking id

The tag configuration wizard will now ask you when to fire this tag. Select all pages and then click on the create button.

When to fire on the tag

Google Tag Manager will now show you a tracking code that you need to add into your WordPress site. You need to copy this code.

Tag manager code

Adding Tag Manager Code in WordPress

First thing you will need to do is install and activate Insert Headers and Footers plugin. Upon activation, you need to visit Settings » Insert Headers and Footers.

Add your Google Tag Manager code in WordPress
Paste your tag manager code in the header section and click on the save button to store your settings.

If you do not wish to install a plugin, then you can also add the Google Tag Manager code in your WordPress theme or Child theme. Simply edit the header.php template and paste the code right after <body> tag.

Publish Your Container

Tags in Google tag manager will not go live until you publish the container. Visit Google Tag Manager dashboard and then click on the publish button.

Publish your changes in Google Tag Manager

You can also preview your website and Google Tag Manager will show you the tags fired on each page view.

Previewing and debugging

That’s all, you have successfully installed and setup Google Tag Manager for your WordPress site. You may also want to see our guide on 7 best analytics solutions for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.