feat(tracking): push Google Ads conversion data to dataLayer on purchase#28
Merged
Merged
Conversation
Wire `value`, `currency`, and `transaction_id` from Stripe Checkout Session
into the `purchase` dataLayer event so GTM can fire Google Ads Conversion
Tracking with accurate per-plan revenue and deduped transaction IDs.
- `BillingController::checkout` adds `{CHECKOUT_SESSION_ID}` to success_url
- `BillingController::processing` retrieves session lazily (closure prop,
so polling partial reloads don't re-hit Stripe) and exposes
`conversion` with `value`/`currency`/`transaction_id`
- `Processing.vue` forwards `conversion` to `trackPurchase`
- `useTracking.trackPurchase` pushes `conversion_value`,
`conversion_currency`, `conversion_transaction_id` to dataLayer +
PostHog
…er crashes `$account->stripe()` can throw `\Stripe\Exception\InvalidArgumentException` (descends from PHP's `InvalidArgumentException`, not `ApiErrorException`) when the Stripe key is missing/malformed. Since the conversion data is purely for tracking, any failure must degrade silently — not break the post-payment success page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
value,currency,transaction_id) into thepurchasedataLayer event so GTM can fire Google Ads Conversion Tracking (AW-18156274196/Dl3oCNKAvKscEJSEy9FD) with accurate per-plan revenue and deduped transaction IDs.BillingController::checkoutnow appends{CHECKOUT_SESSION_ID}to the Stripesuccess_url.BillingController::processinglazily retrieves the Checkout Session (closure prop — polling partial reloads don't re-hit the Stripe API) and exposes aconversionprop withvalue/currency/transaction_id. Usesdata_getwith dot notation + type guards so Stripe shape changes degrade tonullinstead of crashing.Processing.vueforwardsconversiontotrackPurchase.useTracking.trackPurchasepushesconversion_value,conversion_currency,conversion_transaction_idto dataLayer + PostHog.GTM setup (manual, after merge)
conversion_value,conversion_currency,conversion_transaction_id.18156274196(digits only, noAW-prefix)Dl3oCNKAvKscEJSEy9FD{{conversion_value}}{{conversion_transaction_id}}{{conversion_currency}}purchase.Test plan
php artisan test --compact --filter=BillingControllerTest— 20 passedpurchaseevent in GTM Preview with populatedconversion_*fieldstransaction_id)/billing/processingdon't trigger duplicate Stripe API calls