Reputation: 645
Is is possible to track multiple coupons for a single order/transaction in Google Analytics? According to the documentation, the key 'coupon' should be an text...
In our store, customers can fill in multiple coupons for a single order. All the coupons will apply on the complete order, not on products. For example: The coupon 'NOSHIPPING' can be used to get free delivery, but also coupons can be linked to customers to give them an extra discount. So the code 'MYDISCOUNT5PERCENTOFF' gives a selected client also 5 percent discount of the total order. So the order can be completed with 2 coupons!
In the examples on https://developers.google.com/tag-manager/enhanced-ecommerce#purchases only a single coupon is given...
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345', // Transaction ID. Required for purchases and refunds.
'affiliation': 'Online Store',
'revenue': '35.43', // Total transaction value (incl. tax and shipping)
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [ ... ]
}
}
});
Already tried some thing, but it's not possible to push the same object twice, but with different coupons, because the second push will overrule the first one...
It's not possible to push a second purchase after pageload / something like that. Already tried to seperate the coupons with comma's, 'coupon': 'NOSHIPPING,MYDISCOUNT5PERCENTOFF'
but that just gives a coupon with the name including the comma in Analytics, so seperate coupons can't be filtered...
Also tried to set an array instead of an text, like 'coupon': ['NOSHIPPING','MYDISCOUNT5PERCENTOFF']
, but that doesn't register any coupons at all...
Is there any way how to track multiple coupons in Analytics for a single transaction? And if not, please make this possible!
Upvotes: 2
Views: 3590
Reputation: 424
I know this is old, but this is how I track multiple coupons ...
The coupons are pushed to the dataLayer in an array. I create a variable for the coupon array, then I check if the array is set and if the array length is greater than zero, then convert the array to comma separated string.
function() {
if(typeof({{cartContent_totals_applied_coupons}}) !== 'undefined' && {{cartContent_totals_applied_coupons}}.length > 0) {
return {{cartContent_totals_applied_coupons}}.toString();
}
else {
return undefined;
}
}
Upvotes: 0
Reputation: 8907
You won't be able to apply multiple coupons to the same transaction, and you've come close to what I think may be the only solution, which is to concatenate the coupon names, but use something like a pipe (or something easy to distinguish) to delimit them. For example:
'coupon': 'NOSHIPPING|MYDISCOUNT5PERCENTOFF|ANOTHERCOUPON'
In your reports, you would just have to mindful of this concatenation. You could also set up a custom dimension(s) for additional coupon codes, but this would seem more wasteful of a CD, unless you are on A360 and have more than you know what to do with.
Upvotes: 2