Skip to Content
LLM Decode learn.llmdecode.com
Back to all resources
SOP-004

Add Google Tag Manager to a WordPress Site

Perfectly add Google Analytics to a site to measure website data and gather visitor insights, using Google Tag Manager and verify that it is working properly

Type SOPs · PDF
Execution time 10-15 minutes
Last updated 09 June 2025
Who does this The person responsible for website management or analytics
Length 14 pages

Goal

To add Google Tag Manager to a WordPress site

Ideal outcome

Google Tag Manager is properly installed without any technical issues

Why it matters

Google Tag Manager is a great tool to add and manage multiple pixels and tracking codes without needing to edit the code of a site

Before you start

This exact process only applies to WordPress sites

Key steps 34 steps

What is inside 37 headings

1 Environment setup 8

  1. Download the Google Tag Assistant Companion (Free).
  2. To sign up for Google Tag Manager (Free), you’ll need to log in to your Google account.
  3. If this is your first time creating a Google Tag Manager Account, you’ll be redirected to the account creation page.
  4. Fill in the following information:
  5. Once finished. Click “Create”.
  6. You’ll see a Google Tag Manager Terms of Service pop-up. Select the checkbox and click “Yes”.
  7. You will see the code for installing Google Tag Manager. Ignore this since you won’t be manually adding code to your WordPress site. Click “OK”.
  8. Click on "Submit" > "Publish" > Continue to publish your Google Tag Manager container and that’s it!

2 Install and configure the Google Tag Manager WordPress plugin 14

  1. Log into your WordPress site.
  2. In the WordPress sidebar, go to "Plugins" > "Add New".
  3. Enter “Google Tag Manager for WordPress” in the search box.
  4. Install the GTM4WP plugin (the image may vary).
  5. To activate the plugin, go to the WordPress sidebar and click "Settings" > "Google Tag Manager".
  6. Paste your Google Tag Manager ID (the one you got from the Google Tag Manager dashboard) in the available field.
  7. The plugin offers several ways to install the container code on your site. Before you implement any of these, we recommend you create a backup of your site.
  8. Copy the PHP code provided by the plugin and click on “Save Changes”.
  9. In the WordPress sidebar, go to "Appearance" > "Theme Editor".
  10. Make sure that you are editing the theme that you currently have installed on your site (you can go to "Appearance" > "Themes" to check the name of the theme you are using).
  11. Select the “Theme Header” template from the list on the right.
  12. This template is different depending on the theme that you have installed. However, you will always be able to find an opening <body> tag in the code.
  13. Paste the PHP code provided by the plugin right below the opening <body> tag.
  14. Click on “Update File”.

3 QA your installation 12

  1. Open your website homepage using Chrome.
  2. Right-click on the page and select "View Page Source".
  3. Press Ctrl + F (or Command + F on Mac) and search for your GTM ID (e.g., GTM-XXXXXX).
  4. If you do not see the GTM ID in the source code:
  5. Go to Google Tag Manager and open your container.
  6. Click the "Preview" button in the top right.
  7. Enter your website URL in the pop-up window and click "Connect".
  8. A new window will open showing your site with a debug console at the bottom.
  9. Install and open the Google Tag Assistant Companion icon on your browser.
  10. Click on “Add domain”.
  11. Enter your website URL, click “Connect” and reload the page.
  12. If successful, a message saying Tag Assistant Connected will appear.

The document 14 pages

The file is locked

It comes with 2 DAY GEN AI ENGINEERING MASTERMIND, or with the full library.

Bought from LLM Decode before? Sign in to pay ₹ 1,999.00.

Up next · SOP-005 Install Meta Pixel On Your Site How to properly install the Facebook pixel on any site. With this pixel, you can create remarketing audiences and set up conversions for your campaigns Unlock to read