Google Tag Manager Events Not Displaying in Data Layer Upon Checkout
In some implementations of SuiteCommerce Advanced (SCA) 2018.2 – 2022.2 using Google Analytics 4 with the Google Tag Manager Commerce Extension, the data layer code may incorrectly track the following Google Analytics events:
-
Add To Wishlist
-
Add to Cart
-
Product Click
-
View Event Data
-
Product View
-
Transaction
To correct this problem, review the data layer structure of SCA version 2023.1 or later, compare it with your current version, and make modifications as required.
Note:
You need to modify the file, GoogleTagManager
, but the file extension and path varies depending on your version of SCA.
This task requires developer experience.
The following code is a sample of how the data sent to the data layer should look:
------------------
trackAddToWishlist
------------------
addToWishlistEventData = {
event: 'addToWishlist',
data: {
action: 'Add To Wishlist',
currencyCode: String,
sku: String,
id: String,
name: String,
price: Number,
category: 'Shopping - User Interaction',
item_category: String
},
ecommerce: {
items: [
{
action: 'Add To Wishlist',
currencyCode: String,
sku: String,
id: String,
name: String,
price: Number,
category: 'Shopping - User Interaction',
item_category: String
}
]
}
};
--------------
trackAddToCart
--------------
addToCartEventData = {
event: 'addToCart',
ecommerce: {
currencyCode: String,
add: {
products: [
{
sku: String,
id: String,
name: String,
price: Number,
variant: String,
category: String,
quantity: Number,
currency: String
}
]
}
}
};
-----------------
trackProductClick
-----------------
productClickEventData = {
event: 'productClick',
ecommerce: {
click: {
actionField: { list: String },
products: [
{
name: String,
price: Number,
sku: String,
id: String,
category: String,
position: Number,
currency: String
}
]
}
}
};
--------------------
trackPageviewForCart
--------------------
cartViewEventData = {
event: 'cartView',
data: {
page: String,
currencyCode: String,
total: String,
items: [{
sku: String,
id: String,
title: String,
price: Number,
quantity: Number,
image: String,
currency: String
}]
}
};
----------------
trackProductView
----------------
productViewEventData = {
event: 'productView',
ecommerce: {
detail: {
actionField: {
list: String
},
products: [
{
name: String,
sku: String,
id: String,
category: String,
variant: String,
price: Number,
currency: String,
item_list_name: String
}
]
}
},
page: String
};
----------------
trackTransaction
----------------
transactionEventData = {
event: 'transaction',
ecommerce: {
purchase: {
actionField: {
id: String,
affiliation: String,
revenue: Number,
currency: String,
subtotal: Number,
tax: Number,
shipping: Number,
coupon: [
String
]
},
products: [{
name: String,
sku: String,
id: String,
price: Number,
category: String,
variant: String,
quantity: Number,
currency: String
}]
}
}
};