Skip to content
FunnelGuard

Fix guide by FunnelsGuard

GA4 coupon parameter missing: how to find and fix it

TRK-094Low impactDetectedBy FunnelGuardPublished Updated
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.

What you lose when coupon is missing
  • 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.
Orders where the code shows up in GA4Example numbers
Orders where the code shows up in GA4 (example)Orders using a code (store): 100 orders; Coupon visible in GA4 (broken): 0 orders; Coupon visible in GA4 (fixed): 100 orders038771000100Orders using a code (…Coupon visible in GA4…Coupon visible in GA4…orders

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

Check the coupon parameter by hand
  1. 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).

  2. 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.

  3. Open the purchase event

    Click purchase in the stream and look for coupon in the parameters. Also check begin_checkout and add_to_cart if you want the code there too.

  4. Inspect the dataLayer

    In the browser console, type dataLayer and find the ecommerce push. Check that ecommerce.coupon has the code.

  5. Check the report

    In GA4 Admin > Custom definitions, register coupon as an event-scoped custom dimension if you want it in standard reports. Data only appears after registration and from that point on.

Where the coupon gets lost
  1. Code appliedShopper enters SPRING10
  2. Order placedTotal shows discount
  3. dataLayer pushNo coupon field set
  4. GA4 purchaseArrives without coupon
  5. 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.

GA4 purchase event with couponjavascript
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
      }
    ]
  }
});
Add the coupon by platform
  1. Expose the code in the dataLayer

    Make sure your site pushes ecommerce.coupon as 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.

  2. 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 named coupon with your variable.

  3. Preview and publish

    Use Preview mode, place a test order with a code, check the tag fired with coupon, then publish.

WooCommerce: push coupon codes on the order received pagephp
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
} );
Purchase event before and after

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

Confirmation checks
  • A test order with a code shows coupon in 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.
  • coupon is registered as a custom dimension if you want it in reports.

How to prevent it happening again

Keep coupon tracking working
  • 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.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: params rules.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.