How to Add Google Tag Manager to WordPress in 2 Steps

Want to add Google Tag Manager to WordPress and simplify your site tracking system? This tutorial will show you how to install Google Tag Manager in WordPress with and without a plugin.

If you want to track the pageviews, conversions, and use other analytics services on your WordPress site, you need to install tracking codes for them. Each of these services usually comes with different tracking keys.

For example, you need to enter different code snippets for Google Analytics, Facebook Pixel, DoubleClick, Google Ads, etc. It’s a hassle to install and manage these codes separately. Google Tag Manager is a great way to save your time and efforts with a unified solution in this regard.

What is Google Tag Manager

Google Tag Manager is a free online tool. It lets you add and manage various tracking tags from a single dashboard. 

Once you install Google Tag Manager in your WordPress site, you can add other trackers like Google Analytics, Facebook Pixel, and more from Google’s dashboard. You don’t need to visit your WordPress backend or edit your theme files to insert a tracking code thereafter.

Google Tag Manager vs Google Analytics

Glad that you’ve asked! It’s a common query whether Google Tag Manager and Google Analytics are the same. Well, they’re not. Google Tag Manager just creates a way for the trackers to communicate with your website. 

Once you add Google Tag Manager (GTM) to WordPress, this communication path is established. Then, you will need to add the tracking and marketing services (to GTM) that you want. These can be Google Analytics, Facebook Pixel, Google Ads, custom HTML tags, etc.

Get Latest Post Notifications!

Subscribe to our newsletter

So Google Tag Manager and Google Analytics are not the same. When you install Google Analytics (GA) separately on your site, you’ll use GA (only) for that effort.

But if you install Google Tag Manager on WordPress, later you can install many tracking services like GA from the Google Tag Manager dashboard. So using Google Tag Manager is a smarter choice if you consider it for the long run.

How to install Google Tag Manager in WordPress

This is going to be an easy-to-follow process. Let’s see it in this step-by-step tutorial. Here we go!

Step 1: Sign up with Google Tag Manager

Visit the Google Tag Manager website and click the “Start for free” button.

google tag manager landing page

On the next screen, it will ask for some information.

google tag manager signup page

Set a Google Tag Manager account name. Then for the container name, give the specific website domain for which you’re creating your first tag collection. Simply put, a container will contain all the tags for a specific website (or property).

Since we’re talking about WordPress websites, we’ll choose the “Web” option. It will fit for this how to set up Google Tag Manager in WordPress tutorial.

google tag manager container setup

Click the Create button to continue. You’ll see an agreement screen. You need to agree with their terms and conditions to proceed.

On the next screen, 2 code snippets will appear.

google tag manager code snippets

We need to insert these codes into our WordPress site where we want to install Google Tag Manager.

Step 2: Add Google Tag Manager Code to WordPress

In the screenshot above, you can see that the first code snippet needs to be entered in the <head> section of the site. And the second one needs to be entered into the <body> section.

We’ll use a WordPress plugin called “Insert Headers and Footers” to add these snippets. (We can also do it without any plugin, but in that case, we would need to edit our theme’s PHP file. If you’re comfortable with editing the codes of your theme, you can do that. We’ll discuss this method later in this tutorial.)

Install and activate the Insert Headers and Footers plugin on your site. Then open it from DashboardSettings.

Insert Headers and Footers plugin interface

Enter the appropriate code snippets for the <head> and the opening <body> tags. The plugin specifies this for your convenience. Once done, save changes.

👉 Learn More: PostX Review: Best Post Grid WordPress Plugin

By saving these codes, we’ve added or installed Google Tag Manager on WordPress. Now you can visit the GTM dashboard and add your desired tracking services using Google Tag Manager.

Example: Adding a tag via Google Tag Manager

So you’ve installed Google Tag Manager on your WordPress site. As we’ve discussed earlier, no tracking or marketing service will be activated automatically. You need to add these services from the Google Tag Manager (GTM) dashboard. So let’s go to the GTM account dashboard.

Google Tag Manager dashboard

From the top left card, click the “Add a new tag” option. On the next screen, you’ll need to choose a Tag configuration. For this example, we’ll add Google Analytics.

Tag configuration

Click the Tag configuration option and choose Google Analytics: Universal Analytics.

tag configuration 2

Now, under Google Analytics Settings, click Select Settings Variable.

adding tag via GTM

Choose New Variable. Enter your Google Analytics tracking ID for the WordPress site where you want to add Google Analytics via GTM.

adding tag - adding ga tracking id

If you’ve already created a Google Analytics (GA) property for this WordPress site, you can find the tracking ID by following these instructions. Otherwise, you need to create a Google Analytics property for this site. You can follow Google’s guide on how to create a Google Analytics property.

After getting the GA tracking ID, enter it and save changes (see the screenshot above). 

Then, click the Triggering option.

adding tag - ga trigger

Choose All Pages.

Google Tag Manager ga trigger all pages

Save settings.

google tag manager trigger settings

The tag will be saved, but it will NOT go live immediately. We need to publish it.

Publishing a Tag in Google Tag Manager

Sign in to your GTM account. You’ll see all of your Containers. Click the container you want to open.

Google Tag Manager containers

Hit the Tags menu to view all of your tags. 

Google Tag Manager all tags before publishing

Click the Submit button on the top right corner. On the next screen, it will show some options.

publishing a google tag manager tag

You can explore these options to save the GTM container code versions (without publishing) or simply create a version and publish the tag(s).

After publishing the tag(s), you’ll see a success message.

gtm analytics published

How to Add Google Tag Manager to WordPress Without Plugin

As we’ve mentioned earlier, you’ll have to edit your WordPress theme’s header.php file to do this. This might not be the same for all themes. If you use a child theme, the header.php of the child theme should be edited.

As an admin, you can access the theme file editor from your WordPress Dashboard. Go to DashboardAppearanceTheme Editor. You’ll see the theme files there. Open header.php and enter the code snippets under the <head> tag and <body> tag respectively. Then save changes.

Since this method also depends on the theme you’re using, so it would be best if you ask for some support from your theme developer. Sometimes the theme may come with options to insert header and body scripts from the theme’s settings panel.

Wrapping up

We hope this tutorial was helpful to you. Have you added Google Tag Manager to your WordPress site? How was your experience? Please let us know in the comments!

Disclaimer: This post may contain affiliate links and we may receive a small commission if you purchase something by following them. However, we recommend services/products that we believe good to serve your purpose.

Staff Author

Staff Author

A team of WordPress enthusiasts led by Arafat Bin Sultan, a seasoned professional with over a decade of experience in tech blogging, content marketing, and video creation.

Articles: 242

Leave a Reply

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