On this page
What this issue is
GA4 ecommerce events can carry a coupon parameter. It holds the discount code the shopper used, for example SPRING10. You can set it on the event itself (the order-level code) and on each product in the items array (an item-level code).
The issue is when a code was applied in the store, the order total shows the discount, but the event sent to GA4 has no coupon value. Revenue still arrives. The code just doesn't.
Why it costs you leads or sales
This one is low impact. Nothing breaks for the customer and orders still get tracked. The cost is in decisions you make with incomplete data.
- You can't tell which codes (influencer, email, affiliate) produce orders.
- Discount-heavy orders look like full-price ones, so average order value reports mislead you.
- You can't compare coupon users with non-coupon users in Explorations.
- Influencer and partner payouts based on codes can't be checked against GA4.
- Audiences built on coupon use will be empty or wrong.
Example: 100 orders used a discount code. With the parameter missing, GA4 shows none of them by code. After the fix, it shows all of them.
How to check if your site has it
Place a test order with a code
Add a product, apply a real discount code at the cart or checkout and complete the order (use test mode or a code you can refund if needed).
Open GA4 DebugView
In GA4 go to Admin > DebugView. Turn on debug mode with Google Tag Assistant or the GA debug extension, then repeat the journey.
Open the purchase event
Click
purchasein the stream and look forcouponin the parameters. Also checkbegin_checkoutandadd_to_cartif you want the code there too.Inspect the dataLayer
In the browser console, type
dataLayerand find the ecommerce push. Check thatecommerce.couponhas the code.Check the report
In GA4 Admin > Custom definitions, register
couponas an event-scoped custom dimension if you want it in standard reports. Data only appears after registration and from that point on.
- Code appliedShopper enters SPRING10
- Order placedTotal shows discount
- dataLayer pushNo coupon field set
- GA4 purchaseArrives without coupon
- Coupon reportEmpty
The code is applied in the store, but the purchase event leaves without it.
How to fix it
The code must come from your order data and be passed into the ecommerce object. Which setting or file you edit depends on your platform and theme.
window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'T-10042',
value: 54.00,
currency: 'USD',
coupon: 'SPRING10',
items: [
{
item_id: 'SKU-1',
item_name: 'Canvas Tote',
price: 60.00,
quantity: 1,
coupon: 'SPRING10',
discount: 6.00
}
]
}
});Expose the code in the dataLayer
Make sure your site pushes
ecommerce.couponas in the snippet above. If your platform has the code in another variable, create a Data Layer Variable or a custom JavaScript variable that reads it.Map it in the GA4 event tag
Open your GA4 Event tag for
purchase. If it sends the Ecommerce data from the dataLayer, the coupon goes with it. If you set parameters by hand, add an event parameter namedcouponwith your variable.Preview and publish
Use Preview mode, place a test order with a code, check the tag fired with
coupon, then publish.
Find your tracking source
If you use the Google & YouTube app or a third-party tracking app, check its settings for coupon or discount code support. Support varies by app.
Or read the code from the order
On a custom pixel or checkout script, read the discount applications from the checkout object and pass the code into
coupon.Test with a code
Place a test order using a discount code and check DebugView.
Check your GA4 plugin
With WooCommerce, many GA4 plugins have an ecommerce setting. Confirm it is on and that the plugin version supports coupons.
Or add the code in your theme
On the order received page, read the order's used coupons with
$order->get_coupon_codes()and push them into the dataLayer.Test
Place a WooCommerce order with a coupon and check DebugView.
Read the code from your order model
Get the applied code on the server when rendering the confirmation page.
Output it in the push
Add
couponto the ecommerce object, as a string. For several codes, join them with a comma or send the main one.Escape the value
Encode it as JSON so quotes in a code can't break the script.
add_action( 'woocommerce_thankyou', function ( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! $order ) { return; }
$codes = $order->get_coupon_codes();
$coupon = $codes ? implode( ',', $codes ) : '';
?>
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: <?php echo wp_json_encode( (string) $order->get_order_number() ); ?>,
value: <?php echo wp_json_encode( (float) $order->get_total() ); ?>,
currency: <?php echo wp_json_encode( $order->get_currency() ); ?>,
coupon: <?php echo wp_json_encode( $coupon ); ?>
}
});
</script>
<?php
} );Before
- Order total shows a discount
- purchase has value and items but no coupon
- Coupon dimension is empty
After
- purchase includes coupon: SPRING10
- Item-level coupon and discount are set
- You can report revenue by code
How to confirm it's fixed
- A test order with a code shows
couponin the purchase event in DebugView. - The value matches the code you entered, with the same spelling and case.
- A test order without a code sends no coupon, or an empty one.
- The purchase fires once, with the same transaction_id as the order.
couponis registered as a custom dimension if you want it in reports.
How to prevent it happening again
- Add a coupon order to your release test plan for checkout or theme changes.
- Re-test after updating your tracking plugin, theme or checkout app.
- Document which variable holds the code so developers keep it when refactoring.
- Use one source for the code, not several that can disagree.
- Re-test when you add a new discount method, such as automatic discounts or gift cards.
How FunnelGuard handles this
FunnelGuard detects this today. It runs your checkout journey on a schedule as a robot visitor and checks the tracking hits sent to GA4. The check applies parameter rules: it looks at the purchase hit and flags when an expected parameter such as coupon is absent. It works when the journey applies a code, so set up a journey that uses one.
A failure is re-checked from a second region before one alert goes out, with a screenshot and a likely cause. FunnelGuard stops before payment unless the store's test mode is set up. The Free plan covers 1 site and 2 journeys with daily checks, and no card is needed.
Questions people ask
Why is my GA4 coupon parameter empty?
Usually the site never puts the discount code into the ecommerce object, so the purchase event leaves without it. Other causes are a tag that doesn't pass the field, a plugin that doesn't support coupons, or testing with an order that used no code. Check the dataLayer push first.
How do I send a coupon code to GA4?
Add coupon as a string to the ecommerce object of your events, for example in purchase. You can also add coupon and discount on each item in items. Then check it in DebugView.
Why is the coupon not showing in my GA4 reports?
The event may carry it, but the parameter isn't registered as a custom dimension. In Admin > Custom definitions, create an event-scoped dimension for coupon. It only fills from then on, not for past data.
Does a missing coupon parameter affect my revenue tracking?
No. Revenue, transaction_id and items still arrive. You only lose the ability to report by discount code.
Should I set coupon on the event or on each item?
Set it on the event for order-level codes. Set it on the item for codes that apply to one product. You can send both when they apply.
How do I test the GA4 coupon parameter?
Place a test order with a discount code, open Admin > DebugView, and click the purchase event. Look for coupon with the exact code. Also run an order without a code to see it left out.
Can I send more than one coupon code to GA4?
The coupon parameter is a single string. If several codes were used, join them in one string or send the main one, and keep the same rule across the site.
Related issues
- TRK-077purchase event missing on order confirmationFix guide
- TRK-078purchase sent without transaction_idFix guide
- TRK-082purchase value differs from order totalFix guide
- TRK-083items array missing from ecommerce eventsFix guide
- TRK-091ecommerce object not cleared in dataLayer (items leak into next event)Fix guide
- TRK-095Currency on items differs from event currencyFix guide