Track Conversions & Optimize Ad Spend¶
If you run ads (Google, Meta, TikTok, and so on) to sell your app, you need a purchase conversion to fire when a customer completes checkout. That signal is what lets the ad platforms optimize for buyers and lets you measure ROAS (return on ad spend).
PyLocket gives you two ways to do this. Pick one.
Option 1 - Let PyLocket fire your Google Tag Manager (easiest)¶
Best if you sell through a PyLocket-brokered Payment Link or our API and your customers land on PyLocket's hosted thank-you page.
- In Google Tag Manager, create (or open) your container and copy its id. It
looks like
GTM-XXXXXXX. - In the PyLocket Portal, open your app, go to the Sales section, and paste your container id into Conversion tracking (Google Tag Manager). Save.
-
That is it. After each sale, PyLocket loads your container on the hosted thank-you page and pushes a
purchaseevent to yourdataLayer: -
In GTM, add a trigger on the Custom Event
purchaseand a tag (a Google Ads conversion or a GA4purchaseevent) that fires on it.
The event is deduplicated per purchase, so a customer refreshing or re-opening
the thank-you page will not double-count. transaction_id is a stable order
reference you can use in the ad platform to deduplicate as well.
Adding the purchase value (for ROAS)¶
The hosted thank-you page does not include the sale amount (you set your own price in Stripe). To optimize for value, either:
- Read the amount from your own Stripe account and pass it into the event (use Option 2 below, where you control the page), or
- Track value-less (count-based) conversions, which is enough for many campaigns.
Option 2 - Use your own thank-you page (full control)¶
Best if you want full control of the page, the exact conversion value, and your own pixels.
- Set your Stripe Payment Link's after-completion redirect to a thank-you page you host. Then either deliver the app yourself by calling our entitlement API, or link the buyer to PyLocket's secure download page. See the redirect URL and both options in Sell Your App with Stripe (Path C).
-
On your own page, install Google Tag Manager (or your ad pixels directly) and push the
purchaseevent with the value you already know from Stripe: -
Map that event to your Google Ads / GA4 conversion in GTM.
Important: never send the download session_id to an ad platform¶
The session_id on your delivery / download links is a credential that
grants access to the download. Do not put it in a conversion event, a URL you
share with an ad network, or any analytics payload. Use your own order reference
(or the order reference PyLocket provides) as the transaction_id instead.
Stripe and Google setup notes¶
Checkout happens on Stripe's hosted page, where your tags cannot run, so the conversion always fires on the success page you return to. A few things make attribution reliable:
- Exclude Stripe as a referral in GA4 so the sale is credited to the original
ad source, not to Stripe. In GA4: Admin -> Data Streams -> your stream ->
Configure tag settings -> List unwanted referrals, and add
checkout.stripe.comandjs.stripe.com. - Import the conversion into Google Ads. Create your purchase as a GA4 key event, then import it in Google Ads (Goals -> Conversions -> import from GA4), or fire a Google Ads conversion tag directly from the GTM trigger.
- Optional: Stripe can also report the Checkout funnel to GA4. See Stripe's conversion-funnel guide and your Stripe Checkout settings.
Where to find your success URL¶
Your app's success URL (what you paste into a Stripe Payment Link's
after-completion redirect) is shown in the Portal under your app's Sales
section. It already includes the {CHECKOUT_SESSION_ID} placeholder, which
Stripe substitutes at redirect time.