Need custom JavaScript to get total sum of price multiply by quantity from an item array of data layer - google-tag-manager

Current GTM data layer doesn't show checkout total value, I need to get this from the items array of the data layer.
`event: "checkout",
gtm: {uniqueEventId: 243, start: 1675793207075},
ecommerce: {
checkout: {
actionField: {step: 2},
products: [
{
id: "80509",
name: "Delightly: Inner Peace Kit",
category: "Delightly Quick Ship Kits",
variant: "80509",
price: 109.95,
quantity: 1
},
{
id: "80396",
name: "Delite by Delightly: Just Breathe Kit",
category: "Delite by Delightly",
variant: "80396",
price: 44.95,
quantity: 1`
I need total sum of the price multiply by the quantity from the array

Related

Why do I have two different product ids on the same product in my data Layer?

I have a problem with product ids values on my data layer. When I checked Purchase data layer I could see ecommerce data layer section that looks like bellow:
ecommerce: {
currencyCode: "EUR",
purchase: {
actionField: {
id: "394299",
affiliation: "",
revenue: 0,
tax: 0,
shipping: 0,
coupon: "test999"
},
products: [
{
id: 296,
name: "Test Name",
sku: "STR99",
category: "Housewarming",
price: 0,
stocklevel: null,
quantity: 1
},
{
id: 393,
name: "Test Name2",
sku: "MN61",
category: "Wedding",
price: 0,
stocklevel: null,
quantity: 1
}
]
}
}
}
So I see that Test Name's ID equal to 296 and Test Name2 id equal to 393. But when I am on a product page for example on Test Name product page in data Layer I see that value of ecomm_prodid key equals to 484.
I compare it to ID that I could find in Woocomerce admin panel and it looks like the ID from ecomm_prodid key is valid. So the question is why am I seeing different value in Purchase data layer. And on Purchase I don't have valid one and unvalid. I only have one that i unvalid. Data Layer is implemented by wordpress plugins.

Custom metric/dimension not visible in GA4 DebugView on item/product-list level

We're trying to configure GA4 to gather same data that we have in UA.
The problem is that we cant see custom metrics data on item-level in DebugView.
In TagAssistant we can see that data is sent:
{
event: "purchase",
gtm: {uniqueEventId: 10, start: 1651XXX},
gtag: {
targets: {
G-XXX: {_ee: true, _uei: 3, _upi: 2},
UA-XXX: {
currency: "PLN",
country: "PL",
custom_map: {
dimension2: "referrer",
...
dimension13: "ecomm_totalvalue",
metric1: "metric1",
...
metric5: "metric5"
},
_uei: 4
},
AW-106XXX: {}
}
},
eventModel: {
transaction_id: "40XXX",
affiliation: "XXX",
value: "9.99",
currency: "PLN",
tax: "1.87",
shipping: "0",
coupon: "",
items: [
{
id: "670",
name: "Tusz Zamiennik T0711 do Epson (C13T07114010) (Czarny)",
brand: "XXX",
category: "Wkłady/Atramentowe/Zamienniki/Tusze/XXX -> Do:E" +
"pson",
quantity: 1,
price: "9.99",
coupon: "",
metric1: "9.99",
metric2: "9.99",
metric3: "9.99",
metric4: "9.99",
metric5: "9.99"
}
],
send_to: ""
}
}
However, on DebugView side we can see purchase event that:
contains all orginal parameters on event level (like transaction_id, shipping etc.)
contains all orginal parameters on item level (like item_id, quantity, etc.)
But our custom metrics are missing
In the other hand, we tried (with different event) push some custom-dumension data and:
they are visible on GA4 DebugView
we can create custom dimension in GA4 basing on this data and it works
I am thinking about:
Creating event-level custom metric to test if it will be passed to GA4 DebugView
Creating item-level custom dimension to test if it will be passed to GA4 DebugView
However, due to fact that GA requires 24h to make conclusions i decided to ask here for any sugestions why it is not working and what else may i test.

GA4 tracks value of purchase but doesn't add up to Total Revenue

As you can see GA4 clearly doesn't show revenue:
However, when I go to Configure-> Conversions I can clearly see that it does track the value:
Our data layer looks as followed:
{
event: "purchase",
gtm: {uniqueEventId: 7, start: 1541254301557},
ecommerce: {
transaction_id: "TEST000000184",
affiliation: "Brand Name B2C - Brand Name B2C website - Brand Name English",
value: "36.0000",
coupon: "",
tax: "4.5100",
shipping: "10.0000",
items: [
{
item_name: "Plate 27cm green",
item_id: "10000",
item_price: "5.37",
item_brand: "Brand Name",
item_category: "",
quantity: "4.0000"
}
]
}
Currency is a required parameter in your ecommerce object.
currency: "USD",
Also, you should keep your quantity as integers not floats
quantity: "4" not quantity: "4.0000"

Google Analytics not displaying Category

After much pain and weeping and gnashing of teeth, I finally managed to get my website to talk to GTM and GTM to send data to Analytics.
I can see revenue and conversion rates and transaction results in Analytics, but not the product category.
I have my GTM tag set to use the Transaction track type along with the data layer.
My test code is:
dataLayer.push({
'transactionId': 'OnClickTransactionDataLayerPushID', // Transaction ID - Type:String - Required
'transactionAffiliation': 'OnClickTransactionDataLayerPushAffiliation', // store name - Type:String - Optional to use
'transactionTotal': 45, //total revenue - Type:Numeric - Required
'transactionTax': 5, // Tax amount for transaction - Type:Numeric - Optional to use
'transactionShipping': 5, // Shipping cost - Type:Numeric - Optional to use
'transactionProducts': [{
'sku': 'SKU456789', // Product SKU - Type:String - Required
'name': 'OnClickTransactionDataLayerPushName', // Product Name - Type:String - Required
'category': 'OnClickTransactionDataLayerPushNameCategory', // Product Category - Type:String - Optional to use
'price': 35, // Product Price - Type:Numeric - Required
'quantity': 1 // Product Quantity - Type:Numeric - Required
}]
});
In the GA Debugger I can see that the category is being sent as: ec:item variation (&iv) OnClickTransactionDataLayerPushNameCategory
The only problem is that this isn't a true variation. A variation would be something like color or size, not whether an item belongs to a t-shirt category or whatever. In any event, if this information is being sent over, why can't I see it in Analytics?
EDIT
After trying the Enhanced ECommerce code again as below, I see that the product names are hitting the top products list, but no monetary amounts or quantities are displayed. I can see that being sent in the GA debugger though?
dataLayer.push({
"event": "addToCart",
"ecommerce": {
"currencyCode": "USD",
"add": {
"products": [{
"id": "b55da",
"name": "Flexigen T-Shirt",
"price": "16.00",
"brand": "Flexigen",
"category": "T-Shirts",
"variant": "red",
"dimension1": "M",
"position": 0,
"quantity": 1
}]
}
}
});
Your code is standard e-commerce and the report says enhance e-commerce.
Standard
https://support.google.com/tagmanager/answer/6107169?hl=en
Enhance
https://developers.google.com/tag-manager/enhanced-ecommerce
Disable the enhance e-commerce in you view configuration, tab e-commerce and try to look again.

Sylius faceted search

i have sylius 0.15 based webshop and search integrated. I'm trying to make a faceted search depending on selected categories(taxons). For example if i have washing machines, dishwashing machines, shavers, irons and stuff like that every one of them has different attributes. How ca i do faceted search based on selected taxons.
So, i would like when i click on washing machines with attributes( rpm, volume etc.) that filters related to washing machines attributes appear but when i click lets say dishwashers i'd like to display filters with attributes related to dishwashers.
I have this by now and it works but not in described way. It displays only brands and price regarding category(taxon).
sylius_search:
search_form_template: 'SyliusSearchBundle::search_form.html.twig'
engine: elasticsearch
classes:
search:
controller: Acme\Bundle\SearchBundle\Controller\SearchController
repository: Acme\Bundle\SearchBundle\Doctrine\ORM\SearchIndexRepository
filters:
pre_search_filter:
enabled: true
taxonomy: KATEGORIJE
facet_groups:
search_set:
values: [categories, brands, memorija, price, operativni_sustav]
categories_set:
values: [brands, memorija, price, operativni_sustav]
# all_set:
# values: [categories, brands, memorija, price, operativni_sustav]
facets:
categories:
display_name: 'Kategorija'
type: terms
value: ~
brands:
display_name: 'Proizvođač'
type: terms
value: ~
price:
display_name: 'Raspon cijena'
type: range
values:
- { from: 0, to: 50000}
- { from: 50001, to: 200000}
- { from: 200001, to: 5000000}
made_of:
display_name: 'Material'
type: terms
value: ~
color:
display_name: 'Available colors'
type: terms
value: ~
operativni_sustav:
display_name: 'Operativni sustav'
type: terms
value: ~
memorija:
display_name: 'Memorija'
type: terms
value: ~

Resources