Skip to content

What is Google Tag Manager and how to install it

April 10, 2024
Anadir-google-tag-manager

Hello, my name is Javier Chiva, I work as a freelance web developer. Today I would like to talk about Google Tag Manager (GTM) a fundamental tool to understand the behaviour of visitors on the websites I develop.

Integrating GTM into WordPress offers numerous advantages, from improving SEO strategies to gaining deeper insights about our users. However, I know that for many it can seem like a complex task.

Through this guide, I will share my experience and knowledge to help you integrate Google Tag Manager into your WordPress site in a simple and effective way.

From basic installation to advanced optimisation tips, I will show you how to get the most out of GTM, turning web analytics into a powerful ally for your online project.

Google Tag Manager

What is Google Tag Manager and why should you use it in WordPress?

Google Tag Manager (GTM) is a free tool that allows you to manage and deploy tracking tags. and marketing on your website without the need to modify the code.

It is especially useful for those without advanced programming skills, but also offers incredible flexibility and power for experienced developers.

In the context of WordPress, GTM becomes a valuable resource for several reasons:

  1. Simplification of label management: GTM allows you to add, edit and disable tags through a user-friendly interface, without having to touch the site's code.
  2. Improved site performance: By handling all tags from one place, you reduce the amount of code that needs to be loaded directly on your site, which can improve loading speed.
  3. Advanced analysis and monitoring: With GTM, you can easily implement conversion tracking, user behaviour analytics, remarketing and more, allowing you to gain valuable insights into how visitors interact with your site.

Integrating Google Tag Manager into WordPress will not only help you have more efficient control over your user tracking and analytics data collection, but will also optimise the overall performance of your site, which is essential for a good SEO strategy and to provide an exceptional user experience.

We will now move on to how you can install Google Tag Manager on your WordPress site, either manually or via a plugin, making sure to cover all the necessary steps for a successful integration.

Google Tag Manager como instalar
Index

    How to install Google Tag Manager on WordPress

    Installing Google Tag Manager on your WordPress site is a simple process and you can do it in two ways: manually or by using a plugin.

    Below, I explain both methods so that you can choose the one that best suits your needs.

    Option 1: Manually

    1. Create a Google Tag Manager account: The first thing to do is to contact Google Tag Manager and create a new account. If you already have one, you just need to add a new container for your WordPress site.
    2. Get the GTM code: Once you have set up your container, you will be provided with a snippet of code. This code is what will link your WordPress site to GTM.
    3. Insert the code into WordPress: To insert the GTM code, you need to edit your WordPress theme files. Ideally, place the code right after the <head> in the archive header.php and, according to GTM's instructions, also just after the opening label <body>.
      • Note: If you are not comfortable editing theme files or if your site receives frequent theme updates, consider creating a child theme or using a specific plugin that allows you to insert code snippets.
    4. Check the installation: You can verify that GTM is working properly on your site by using the Google Chrome Tag Assistant extension or by simply checking the source code of your website to make sure that GTM code is present.

    Option 2: Using a Plugin for Google Tag Manager

    If you prefer to avoid editing your theme files directly, you can use a WordPress plugin specifically designed to integrate Google Tag Manager:

    1. Install a GTM plugin: There are several free and paid plugins that make it easy to integrate GTM into WordPress. Some of the most popular include "DuracellTomi's Google Tag Manager for WordPress" and "Insert Headers and Footers".
    2. Configure the plugin: Once installed, go to the plugin configuration and enter the ID of your GTM container. This ID is usually in the format "GTM-XXXXXXXX".
    3. Save changes and verify installation: After saving your changes, use the Google Chrome Tag Assistant extension or check the source code of your page to make sure the GTM code is loading correctly.

    Both methods are effective for integrating Google Tag Manager into WordPress, and the choice depends on your comfort level with code editing and your personal preferences.

    Setting up your first tag in Google Tag Manager for WordPress

    Once you have installed GTM on your WordPress site, the next step is to set up tags. Tags are small pieces of code or tracking pixels that collect and send information to third parties, such as Google Analytics.

    Here's how you can set up your first label, step by step:

    1. Log in to your Google Tag Manager account: Go to GTM and select the container you have created for your WordPress site.
    2. Create a new label: Click on "Tags" in the side menu and then on "New" to start setting up a new tag.
    3. Configure the Google Analytics tag: As an example, let's set up a Google Analytics tag. Choose "Google Analytics: Universal Analytics" as the tag type. Next, you will need to set the tracking type (e.g. "Page View") and provide the tracking ID of your Google Analytics account.
    4. Set the trigger: The trigger determines when the tag will be activated. For basic page view tracking, you can use the default "All Pages" trigger, which activates the tag on all pages of your site.
    5. Save and test your label: Once set up, save your tag and use the preview mode in GTM to test that the tag is working properly on your site. You can check in Google Analytics to see if page views are registering as expected.
    6. Publish the modifications in GTM: After confirming that everything is working correctly, don't forget to publish the changes to GTM so that your tag settings are activated on your live site.

    Setting up tags in GTM may seem complex at first, but once you become familiar with the interface and process, you will discover the powerful flexibility GTM offers for advanced tracking and optimisation of your WordPress site.

    Best practices for Google Tag Manager in WordPress

    To ensure a successful and efficient implementation of GTM in WordPress, here are some best practices:

    • Keep your GTM clean: Organise your labels, triggers and variables logically, using descriptive names to make them easier to manage in the long term.
    • Use preview and debugging: Before publishing changes, always use the preview mode to test your tags to make sure they work as expected.
    • Safety first: Limit access to your GTM account to only users who need to edit or manage tags.
    • Document your changes: Keep track of changes made in GTM, especially if you are working in a team. This will help avoid confusion and facilitate problem solving.
    • Keep up to date: GTM and tracking tools are constantly evolving. Stay informed about new features and best practices.

    By following these tips, you will be able to make the most of Google Tag Manager on your WordPress site, improving your web analytics and data-driven decision making.

    Troubleshooting common problems when installing or configuring GTM in WordPress

    Even with a detailed guide, problems can still arise when installing or configuring Google Tag Manager on WordPress. Below, I'll address some of the most common problems and how to fix them.

    Problem 1: GTM does not collect data

    If you have configured GTM but do not see data in the relevant analysis platforms, consider the following:

    • Check your label and trigger settings: Make sure that the tags are configured correctly and that the triggers are activating the tags as they should.
    • Use the GTM preview mode: This will help you identify if the tags are triggering correctly when you visit your site.
    • Check the GTM code on your site: Make sure that the GTM code has been added correctly to your WordPress site, according to the installation instructions.

    Problem 2: Slow loading of the site

    Although GTM can improve performance by centralising tag management, misconfiguration can slow down your site:

    • Limit the number of labels: Use only necessary labels and avoid redundancy.
    • Optimise triggers: Configure triggers so that labels are loaded only under specific conditions, rather than on all pages.

    Problem 3: Conflicts with WordPress plugins

    Some WordPress plugins may interfere with the correct execution of GTM:

    • Temporarily disable other plugins: If you suspect a conflict, try disabling other plugins temporarily to identify the problem.
    • Search for GTM compatible plugins: Some plugins are designed to work well with GTM, consider using them if you face compatibility issues.

    Frequently asked questions

    Do I need to know how to code to use Google Tag Manager in WordPress? Plus Icon

    Can I use Google Tag Manager to track specific events on my WordPress site, such as button clicks or subscription forms? Plus Icon

    Does GTM affect the SEO of my WordPress site? Plus Icon

    en_GB
    Options
    ×