How to set up Google Tag Manager for website tracking

Author:

Setting up Google Tag Manager (GTM) for website tracking allows you to manage and deploy various tracking tags (such as Google Analytics, Facebook Pixel, etc.) without directly modifying your website’s code. Here’s a comprehensive guide to help you set up Google Tag Manager for website tracking:

Prerequisites

  1. Google Tag Manager Account: Ensure you have a GTM account set up. If not, create one at Google Tag Manager.
  2. Access to Website: You should have access to edit the HTML of your website or CMS to add the GTM container code snippet.

Step-by-Step Guide to Set Up Google Tag Manager

1. Create a Google Tag Manager Account and Container

  1. Sign in to Google Tag Manager:
  2. Create an Account:
    • If you don’t have an account, create one by entering an Account Name and selecting your country or region.
  3. Create a Container:
    • Once logged in, click on “Create Account” to create a new account if needed.
    • Click on “Create Container” to set up a new container for your website.
  4. Enter Container Details:
    • Choose a Container Name (e.g., your website name).
    • Select the Target Platform (Web).
    • Choose a Container Setup Method (e.g., Web).
  5. Accept Terms:
    • Review and accept the Google Tag Manager Terms of Service.
  6. Obtain Container Snippet:
    • After creating the container, you’ll be presented with the GTM container snippet (a piece of JavaScript code). Copy this snippet.

2. Install Google Tag Manager Container Code on Your Website

  1. Add Container Snippet to Your Website:
    • Paste the GTM container snippet into every page of your website’s HTML, ideally in the <head> section, just after the opening <body> tag.
    • Alternatively, use a CMS plugin or integration if available (e.g., for WordPress, Drupal, etc.).
  2. Verify Installation:
    • Save and publish your website changes.
    • Verify the GTM container installation using tools like the GTM Preview Mode or browser extensions (e.g., Tag Assistant for Chrome).

3. Set Up Google Analytics Tracking via Google Tag Manager

  1. Create a Google Analytics Tag:
    • Log in to your GTM account and select the container for your website.
    • Click on “Tags” in the left sidebar and then click on “New.”
    • Choose “Tag Configuration” and select “Google Analytics: Universal Analytics” (for gtag.js) or “Google Analytics: GA4 Configuration” (for Google Analytics 4).
    • Configure the tag with your Google Analytics tracking ID (UA-XXXXX-X for Universal Analytics) or Measurement ID (G-XXXXXXX for GA4).
    • Choose “Page View” as the track type (or configure other settings as needed, such as event tracking).
    • Set up triggers (e.g., All Pages trigger to fire on all page views).
  2. Set Up Trigger:
    • Click on “Triggering” in the tag configuration.
    • Create a new trigger (e.g., “All Pages”) to fire on all pages of your website.
    • Save your trigger.
  3. Save and Publish:
    • Name your tag (e.g., “Google Analytics – Page View”) and click on “Save.”
    • Click on “Submit” to publish your changes in GTM.

4. Add Additional Tags (Optional)

  1. Add Other Tags:
    • Follow similar steps to add tags for other tools or platforms you wish to track (e.g., Facebook Pixel, Google Ads Remarketing, Hotjar, etc.).
    • Choose the appropriate tag type and configure it based on the platform’s requirements.
    • Set up triggers to fire the tag based on specific user interactions or page views.

5. Preview and Test

  1. Preview Mode:
    • Use GTM’s Preview Mode to test tags and triggers before publishing changes.
    • Open your website and verify that tags fire correctly based on user interactions (e.g., page views, form submissions, clicks).

6. Publish Changes

  1. Publish Tags and Triggers:
    • After verifying everything works as expected in Preview Mode, click on “Submit” in GTM to publish your changes live.

7. Monitor and Maintain

  1. Regularly Monitor Data:
    • Use Google Analytics and other integrated tools to monitor data collected via GTM.
    • Adjust tags and triggers as needed based on new requirements or changes to your website.

Additional Tips

  • Document Your Setup: Keep documentation of tags, triggers, and variables used in GTM for future reference and team collaboration.
  • Stay Updated: Regularly check for updates and new features in GTM and integrated platforms to optimize tracking capabilities.

By following these steps, you can effectively set up Google Tag Manager for website tracking, enabling you to manage and deploy various tracking tags without the need for manual code updates on your website.