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
Know what the page pushes
Applying a code runs{ event: "apply_coupon", coupon: "SPRING20" }. GTM sees an event namedapply_couponwith the code on a top-levelcouponkey.Read the coupon into a variable
Create a Data Layer Variable with Data Layer Variable Namecoupon, so the applied code is available to your tag.Create the Custom Event trigger
Triggers → New → Custom Event, event nameapply_coupon. It must match the pushed string exactly.Fire a GA4 Event tag on it
Build a GA4 Event tag namedapply_couponwith an event parametercouponset to your Data Layer Variable, and set the trigger above as its firing trigger. The course'sCustom HTML - Teststand-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.
- In your GTM, click Preview.
- Paste the live URL above and click Connect.
- Interact with the live page and watch your tag fire in Tag Assistant.
What you should expect to see
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