MystoreMystore is an ONDC network-connected ecosystem built in India for Indian sellers. Mystore is the first ONDC network participant to connect as a Buyer and Seller NP.  You can register as a seller on Mystore and upload your catalogue. You will have a dedicated Seller page (digi-catalog) along with a Unique QR Code for your page that you can market to your buyers. Your catalogue will also appear on the ONDC network through the Mystore Buyer App and other buyer apps catering to related product domains. Mystore provides a comprehensive seller dashboard to manage your products, orders, and payouts. Mystore also facilitates seamless online shopping across categories with its Mystore Buyer App.https://www.mystore.in/s/62ea2c599d1398fa16dbae0a/66defda954ce55002beebf8c/mystore-logo-480x480.png
9th Floor, Tower A, Spaze iTech Park, Sector 49122018Gurgaon DivisionIN
Mystore
9th Floor, Tower A, Spaze iTech Park, Sector 49Gurgaon Division, IN
+918010412412https://www.mystore.in/s/62ea2c599d1398fa16dbae0a/66defda954ce55002beebf8c/mystore-logo-480x480.png"[email protected]
Google Tag Manager (GTM)

Google Tag Manager (GTM)

Google Tag Manager (GTM)

Guide to Google Tag Manager (GTM)

For website owners seeking granular control over their analytics and marketing integrations, Google Tag Manager (GTM) is an indispensable free tool. It empowers you to manage and deploy website tracking codes (tags) without the need for constant code modifications, offering flexibility, efficiency, and deeper insights into user behavior. This guide will provide a comprehensive overview of GTM and demonstrate how to set up essential tracking components.  

What is Google Tag Manager (GTM)?

Think of GTM as a central management system for all the tracking snippets or "tags" you want to implement on your website. These tags can originate from various platforms, including Google Analytics, Google Ads, Facebook Pixel, and countless other marketing and analytics services. Instead of manually adding each code snippet to your website's HTML, you add the GTM container code once, and then manage all other tags through the user-friendly GTM interface.  

Why is GTM Essential for Website Tracking?

  • Simplified Tag Management: Easily add, edit, and remove tracking codes without requiring developer intervention or direct code changes. This saves time and reduces the risk of website errors.  
  • Centralized Control: Manage all your tracking scripts in one place, providing a clear overview of your website's data collection ecosystem.  
  • Faster Deployment: Implement new tracking requirements and marketing pixels quickly and efficiently, allowing you to respond swiftly to evolving business needs.  
  • Version Control: GTM keeps a history of your container configurations, allowing you to revert to previous versions if necessary.  
  • Built-in Testing and Debugging: GTM offers robust preview and debug modes to ensure your tags are firing correctly before you make them live.  
  • Enhanced Data Accuracy: By using the Data Layer, you can provide GTM with structured and reliable information about user interactions, leading to more accurate tracking.  
  • Integration with Numerous Platforms: GTM seamlessly integrates with a vast array of marketing and analytics tools, providing a unified approach to data collection.  

Core GTM Concepts You Need to Know

To effectively utilize GTM, it's crucial to understand these fundamental concepts:

  • Tags: These are snippets of code or pixels from third-party platforms (e.g., Google Analytics tracking code, Facebook Pixel event code). Tags are what actually send data to these platforms.  
  • Triggers: These are rules that define when and where a tag should fire on your website. Examples include a trigger that fires when a specific page loads, when a user clicks a button, or when a form is submitted.
  • Variables: These are named placeholders that hold values. These values can be used within tags and triggers. Variables can represent various pieces of information, such as page URLs, event categories, transaction amounts, or user IDs. GTM offers built-in variables, and you can also create User-Defined Variables to capture specific data points.
  • Data Layer: This is a JavaScript object on your website that acts as a temporary holding place for information about user interactions and events. Instead of tags directly scraping information from the DOM (Document Object Model), they can access structured and organized data from the Data Layer, leading to more reliable and maintainable tracking.  

Setting Up GTM: A Step-by-Step Guide

  1. Create a GTM Account:

    • Go to https://tagmanager.google.com/ and sign in with your Google account.
    • Click "Create Account."
    • Enter your account name (usually your business name).
    • Configure the container setup:
      • Container Name: Typically your website's domain name (e.g., example.com).  
      • Where to Use Container: Select "Web."
    • Click "Create" and agree to the Google Tag Manager Terms of Service.
  2. Install the GTM Container Code on Your Website:

    • After creating your container, GTM will provide you with two snippets of code.  
    • Snippet 1: This code needs to be placed as high in the <head> section of every page of your website as possible.  
    • Snippet 2: This code needs to be placed immediately after the opening <body> tag on every page of your website.
    • Important for Mystore Enterprise Users: If you are using the Mystore Enterprise plan with your own domain, you will typically have access to your website's theme files or a dedicated section in your Mystore admin dashboard where you can insert these code snippets. Consult your Mystore documentation or support for the specific instructions on adding custom code to your website's <head> and <body> sections.

Setting Up a Trigger, a Tag, and a Custom Variable from the Data Layer

Let's walk through a practical example of tracking a "Product Click" event using the Data Layer, a GTM Trigger, a Custom Variable, and a Google Analytics tag.

Scenario: You want to track when users click on a product listing on your website and send the product name to Google Analytics as an event.

1. Implement the Data Layer (Website Development):

When a user clicks on a product, your website's code needs to push information about that product into the Data Layer:

JavaScript
dataLayer.push({
  'event': 'productClick',
  'productName': 'Awesome T-Shirt',
  'productId': 'TSH-123'
});

2. Create a Data Layer Variable in GTM:

To access the productName from the Data Layer, create a User-Defined Variable in GTM:

  • Variable Name: dlv - productName
    • Variable Type: Data Layer Variable
    • Data Layer Variable Name: productName
    • Version: Version 2

3. Create a Trigger in GTM:

Create a Custom Event trigger that fires when the productClick event occurs in the Data Layer:

  • Trigger Name: dl - Product Click
    • Trigger Type: Custom Event
    • Event name: productClick
    • This trigger fires on: All Custom Events

4. Create a Google Analytics Tag in GTM:

Now, create a Google Analytics tag to send the "Product Click" event to your GA property:

  • Tag Name: GA - Event - Product Click
    • Tag Type: Google Analytics: Universal Analytics (or Google Analytics: GA4 if you are using GA4)
    • Track Type: Event
    • Category: Product Interactions
    • Action: Click
    • Label:NaN (Select the Data Layer Variable you created)  
    • Google Analytics Settings: Select your existing Google Analytics Settings Variable (or create a new one with your Tracking ID).
    • Triggering: Choose the trigger you created: dl - Product Click.

Explanation:

  • When a user clicks a product, the website pushes the productClick event and the productName into the Data Layer.
  • The dl - Product Click trigger listens for this specific productClick event.
  • When the trigger fires, the GA - Event - Product Click tag sends an event to Google Analytics.
  • The Event Category is set to "Product Interactions," the Action is "Click," and the Label dynamically pulls the productName from the Data Layer using the dlv - productName variable.

Best Practices for GTM Implementation

  • Plan Your Tracking: Before implementing any tags, define your tracking goals and create a comprehensive tracking plan.  
  • Utilize the Data Layer: Prioritize using the Data Layer for structured and reliable data collection.
  • Test Thoroughly: Always use GTM's Preview and Debug mode to verify that your tags and triggers are working as expected before publishing.  
  • Maintain Organization: Use clear and consistent naming conventions for your tags, triggers, and variables. Utilize folders to group related items.  
  • Implement Version Control: Regularly review and understand the changes you are making to your GTM container.
  • Stay Updated: Keep your GTM container code updated and be aware of new features and best practices.

Conclusion

Google Tag Manager is a powerful tool that provides website owners with unprecedented control over their tracking and analytics. By understanding its core concepts and leveraging the Data Layer, you can implement sophisticated tracking solutions without extensive coding knowledge. For Mystore Enterprise users with their own domains, GTM is a key enabler for gaining deep insights into customer behavior, optimizing marketing efforts, and making data-driven decisions to fuel online growth. Embrace GTM and unlock the full potential of your website data.