How to Install Google Tag Manager in WordPress

How to Install Google Tag Manager in WordPress (The RIGHT Way)

Are you looking to install Google Tag Manager in WordPress?

If you want to integrate various analytics and marketing services on your WordPress site, then Google Tag Manager is a great tool you can use. It allows you to add and update various tracking codes on your website easily.

In this article, we’ll show you how to install Google Tag Manager in WordPress in the right way.

What Is Google Tag Manager?

Google Tag Manager is a free tag management tool by Google, which allows you to deploy and update different code snippets called ‘tags’ on your website.

MonsterInsights is the best WordPress Analytics plugin. Get it for free!

Different tracking services like Google Analytics, Adobe Analytics, Facebook Pixel, LinkedIn Insight, and advertising tools like Google AdWords require you to add a few lines of JavaScript or HTML code to your website to integrate their services.

With Google Tag Manager, you can easily add and manage all these codes from a single interface, without having to edit your website’s code.

There’re built-in tag templates for popular services like Google Analytics and DoubleClick. You can also add custom tags to your website.

Google Tag Manager is a smart tool which enables anyone, including beginners, to implement tracking scripts on their websites quickly.

With that said, let’s go ahead and see how to set up Google Tag Manager in WordPress in the proper way.

Adding Google Tag Manager to WordPress – Step by Step

Step 1: Create Your Google Tag Manager Account

First of all, you need to visit the Google Tag Manager website, and then click the Sign-Up button.

Sign Up for Google Tag Manager

Next, you need to sign in with your Google account. Once done, you can see the Google Tag Manager’s Create Account page. Click on the ‘Create Account’ button to get started.

Create Google Tag Manager Account

On the next screen, you can add a new account. Enter your account name and choose a country in the Account Setup box. You can use your company name as your account name.

Add New Google Tag Manager Account - Account Setup

Next, you need to set up your container. A container is the collection of tags, triggers, and all configurations installed on a website.

You can enter your website name as your container name. Choose ‘Web’ under Where to use container option, and then click on the Create button.

Google Tag Manager Container Setup

Now you’ll need to accept Google Tag Manager Terms of Service Agreement to proceed. Check the box next to ‘I accept the Data Processing Terms as required by GDPR.’ at the bottom, and then also click the ‘Yes’ button on the top right corner.

If you want to learn more about GDPR, go through our guide on GDPR and Google Analytics.

Accept Google Tag Manager Terms of Service and GDPR terms

Upon accepting the terms of service, you’ll see a new popup window appear on screen with code snippets to install Google Tag Manager on your website.

Google Tag Manager Installation Codes

There’re two code snippets to be added to header (inside <head > tag) and in the <body > section on your website.

Step 2: Adding Google Tag Manager Code to WordPress

Login to your WordPress dashboard and then install Insert Header and Footers plugin. Upon activation, go to Settings » Insert Headers and Footers page.

Insert Headers and Footers WordPress Plugjn Settings

Now you can see two boxes for adding header and footer code. Go back to your Google Tag Manager account and copy the code in the first box. Paste the code into ‘Scripts in Header’ box.

Similarly, copy the other code from your Tag Manager account and insert that into the ‘Scripts in Footer’ box.

Add Google Tag Manager Codes to WordPress with Insert Headers and Footers plugin

After that, don’t forget to save your changes.

That’s it! You’ve successfully installed Google Tag Manager in your WordPress site. Now you can use your Google Tag Manager dashboard to install any tracking code to your WordPress website.

Step 3: Add and Publish Tags in Your Tag Manager

Once you’ve installed Google Tag Manager on your website, you’re ready to add code snippets (tags) provided by different tracking tools on your site.

Google Tag Manager supports over 50 tag types, including the Google marketing products and other third-party services. Plus, you can also add custom HTML or JavaScript tags on your site using its interface.

Click on the ‘New Tag’ icon, and follow the steps to create your first tag.

Click New Tag Option to Add a New Code in Google Tag Manager

As an example, you can check out our full guide on how to install Google Analytics in WordPress with Google Tag Manager.

Now, you can add different tags in your Google Tag Manager container by following the same process and integrate your WordPress site with various marketing and tracking tools.

We hope this article helped you to learn how to install Google Tag Manager in WordPress in the right way. You may also want to see our guide on how to configure your WordPress website with Google Search Console.

And don’t forget to follow us on Twitter and Facebook for more helpful marketing tips.

Want to Try MonsterInsights for Free?

Enter the URL of Your WordPress website to install MonsterInsights Lite.


  1. what about the code that Google tells you to put right after the opening tag? How do you do that without editing your header.php file?

    1. Hi James,

      If you’re using the Insert Headers and Footers plugin and you need to insert snippets within the your site’s <body>, use the “Scripts in Footer” section.

      The section will print scripts before the closing </body> tag.

      While it’s not right after the opening body tag (as Google suggests), as long as the snippet is enclosed within the <body>…</body> tag, it will be fine.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.