How to Setup Google Tag Manager for WordPress?

How to Setup Google Tag Manager for WordPress?:- Google Tag Manager is a powerful tool which is used mainly for tracking purpose similar to Google analytics. If you are seeking for detailed information about Google tag manager and how to set it up with WordPress site then you are at the correct place.

In this post, we explain:

  • What Google Tag Manager is
  • Why you need to use the tool and
  • How to install it manually or using a plugin on WordPress site.

On top of all, we describe Google tag manager to give you a brief idea of what you can achieve with tag management system like no other tool. We are saying this because there exists number of tag management system like Qubit, Tealium and Adobe experience platform.

What is Google Tag Manager?

This is an awesome tool for all your requirements of digital tracking. It enables you to deploy tags without editing your code. To offer a clear understanding, let us define tags in terms of digital tracking.

A tag is a Javascript code that you add to your site to activate third party features like traffic analytics, live chat, advertising among other things. Best example of a tag is Google Analytics tracking code that you add on your website to tracking traffic.

So the purpose of a tag is to collect visitor data for analytics & digital marketing tool. Companies that provide these tags are known as tag vendors.

Why Google Tag Manager?

Implementing tags on your site means manual editing of your code. On WordPress it means editing various code files like header.php & function.php among others.

Now if you add JavaScript code into files, it will slow down your website. Beside this it opens your site to security vulnerabilities especially if you get tags from untrustworthy sources.

Also there is various issues occurs to maintain the codes you are adding to your pages. For examples you need to update the tags if something changes and that means digging deeper into codes.

How to Setup Google Tag manager for WordPress?

Initially we install tag manager on WordPress site. There are two methods:

  • Manually and
  • Via a Plugin

First Create a Google Tag Manager account:

Initially create a Google tag manager account. This will unlock GTM dashboard and tags. You need to integrate the tool with WordPress site.

Now visit Google tag manger site. Login with your Google account or create new one if you don’t have

Then you’ll be redirected to tag manager admin dashboard. Next tap on create account link. On the next screen, enter account name, select country name and click on continue button.

Now enter domain name in container section and choose web. After that click on create button.

Accept terms of service agreement and data processing terms. A pop-up will occur with Google tag manager installation codes. GTM offers instructions to how to copy paste these codes but its challenging for beginners.

Important notice before starting:

  • Backup WordPress site before making changes to theme files.
  • Create WordPress child theme & edit that instead of parent theme.

Setting up Google Tag Manager Manually:

Login to WordPress admin dashboard and navigate to Appearance-> Editor.

Click on theme header (header.php) from the right side file navigator to launch header.php in theme editor. As per GTM instruction you need to paste the first code high in the head section and the second immediately after opening <body> tag.

After pasting the code according to instructions click on update file button to save your changes. Google tag manager is now installed on your site.

How to add Google Tag Manager to WordPress Via Plugin?

In this method we may use a nifty plugin as Duracell’s Google Tag Manager for WordPress. Its available in WordPress plugin repo that means you can directly install it from WordPress admin dashboard.

Navigate to plugins-> Add new. Enter Duracell’s Google Tag Manager in search field. Once you find the plugin, click on Install button.  Once installed click on Activate button.

A notice will displayed at the top to enter GTM ID to start using tag manager.

You can get your GTM Id in the top right corner in GTM dashboard. Copy it and paste it in required field of WordPress admin dashboard.

How to add Google analytics to your WordPress Site using Google Tag Manager:

Navigate back to Google Tag Manager & click on tags from the left navigation. After that click on New button.

On the pop-up that displays, name your tag & then click on tag configuration to select a tag (Google analytics in our case).

Select Google Analytics-Universal Analytics. Doing this will leads back to tag configuration. Select page view under track type since we want to report all page views to Google analytics.

Under GA settings, choose New Variable. This will open a new box where you have to enter Google analytics tracking id. Don’t forget to give a name to your variable.

Now we just need to set a trigger for Google analytics tag. Click on triggering to choose or create new trigger. Since we want to track traffic of all the pages, we can go with existing trigger. Choose All pages and click on save.

Testing Your Tag:-

Yet your GA Tag isn’t live, but you can check it if it’s working by hitting preview button. Once Google Tag manager enters into preview mode, reload your site. In Google Tag Manager console window at bottom of your browser window. You should see tag fired when you reload your site.

If you login to Google analytics account, navigate to Real time, you will see page view triggered by reloading your site.

But our Google analytics tag is live only for us not for the users we intend to track. To make the changes live on your site and start tracking data simply click on submit button.

This will slide-in a pop-up that enables you to name your version & add a description. After doing this click on Publish.