Reputation: 3
I have following data layer deployed on confirmation page which captures the transactional data all correct. enter code here
<!-- Enhanced Ecommerce Data Layer through Google Tag Manager -->
<script>
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': rtCONFIRMATIONNUMBER_0,
'revenue': rtTOTALCOST,
'tax':rtTAX_0,
},
'products': [{
'name': rtPROPERTYNAME+'-'+rtROOMTYPE_0,
'id': rtCONFIRMATIONNUMBER_0,
'price': rtTOTALCOST,
'quantity': 1
}]
}
}
},{
'event': 'purchase'
});
</script>
<!-- END Enhanced Ecommerce Data Layer through Google Tag Manager -->
But this is not enough when user is adding some other add ons available at the time of checkout which I want to capture under the same transaction ID. How can I modify this to capture the added Items data?
Upvotes: 0
Views: 132
Reputation: 8907
First of all, there looks to be an error with your dataLayer.push
. Your event
key should be defined in the same object as your ecommerce
object if you are planning on firing tags with the purchase
event:
dataLayer.push({
'ecommerce': {
// ecommerce stuff
},
'event': 'purchase'
})
Back to your main question now, one option would be to add the other add-ons as separate products:
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': rtCONFIRMATIONNUMBER_0,
'revenue': rtTOTALCOST,
'tax': rtTAX_0,
},
'products': [{
'name': rtPROPERTYNAME + '-' + rtROOMTYPE_0,
'id': rtCONFIRMATIONNUMBER_0,
'price': rtTOTALCOST,
'quantity': 1
},
{
'name': rtPROPERTYNAME2 + '-' + rtROOMTYPE2_0,
'id': rtCONFIRMATIONNUMBER2_0,
'price': rtTOTALCOST2,
'quantity': 1,
'category': 'add-on'
},
// other product objects like add-ons
]
}
}
Upvotes: 0