Reputation: 4777
I'm succesfully tracking some events with gtag.js on Google Analytics, with the exception of "purchase" event. Using GTM/GA chrome plugin I've checked that all events are tracked correctly, "purchase" included. The problem is that "purchase" is not tracked on Google Analytics: all the others are tracked ("begin_checkout", "add_to_cart" ...).
gtag("event", "purchase", {
affiliation: "Google online store",
coupon: "SUMMER_DISCOUNT",
currency: "USD",
shipping: 5.55,
tax: 3.33,
transaction_id: "T_1",
value: 28.86,
items: [
{
id: "P12345",
name: "Android Warhol T-Shirt",
coupon: "P12345_coupon",
list_name: "Search Results",
brand: "Google",
category: "Apparel/T-Shirts",
variant: "Black",
list_position: 3,
quantity: 1,
price: 9.99
},
{
id: "P12346",
name: "Flame challenge TShirt",
coupon: "P12346_coupon",
list_name: "Search Results",
brand: "MyBrand",
category: "Apparel/T-Shirts",
variant: "Red",
list_position: 5,
quantity: 1,
price: 9.99
}
]
});
The conversion/e-commerce graph is flat as you can see. What am I missing?
Update I've created a GAnalytics test account and the purchase event is tracked. On the screenshot's account, maybe, some configuration is missing: could be?
Upvotes: 8
Views: 7958
Reputation: 11
Just found that:
"transaction_id": "-1",
will also be hard ignored by GA4, even in debug_mode. So if you're testing, developing or debugging it will get picked up if you insert "TEST" (or anything else for that matter) before it.
gtag("event", "purchase", { debug_mode: true,
transaction_id: "TEST-1",
...
Upvotes: 1
Reputation: 27
For Item Data:
, id should be the transaction ID.
See here:
https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#item
Upvotes: -2
Reputation: 112
I had the exact same problem. Some things I noticed that could explain ut.
Date Range: Maybe you missed the fact that the date range in your Analytics report is set for 26 Oct - 1 Nov, while your events were triggered on 2 Nov?
Wrong Value Field: If the calculation of the value field is wrong (does not equal total of all items plus shipping field plus tax field) Google might ignore the event.
Processing Time: Even when the "Real-Time" view shows the events, they are not always included in other reports until some time later.
Upvotes: 3
Reputation: 351
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-Y"></script>
<script nonce="djRFUUKP+SLF1k4qkKFqiLTO4Qo=">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-XXXXXX-Y');
</script>
<script nonce="djRFUUKP+SLF1k4qkKFqiLTO4Qo=">
gtag('event', 'purchase', {
"transaction_id": "24.031608523954162_C",
"affiliation": "Google online store_C",
"value": 0.01,
"currency": "GBP",
"tax": 1.24,
"shipping": 0,
"items": [
{
"id": "P12345C",
"name": "Android Warhol T-Shirt",
"list_name": "Search Results",
"brand": "Google",
"category": "Apparel/T-Shirts",
"variant": "Black",
"list_position": 1,
"quantity": 2,
"price": '0.01'
},
{
"id": "P67890C",
"name": "Flame challenge TShirt",
"list_name": "Search Results",
"brand": "MyBrand",
"category": "Apparel/T-Shirts",
"variant": "Red",
"list_position": 2,
"quantity": 1,
"price": '3.0'
}
]
});
</script>
We use nonce because we are using CSP and believe all CSP urls are set correctly in the CSP.
Any insight would be a great help as to why this would not be logging this transaction data.
Upvotes: 2