E-Commerce Checkout Tracking mit Google Analytics
Um das Standard E-Commerce Tracking in Google Analytics einzurichten gibt es viele verschiedene Wege. Einen Standardweg möchte ich hier beschreiben:
E-Commerce mit gtag.js
Um generell das Tracking nutzen zu können, muss zuerst der Google Analytics Code eingebunden werden. Das sieht dann z.B. so aus:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXXX', { 'anonymize_ip': true });
</script>
Durch das initiale Laden dieses Skriptes wird Euch die Möglichkeit gegeben, die im Checkout an Google Analytics zu übergeben. Das sieht dann so aus:
<script>
gtag('event', 'purchase', {
"transaction_id": "24.031608523954162",
"affiliation": "Google online store",
"value": 23.07,
"currency": "EUR",
"tax": 1.24,
"shipping": 0,
"items": [
{
"id": "P12345",
"name": "Android Warhol T-Shirt",
"list_name": "Search Results",
"brand": "Google",
"category": "Apparel/T-Shirts",
"variant": "Black",
"list_position": 1,
"quantity": 2,
"price": '2.0'
},
{
"id": "P67890",
"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>
Gebt uns gerne Feedback, wenn das nicht (mehr) so funktionieren sollte.