- Issue created by @newaytech
- πΊπΈUnited States rszrama
Drupal Commerce has a coupon reference field on orders that stores which coupons have been applied to the order. It's not an exact match to Google's data model, which appears to expect a single coupon, but we can grab the first one and add it to the purchase event template in:
https://git.drupalcode.org/project/google_tag/-/blob/2.0.x/src/Plugin/Go...
Would be nice if one of the options I've tagged into the "Deprecate Commerce GTM" list could be used to give merchants the opportunity to alter which coupon code gets used in the event of there being more than one. We could always sort them by their relative promotion sort orders so there's at least a consistent default with some UI based influence.
- First commit to issue fork.
- Merge request !80Issue #3442913: Tracking Coupon codes from Commerce Promotions β (Open) created by kaszarobert
- Status changed to Needs review
7 months ago 12:52pm 24 April 2024 - πΈπ°Slovakia kaszarobert
I created a MR with simply adding the coupon code to the dataLayer.
- π¬π§United Kingdom newaytech
Thanks kaszarobert - can I add your commit into my composer.json - or do we need a .patch file for that?
- πΈπ°Slovakia kaszarobert
@newaytech usually you add patch files to composer.json because the feature branch used for MR could change in the meantime if further changes will be required by reviewers. A patch file will stay the same. I uploaded a static patch file with the same modifications as in MR.
- π¬π§United Kingdom newaytech
Thanks kaszarobert - I've applied your patch via composer.json - works a treat - and we're now tracking promo codes in GA4 via GTM - fantastic!