How to Add Google Tag Manager to WordPress?

14 minutes read

To add Google Tag Manager to a WordPress website, you need to follow these steps:

  1. Sign in to your Google Tag Manager account. If you don't have one, you can create it by visiting the Google Tag Manager website.
  2. Once you're logged in, click on "New Container" and give it a name that represents your website.
  3. After creating the container, you'll see a popup window containing two code snippets, the first one is for the head section of your website, and the second one is for the body section. Copy these code snippets.
  4. Log in to your WordPress admin dashboard.
  5. In the dashboard menu, go to "Appearance" and click on "Editor."
  6. On the right side, you'll see different templates listed. Look for "Theme Header" or "header.php" (this may vary depending on your theme).
  7. Click on the "Theme Header" or "header.php" to open it in the code editor.
  8. Paste the code snippet that you copied from Google Tag Manager just before the closing tag.
  9. Save the changes.
  10. Now go back to Google Tag Manager and copy the second code snippet.
  11. Return to your WordPress admin dashboard.
  12. In the dashboard menu, go to "Plugins" and click on "Add New."
  13. Search for "Insert Headers and Footers" in the plugin search bar.
  14. Install and activate the "Insert Headers and Footers" plugin.
  15. Once activated, go to "Settings" and click on "Insert Headers and Footers."
  16. Paste the second code snippet into the box labeled "Scripts in Footer."
  17. Save the changes.


Congratulations! You have successfully added Google Tag Manager to your WordPress website. Please note that the steps provided may vary slightly depending on your theme or any additional plugins you may be using.

Best Google Analytics Books In 2024

1
Google Analytics Demystified (4th Edition)

Rating is 5 out of 5

Google Analytics Demystified (4th Edition)

2
Learning Google Analytics: Creating Business Impact and Driving Insights

Rating is 4.9 out of 5

Learning Google Analytics: Creating Business Impact and Driving Insights

3
Google Analytics: Understanding Visitor Behavior

Rating is 4.8 out of 5

Google Analytics: Understanding Visitor Behavior

4
Google Analytics Breakthrough: From Zero to Business Impact

Rating is 4.7 out of 5

Google Analytics Breakthrough: From Zero to Business Impact

5
Google Analytics Alternatives: A Guide to Navigating the World of Options Beyond Google

Rating is 4.6 out of 5

Google Analytics Alternatives: A Guide to Navigating the World of Options Beyond Google

6
Learning Google AdWords and Google Analytics

Rating is 4.5 out of 5

Learning Google AdWords and Google Analytics

7
Data Engineering with Google Cloud Platform: A practical guide to operationalizing scalable data analytics systems on GCP

Rating is 4.4 out of 5

Data Engineering with Google Cloud Platform: A practical guide to operationalizing scalable data analytics systems on GCP

8
Practical Google Analytics and Google Tag Manager for Developers

Rating is 4.3 out of 5

Practical Google Analytics and Google Tag Manager for Developers

9
Advanced Web Metrics with Google Analytics

Rating is 4.2 out of 5

Advanced Web Metrics with Google Analytics


How to track form submissions using Google Tag Manager on WordPress?

To track form submissions using Google Tag Manager on WordPress, follow these steps:

  1. Install and activate the Google Tag Manager (GTM) plugin in your WordPress admin panel.
  2. Log in to your Google Tag Manager account and create a new GTM container.
  3. Retrieve the GTM container ID, which will be in the format "GTM-XXXXXX."
  4. Go back to your WordPress admin panel and navigate to the GTM plugin settings.
  5. Enter your GTM container ID in the provided field and save the changes.
  6. Open Google Tag Manager and create a new Trigger.
  7. In the Trigger Configuration, select the appropriate trigger type based on your form submission (e.g., a specific form ID, form submission event, etc.).
  8. Configure the trigger options according to your specific form structure and requirements.
  9. Save the trigger and create a new Tag.
  10. In the Tag Configuration, select "Google Analytics – Universal Analytics" as the tag type.
  11. Enter your Google Analytics tracking ID (UA-XXXXX-X) in the "Tracking ID" field.
  12. Add a custom event name in the "Event" field to help you identify the form submission in Google Analytics.
  13. Under the "Triggering" section, select the previously created Trigger.
  14. Save the Tag and submit changes in Google Tag Manager.
  15. Update the GTM container on your WordPress site by refreshing the GTM plugin settings page and clicking the "Update Google Tag Manager" button.
  16. Test the implementation by submitting a form on your website and checking if the form submission event is recorded in your Google Analytics account.


What is Google Tag Manager and why should I use it on WordPress?

Google Tag Manager is a free tool provided by Google that allows you to manage and deploy various tracking codes and tags on your website. Instead of manually adding these codes to your website's source code, Google Tag Manager provides a user-friendly interface where you can add, modify, and update tags without any coding knowledge.


Using Google Tag Manager on WordPress can be beneficial for several reasons:

  1. Easy implementation: With Google Tag Manager, you only need to add the Tag Manager code snippet to your WordPress site once. Afterward, you can manage all your tracking codes and tags through the Tag Manager interface without editing your site's code.
  2. Flexibility and scalability: Tag Manager allows you to implement various tracking codes and tags without relying on a developer. You can track website analytics, conversion tracking, remarketing, and more, by simply adding tags in the Tag Manager interface.
  3. Centralized control: Tag Manager provides a centralized platform to manage all your tags, making it easier to track, update, and maintain your website's tracking codes. It eliminates the need to modify code on multiple pages whenever you make changes.
  4. Reduced page load time: Google Tag Manager loads tags asynchronously, which means they don't block the rendering of your website content. This can help improve your website's load time, providing a better user experience.
  5. Collaboration: If you have multiple people working on your website, Tag Manager allows you to collaborate by providing different levels of access to users. You can grant permissions to view, edit, or publish tags, allowing for better teamwork.


Overall, using Google Tag Manager on WordPress allows you to manage tracking codes more efficiently and provides greater control over your website's analytics and marketing integrations.


How to install Google Tag Manager on WordPress?

To install Google Tag Manager on WordPress, you can follow these steps:

  1. Sign in to your Google Tag Manager account (or create a new one if you don't have one already).
  2. Once signed in, click on "New Account" to create a new container.
  3. Provide a name for your container, choose the platform as Web, and click on "Create".
  4. In the next window, you'll see the Container Preview and the Container ID. Copy the Container ID, which will look like GTM-XXXXXX.
  5. Log in to your WordPress dashboard.
  6. Install and activate a plugin called "Insert Headers and Footers". This plugin allows you to easily add code snippets to your website.
  7. Once activated, go to "Settings" and click on "Insert Headers and Footers".
  8. In the "Scripts in Header" section, paste the Google Tag Manager code snippet that you copied earlier in the "Scripts in Header" field.
  9. Save the changes.
  10. Go back to your Google Tag Manager account and click on "Submit" to publish the container.
  11. Verify the installation by visiting your website and checking if the Google Tag Manager container is present in the source code.


That's it! Google Tag Manager is now installed on your WordPress website. You can start adding tags, triggers, and variables within your Google Tag Manager account to track various events and analytics on your site.


What are the steps to add Google Analytics tracking using Google Tag Manager on WordPress?

To add Google Analytics tracking using Google Tag Manager on WordPress, follow these steps:

  1. Sign in to your Google Tag Manager account and create a new container for your website.
  2. Copy the generated code snippet for the container.
  3. Install and activate the "Insert Headers and Footers" plugin on your WordPress website.
  4. Go to Settings > Insert Headers and Footers on your WordPress dashboard.
  5. Paste the Google Tag Manager container code snippet into the "Scripts in Header" section.
  6. Save your changes.
  7. Go back to your Google Tag Manager account and set up a new Google Analytics tag.
  8. Configure the Google Analytics tag by entering your Google Analytics Tracking ID and desired settings.
  9. Set the trigger for the tag to "All Pages" so that it fires on every page of your website.
  10. Save the tag.
  11. Publish your changes in Google Tag Manager.
  12. Go back to your WordPress dashboard and head to the "Tags" section of the Google Tag Manager plugin.
  13. Click on "Import Google Analytics settings" and select the container that contains your Google Analytics tag.
  14. Map the settings accordingly and click "Import settings."
  15. Save your changes in the plugin.
  16. Clear any caching that may be active on your website.


After completing these steps, Google Analytics tracking will be added to your WordPress website using Google Tag Manager. You can monitor the data in your Google Analytics account for insights into your website's performance.


What is the process of adding Hotjar tracking code using Google Tag Manager on WordPress?

To add Hotjar tracking code using Google Tag Manager on WordPress, follow these steps:

  1. Install and activate the Google Tag Manager plugin on your WordPress site.
  2. Go to the Google Tag Manager website (tagmanager.google.com) and sign in with your Google account.
  3. Create a new container by clicking on the "Create Account" button and entering your container name.
  4. After creating the container, you will be provided with a container ID that starts with "GTM-". Copy this ID.
  5. Go to your WordPress admin area and navigate to the Google Tag Manager plugin settings.
  6. Paste the container ID into the "Container ID" field and save the changes.
  7. Now, go back to the Google Tag Manager website and click on your container.
  8. In the container overview, click on "Add a new tag".
  9. Give your tag a name and click on the "Tag Configuration" section.
  10. Select "Custom HTML" under the "Choose tag type" option.
  11. Copy the Hotjar tracking code that you obtained from the Hotjar website.
  12. Paste the Hotjar tracking code into the "HTML" field in Google Tag Manager.
  13. Click on the "Triggering" section and choose either "All pages" or specify the pages you want to track with Hotjar.
  14. Save the tag and submit the changes in Google Tag Manager.
  15. Finally, go back to your WordPress admin area and verify that the Google Tag Manager plugin is active and the Hotjar tracking code is working properly on your website.


Remember to publish the changes in Google Tag Manager for them to take effect.


How to use data layer variables in Google Tag Manager on WordPress?

To use data layer variables in Google Tag Manager on WordPress, you need to follow these steps:

  1. Install and activate the Google Tag Manager plugin on your WordPress site.
  2. Go to your Google Tag Manager account and create a new Variable. Choose the appropriate variable type based on the data you want to collect (e.g., Constant, JavaScript Variable, Data Layer Variable).
  3. In WordPress, navigate to your Google Tag Manager settings by clicking on "Google Tag Manager" in the left-hand menu of your WordPress dashboard.
  4. Enter your Google Tag Manager container ID in the provided field.
  5. In the "Tag Manager Variables" section, select the appropriate data layer variable from the dropdown menu or create a new one by clicking on the "Add New Variable" button.
  6. Save your changes.
  7. Go to your Google Tag Manager account and create a new Tag or modify an existing Tag.
  8. Use the data layer variable by selecting it from the variable dropdown options or by typing it directly in the appropriate field.
  9. Once you have finished configuring your Tag, save and publish it.


Note: Make sure that the data layer variable is present on the website before the Tag is fired. You can check this by inspecting the page source code or using the Google Tag Assistant Chrome extension.

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

To track website tags with Google Tag Manager, follow these steps:Set up a Google Tag Manager account: Start by signing in to your Google account and access the Google Tag Manager website. Create a new account by providing the necessary details and setting up ...
To check your Google Tag Manager tags, you can follow these steps:Go to the Google Tag Manager website and log in with your Google account credentials. Once logged in, you'll be directed to the Google Tag Manager dashboard. Select the container you want to...
To set up Google Tag Manager for Magento 2, you need to follow these steps:Create a Google Tag Manager account: Go to the Google Tag Manager website and sign in with your Google account or create a new one if you don't have one. Set up a new container: Onc...