Don't have one? Create one ↗
← All courses

Lesson 14 of 16

Coupon Applied

① Connect your GTM container

Paste your container ID to load it into this page. It only ever runs here.

Advanced: use a specific environment

Coupons are how you connect revenue back to a campaign. When a shopper applies a discount, the page pushes apply_coupon with the code, so you can see which promotions actually get used and what they earn.

Here the code rides as a plain coupon key on the push rather than inside the ecommerce object. You build a Custom Event trigger and a GA4 Event tag that captures that code as an event parameter.

Goal

Fire a GA4 Event tag on apply_coupon and capture the coupon code as a parameter.

Build it in GTM

  1. Know what the page pushes

    Applying a code runs { event: "apply_coupon", coupon: "SPRING20" }. GTM sees an event named apply_coupon with the code on a top-level coupon key.
  2. Read the coupon into a variable

    Create a Data Layer Variable with Data Layer Variable Name coupon, so the applied code is available to your tag.
  3. Create the Custom Event trigger

    Triggers → New → Custom Event, event name apply_coupon. It must match the pushed string exactly.
  4. Fire a GA4 Event tag on it

    Build a GA4 Event tag named apply_coupon with an event parameter coupon set to your Data Layer Variable, and set the trigger above as its firing trigger. The course's Custom HTML - Test stand-in with <script></script> is an accepted placeholder.

Debug in Tag Assistant

Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.

  1. In your GTM, click Preview.
  2. Paste the live URL above and click Connect.
  3. Interact with the live page and watch your tag fire in Tag Assistant.

What you should expect to see

Apply a code. In Tag Assistant an apply_coupon event appears in the left rail, and your GA4 Event tag shows under Tags Fired with the coupon parameter carrying the code you entered.

Verify your container

Built it? Export your container, Admin → Export Container, choose your workspace, then drop the JSON here to check it against this lesson.

Drop your container .json here

or browse · checked in your browser, nothing is uploaded

0 of 16 lessons complete