Skip to content

Google Tag Manager

Google Tag Manager (GTM) is a powerful tool that allows you to manage and deploy marketing tags (such as tracking pixels, website analytics, and more) on your website or app without having to modify the code. This guide provides a step-by-step process to set up and configure GTM for your project.

Setup Guide

Follow these steps to set up Google Tag Manager:

  1. Login and Create a New Container

    • Go to Google Tag Manager and sign in with your Google account.
    • Create a new container by clicking on the “Create Account” button and following the prompts.
    • Select the appropriate container type (Web, iOS, Android, AMP) based on your project requirements.

  2. Retrieve the Container ID

    • After creating the container, you will see a screen displaying the GTM code snippet.
    • Copy the container ID, which is in the format GTM-XXXXXX.

  3. Configure Your Environment Variables

    • Open your project’s .env file.
    • Paste the container ID into the .env file as shown below:
    .env
    GOOGLE_GTM_ID=GTM-XXXXXX
    # Optionally, you can override the default domain for the GTM script:
    # GOOGLE_GTM_DOMAIN=https://www.your-custom-domain.com

Built-in Tag Events

Google Tag Manager supports a variety of built-in events that you can use to track user interactions on your site. Below is a list of commonly used events:

Event NameDescription
page_viewedTriggered when a page is viewed
search_viewedTriggered when a search is performed
product_added_to_cartTriggered when a product is added to the cart
product_removed_from_cartTriggered when a product is removed from the cart
cart_updatedTriggered when the cart is updated
collection_viewedTriggered when a collection page is viewed
product_viewedTriggered when a product page is viewed

Conclusion

With these steps, you should be able to integrate GTM into your project efficiently. For advanced configurations and custom event tracking, refer to the official GTM documentation.