Google Tag Manager for beginners — Understanding Google Tag Manager Part 2

Deepak Garg
5 min readJan 3, 2022

I started with Google Tag Manager for Beginners course on CXL, and my tutor is Chris Mercer from measurementmarketing.io.

During the week, we covered all about the Data Layer and how dataLayer store the data and read the data. THat also includes the Ecommerce tracking and storing different variables in Data Layers.

In computing terms, variables denote compartments in computer memory, which are reserved for storing values. This is a significant achievement in efficiency, because it means that values can be reused across functions, procedures, and environments. The alternative would be to treat each representation of the same value as unique, temporary, and disposable, creating a mass of redundancy and inefficiency, and making the current computing landscape a whole lot different.

In Google Tag Manager, the term variable is used to denote a helper function that your tags, triggers, and other variables can invoke to retrieve values from. Thus, the idea is very similar to the broader concept of computing variables explored in the previous paragraph.

In GTM, invoking the variable function is done with a specific syntax:

{{variable name}}

#dataLayer Storing Details:

During the Lesson, we discussed how to store details in dataLayer and how GTM build data Layer with each tag.

With each tag, dataLayer get changed and each event creates it’s own dataLayer with different elements associated with it. That may include Click Element, Click URL, ELement Id, ELement Class and much more.

The data layer is really just a virtual filing cabinet on the browser.It’s something where the information is temporarily stored for the session so that you can store information about the user’s journey as the user is actually going through the site.That’s what the data is for.It’s used to place and to store information.And it has two key points.Number one is the what they call the key and then there’s the value.It’s actually called the key value pairs for that reason.So there’s the key, which is sort of just the variable name here and then there’s the value of that key.So key value pairs is how this is put together.

The Correct format of DataLayer is window.dataLayer.pushand then you put in the key value pairs that you want stored in the data layer.

We discussed creating a Custom DataLayer to push different events and dataLayer. We also covered . Customizing the Message Event and creating a custom Event using dataLayer. This is really important to do a custom event as that will help with the tracking and make it easily understandable on what we are tracking.

The next part of the lesson includes debugging dataLayer codes. Whenever there is an error in custom dataLayer code, GTM will give a pro tip to fix the issue before we preview it which is really helpful in identifying the issue and fixing the issue. Some common errors include:

  • Key Value pair doesn’t have a comma
  • Key Values doesn’t have brackets or braces

Resource: https://developers.google.com/tag-platform/tag-manager/web/datalayer

#DataLayer Reading Details

During the Lesson we discussed Data Layer variables and different tools to test out things. We uncovered how to create custom data layer variable to store the data in Analytics. Setting up data layer key as custom data layer variable and send the event information to

Then we discussed about “The Inspector” Tool and how to review the data using the tool. This tool will help in understanding the data layer and how different events or tags get fired and what values they push through the data layer. This is really great tool for someone using GTM and wanted to review the data layer data with each event.

Resources:

DataLayer Inspect Tool: https://adswerve.com/blog/google-tag-manager-datalayer-inspector/

Google’s Developer Guide: https://developers.google.com/tag-platform/tag-manager/web/datalayer

Tracking Ecommerce Basics

During the lesson we discussed the basic structure of Data Layer push for ecommerce tracking and the attributes required for ecommerce tracking. We also discussed the difference between standard and enhanced ecommerce tracking. Stand ecommerce is just the purchase information and a sort of details of what was purchased, however enhanced ecommerce provides additional details along with the purchase.

We did a test transaction on the wordpress site, and should be able to grab the Ecommerce information that needed and send that information into the Data Layer and ultimately send it on to the platform that’s going to record it. Here are some of the attributes/variable required as per Google’s documentation

Transaction Data

Variable Name

Description

Type

transactionId (Required)

Unique transaction identifier

string

transactionAffiliation (Optional)

Partner or store

string

transactionTotal (Required)

Total value of the transaction

numeric

transactionShipping (Optional)

Shipping charge for the transaction

numeric

transactionTax (Optional)

Tax amount for the transaction

numeric

transactionProducts (Optional)

List of items purchased in the transaction

array of product objects

Product Data

Variable Name

Description

Type

name (Required)

Product name

string

sku (Required)

Product SKU

string

category (Optional)

Product category

string

price (Required)

Unit price

numeric

quantity (Required)

Number of items

numeric

As per the Google’s Guide:

Standard reports

The following standard reports are available. Additional reports are available as part of Enhanced Ecommerce.

  • Overview: Summary of Revenue, Ecommerce Conversion Rate, Transactions, Average Order Value and other metrics.
  • Product Performance: Revenue, Purchases, Quantity, Average Price, and Average QTY by SKU and Category.
  • Sales Performance: Revenue by Date.
  • Transactions: Revenue, Tax, Shipping, and Quantity by Transaction ID.
  • Time to Purchase: Days to Transaction and Sessions to Transaction.

Based on this data, you can develop an understanding of:

  • Which products sell well, and by inference, which products are best suited for your customer base and which are supported by your best marketing efforts.
  • The revenue per transaction, and the number of products per transaction. For example, if the number of products per transaction is lower than you’d like, you might benefit from offering better quantity discounts, or eliminating shipping costs if customers meet a minimum dollar amount.
  • How long (in time and in number of sessions) it takes customers to make the decision to purchase. If your sales cycle is stable, or fluctuates predictably based on product or season, you can use this information (in conjunction with overall sales forecasts) to make reliable predictions about revenue. If customers routinely make numerous visits before they purchase, you might think about a site design that leads more easily to your purchase pages, or options that let users compare your products and prices to your competitors’.

Lesson Resources:

During the Next chapter of the course, we are going to discuss Cross-Domain Tracking and in which scenarios we need cross domain tracking.

--

--