Integrating Google Tag Manager in WordPress Plugin

Posted on 20th June 2023

Google Tag Manager (GTM) is a free tool that allows you to manage and deploy marketing tags (such as tracking codes) on your website or mobile app without having to edit your code.

With GTM, you can update your tags and code snippets anytime, without having to go through your development team. This saves you time and ensures that your changes are made correctly.

GTM is also helpful if you are not a developer and don’t have access to your website’s code. It can be used to deploy analytics and marketing tags on your website or app without having to edit code.

In this article, we will show you how to easily add Google Tag Manager to your WordPress website or plugin.

What is Google Tag Manager?

Google Tag Manager is a free tool that allows you to manage and deploy marketing tags (such as tracking codes) on your website or mobile app without having to edit your code.

With GTM, you can update your tags and code snippets anytime, without having to go through your development team. This saves you time and ensures that your changes are made correctly.

GTM is also helpful if you are not a developer and don’t have access to your website’s code. It can be used to deploy analytics and marketing tags on your website or app without having to edit code.

In this article, we will show you how to easily add Google Tag Manager to your WordPress website or plugin.

How Does Google Tag Manager Work?

Google Tag Manager works by inserting a small snippet of code (called a container tag) on your website or app. This container tag loads other tags, such as analytics and marketing tags, from Google Tag Manager’s servers.

When you want to update or add a new tag, you can do it from the Google Tag Manager interface, without having to edit your code.

This is helpful if you are not a developer or if you want to make changes without going through your development team.

It is also helpful if you have multiple tags on your website or app. With GTM, you can manage all your tags in one place.

How to Install Google Tag Manager in WordPress?

The easiest way to install Google Tag Manager in WordPress is by using the Google Tag Manager for WordPress plugin.

This plugin is created by Google and it is available for free from the WordPress.org plugin repository.

First, you need to install and activate the plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, the plugin will add a new menu item labeled ‘Google Tag Manager’ to your WordPress admin bar.

Click on it to open the plugin’s settings page.

On the plugin’s settings page, you need to enter your Google Tag Manager ID. You can find your GTM ID in your GTM account under ‘Admin’ -> ‘Install Google Tag Manager’.

Scroll down to the ‘Where should the container tag be placed?’ section and select ‘Replace the entire section with the Google Tag Manager code’.

This option will insert the GTM container tag in the section of your WordPress website.

Scroll down and click on the ‘Save Changes’ button to store your settings.

That’s it. You have successfully installed Google Tag Manager in WordPress.

How to Add Google Tag Manager to WordPress Theme or Plugin?

If you want more control over where the GTM container tag is placed, then you can add it to your WordPress theme or plugin yourself.

First, you need to login to your Google Tag Manager account and click on the ‘Admin’ tab.

Under the ‘Container’ section, click on the ‘Install Google Tag Manager’ button.

On the next page, you need to scroll down to the ‘Copy the code below and paste it as high in the of every page of your site as possible’ section.

This code contains your GTM ID. You need to copy this code and add it to your WordPress theme or plugin.

If you are using a WordPress theme, then you need to edit your theme’s header.php file and paste the code just before the closing tag.

If you are using a WordPress plugin, then you need to edit your plugin’s main PHP file and paste the code just before the closing tag.

Once you have added the code, you need to click on the ‘Publish’ button to save your changes.

That’s it. Google Tag Manager is now installed on your WordPress website.

How to Use Google Tag Manager in WordPress?

Now that you have installed GTM in WordPress, let’s take a look at how to use it.

First, you need to login to your Google Tag Manager account and click on the ‘Tags’ tab.

On the next page, you need to click on the ‘New Tag’ button.

This will bring up the tag configuration wizard.

First, you need to enter a name for your tag and select the tag type.

For this tutorial, we will be using the ‘Google Analytics’ tag type.

You need to select the ‘Google Analytics’ tag type and enter your Google Analytics Tracking ID.

If you don’t have a Google Analytics account, then you can sign up for one here.

After that, you need to scroll down and click on the ‘Triggering’ tab.

On the next page, you need to select the ‘All Pages’ trigger type.

This trigger type will fire your tag on all pages of your website.

You can also create custom triggers to fire your tag on specific pages or events.

Once you are done, you need to click on the ‘Save’ button to save your changes.

Your tag is now ready and you can click on the ‘Publish’ button to deploy it on your website.

That’s it. You have successfully added your first tag with Google Tag Manager.

You can now repeat these steps to add more tags, without having to edit your code.

We hope this article helped you learn how to use Google Tag Manager in WordPress. You may also want to see our ultimate WordPress SEO guide for beginners.

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.