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:
-
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.
-
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
.
-
Configure Your Environment Variables
- Open your project’s
.env
file. - Paste the container ID into the
.env
file as shown below:
- Open your project’s
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 Name | Description |
---|---|
page_viewed | Triggered when a page is viewed |
search_viewed | Triggered when a search is performed |
product_added_to_cart | Triggered when a product is added to the cart |
product_removed_from_cart | Triggered when a product is removed from the cart |
cart_updated | Triggered when the cart is updated |
collection_viewed | Triggered when a collection page is viewed |
product_viewed | Triggered 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.