Adding Google Tag Manager to a WordPress Site

Goal: To add Google Tag Manager to a WordPress site.
Ideal Outcome: Google Tag Manager is properly installed without any technical issues.

Pre­requisites or requirements: This exact process only applies to WordPress.org sites.

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

Where this is done: In your WordPress install and Google Tag Manager. When this is done: Only once—the first time you install Google Tag Manager. Who does this: The person responsible for website management or analytics.


Environment Setup


Important: This Article works only for self­hosted WordPress sites, aka WordPress.org

and not WordPress.com

  1. Download the Google Tag Assistant Chrome Extension (Free)

  2. Sign up for Google Tag Manager (Free):

    1. You’ll need to log in to your Google account.

    2. If this is your first time creating a Google Tag Manager Account, you’ll be prompted to set up one right away.
      • You can just use your company/website name for both the account and container
      • Under “Where to Use Container”, select “Web”
google tag manager setup

c. Accept the terms and conditions.

  1. You will see your Google Tag Manager code, but you won’t need it using this method.
  2. Once, you are in your Workspace, make note of your Google Tag Manager ID.


  1. Click on Submit > Publish > Continue to publish your Google Tag Manager container. 




Install and configure the Google Tag Manager WordPress plugin

  1. Log in to 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 DuracellTomi’s Google Tag Manager for WordPress (the image may vary).


5. Activate the plugin.
6. In the WordPress sidebar, go to Settings > Google Tag Manager
7. Paste your Google Tag Manager ID (the one you got from the Google Tag Manager dashboard) in the available field.



8. 
Select the “Custom (needs tweak in your template)” container code placement and click on “Save Changes.”



9. Copy the PHP code provided by the plugin and click on “Save Changes”



10. 
In the WordPress sidebar, go to Appearance > Editor
11. Make sure that you are editing the Theme that you currently have installed in your site (you can go to Appearance > Themes to check the name of the theme you are using)



12. Select the “Theme Header” template from the list on the right.
13. 
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.



14. 
Enter the PHP code provided by the plugin right below the opening <body> tag.



15. 
Click on “Update File”

QA-ing your installation 

1. Open your website homepage using Chrome.
2. Click on the Google Tag Assistant Chrome Extension


3. 
Click on “Enable”



4. 
Refresh the page and click on the Google Tag Assistant Chrome Extension again.
5. 
You should see a green tag for Google Tag Manager, indicating that the installation was successful.


Did you find this article useful?