Coupons
Send the discount codes visitors try: the ones that work, and the ones your site refuses. Recordings show each in the timeline, with what it took off or why it was refused, and the session list counts refusals, so you can find the visitors whose code didn't work.
// Where your site checks a discount code:
window.peekbird = window.peekbird || [];
// A code that worked, and what it took off:
peekbird.push(['track', 'coupon_applied', { code: 'SPRING10', discount: 5.00 }]);
// One that was refused: why, and what the visitor was told.
peekbird.push(['track', 'coupon_failed', {
code: 'SUMMER25',
reason: 'expired',
message: 'This code has expired'
}]);// In your theme's JavaScript, where the cart checks a discount code:
window.peekbird = window.peekbird || [];
// A code that worked, and what it took off:
peekbird.push(['track', 'coupon_applied', { code: 'SPRING10', discount: 5.00 }]);
// One that was refused: why, and what the visitor was told.
peekbird.push(['track', 'coupon_failed', {
code: 'SUMMER25',
reason: 'expired',
message: 'This code has expired'
}]);// In your theme's JavaScript, where a discount code is checked:
window.peekbird = window.peekbird || [];
// A code that worked, and what it took off:
peekbird.push(['track', 'coupon_applied', { code: 'SPRING10', discount: 5.00 }]);
// One that was refused: why, and what the visitor was told.
peekbird.push(['track', 'coupon_failed', {
code: 'SUMMER25',
reason: 'expired',
message: 'This code has expired'
}]);<script>
window.peekbird = window.peekbird || [];
peekbird.push(['track', 'coupon_failed', {
code: {{DLV - coupon}},
reason: {{DLV - coupon_error}}
}]);
</script>The events
coupon_applied: a code worked. The timeline shows the code and what it took off.coupon_failed: a code was refused. The session list counts them; the timeline shows the code and why.
The fields
code- The discount code the visitor entered.
discount- coupon_applied: what it took off, as a number (5.00), in the currency of the cart.
reason- coupon_failed: why, in a word you choose: expired, invalid, minimum_not_met.
message- coupon_failed: what the visitor was told, word for word. The timeline shows it (or the reason, without one).
Good to know
- Send one each time the visitor applies a code, not while they type it.
- To also keep the code with the order, add it to the purchase:
coupon: 'SPRING10'. - They're events like any other: filter sessions by them, or create a custom event goal named
coupon_appliedto count coupon use per variation.