-
Dumb Question about GA4 Ecommerce Tracking: Dynamic Content
Hi all,
I have a really dumb question here. Up until now, I’ve been using the GA tag to track ecommerce data and I simply migrated the existing code when GA4 came out. I’ve since added the data layer and tried to start tracking purchases.
So here’s my dumb question. The vast majority of samples I’ve seen from Google and people on YouTube include absolute values, such as ‘Stan and Friends Tee’ for the product name and ‘7.77’ for the value. That’s all well and good, but what if you want to dynamically populate the field based on the value across multiple pages? It wouldn’t work if you sell hats AND t-shirts because it would spit out t-shirts in the reporting when you’re trying to tell Google that you sold a hat and you want to record it with a unique SKU. It would have to be dynamic, right?
Example code:
dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.
dataLayer.push({
event: “purchase”,
ecommerce: {
transaction_id: {{transactionId}},
value: {{itemValue}},
tax: {{itemTax}},
shipping: {{itemShipping}},
currency: “USD”,
items: [
{
item_id: {{itemSku}},
item_name: {{itemName}},
index: 0,
price: {{itemPrice}},
quantity: {{itemQuantity}}
}]
}
});You get the gist. So, why do I always see absolute values in these fields in these examples when they should be dynamic and populated based on the element’s value? Is there a best practice for this?
Appreciate anyone’s help here!
Log in to reply.