Stripe Payment Link Conversion Tracking


💡 Tip — Get in touch for an easier, more advanced, simpler Stripe tracking system.


Video

From Reddit to a blog post

A year ago I answered a question on Reddit regarding how to track Stripe payment links with Google Tag Manager.

After doing a few of these setups last year, I thought I would write a little blog post about it.

Stripe Conversion Tracking

If you use Stripe payment links and plan on running ads on Facebook, Google Ads, or just want to track your traffic sources on Google Analytics, it's quite tricky!

However, conversion tracking is a non-negotiable.

You need conversion tracking to

  1. measure the ROI of each ad

  2. see which keywords are worth bidding on

  3. see which organic SEO strategies work

  4. learn which landing pages bring in traffic

  5. know which of your funnels have friction points where customers get stuck.

  6. As a safety net when your sales suddenly decrease by 80% to understand if it's due to a problem on your website, due to a competitor bidding on your target audience. A technical issue or something else. Without analytics it's like a doctor trying to cure a disease without lab results, not knowing which disease you're having.

Why tracking Stripe payment links conversions is difficult?

Stripe payment links are difficult to track because stripe.com is a different website than yours.

Because Stripe is on a different domain any tracking cookies are not shared. And we cannot add any code to Stripe because it's a closed system.

And at the moment Stripe does not offer any built-in conversion tracking system like many platforms do.

So, how do we track Stripe payment link conversions for Google Ads, Meta and Google Analytics?

Two methods – Simple and advanced

psst. Get in touch for a third one.

Step 1 - Both methods start with a redirect

Here I'll offer the basic steps for two different methods: a simple method and a more advanced method.

Both methods start off with a redirect after Stripe payment is successful back to your website to a thank you page and then adding the Stripe checkout session ID variable as a URL parameter.

https://example.com/thank-you?stripeID={CHECKOUT_SESSION_ID}
Stripe payment link conversion tracking screenshot confirmation page redirect with URL parameters.

The next step is going to be JavaScript in your website thank you page that will parse the URL and look for

checkout_session_id=

Then trigger the conversion if our URL contains this.

Next, we have a couple of options, Simple and Advanced.

Let's start off with the Simple option.

Simple Option

In the simple option we do not integrate with stripe API's in any way so it is simply a dumb script that checks if the URL contains this thing then we should trigger a conversion in Google tag manager for example and fire our tracking tags for Google Analytics, Google Ads, Meta, Pixel, TikTok etc.

<script>
function getQueryParam(param){const urlParams=new URLSearchParams(window.location.search);return urlParams.get(param);}var checkoutSessionId=getQueryParam('checkout_session_id');if(checkoutSessionId){console.log('Checkout Session ID:',checkoutSessionId);window.dataLayer=window.dataLayer||[];

window.dataLayer.push({event:'purchase',checkoutSessionId:checkoutSessionId});}</script>

This simple script in Google Tag Manager will trigger a custom event you can use to trigger conversion tags.

You can now fire a custom event in Google Tag Manager and fire your tracking scripts.

If you have different types of purchases, you could add an extra parameter and use some events instead of all custom events.

Stripe payment link, Google Tag Manager screenshot, custom event trigger purchase.

Simple+ with conversion currencies and values

Alright, let's upgrade the simple setup a little bit and track the conversion value.

This method works if you just have one or a couple of Stripe payment links and their prices don't change that often.

The basic idea is that you are just gonna add the value of the conversion and potentially a currency code into the URL. It's stupid, but it works.

https://example.com/thank-you?checkout_session_id={CHECKOUT_SESSION_ID}&value=100

Example JS snippet 👇


 // Function to get query parameter by name
function getQueryParam(param) {
    const urlParams = new URLSearchParams(window.location.search);
    return urlParams.get(param);
}

// Check if the URL contains 'checkout_session_id' and 'value'
var transactionId = getQueryParam('checkout_session_id');
var value = parseFloat(getQueryParam('value')); // Parse value as float

if (transactionId) {
    // Log the transaction ID and value to the console
    console.log('Transaction ID:', transactionId);
    console.log('Transaction Value:', value);

    // Fire a purchase data layer event
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
        event: 'purchase',
        ecommerce: {
            transaction_id: transactionId,
            currency: 'USD',
            value: value
        }
    });
}

Screenshot of Google Chrome with Stripe, Payment Link Conversion Tracking, URL, Parameters, Custom JavaScript, and Data Layer Purchase Event.

You can use the Stripe transaction ID which we easily get via the URL as the Google Ads transaction ID or Google Analytics eCommerce purchase event transaction ID and the Metapixel event ID.

âť—It's important to have a unique identifier because it's quite likely that people will refresh the thank you page, for example by accident, which would create duplicate conversions unless we have an ID that is constant for every Stripe payment.

Advanced version

For an advanced version, here is the logic. We again begin by having the redirect from Stripe to our website with the checkout session ID.

We then create a tiny app that works as an intermediary between our website and Stripe.

You can use AI tools to make this app. It could perhaps be a Cloudflare worker or a Make.com automation or N8n.com automation for example

Stripe Payment Link Advanced Conversion Tracking. Screenshot of Make.com, Webhook, Stripe API connector.

đź”— You can download a make.com Webhook-Stripe-Respond template here

We may need to ask an AI to provide security checks, e.g. possibly blocking other domains than your own from getting a response, and considering some sort of restriction — if someone just starts polling your webhook like crazy from the same IP. Cloudflare worker could work with more ease here.

Our website, the thank you page, will have a JavaScript that has a fetch that will ask our webhook for the information about this unique purchase.

The webhook will respond with all the information like the price and the taxes and discount codes and the email, maybe phone number — even full address.

Stripe payment link conversion tracking make.com/http request to Stripe API screenshot.

Here's a simple starting point for your thank you page JavaScript fetch function:


fetch('https://hook.eu1.make.com/jskt6huw3jkdk4kj4ym3xgunhi91', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        test: 'test',
        stripeSessionId: 'cs_test_b1QMp....'
    })
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));



This info can be used for more accurate conversion tracking including Google Ads Enhanced Conversion tracking, Meta Pixel Advanced Matching and Meta Conversions API

The benefit of the advanced method is that it's always gonna work regardless if you change your products, if you add new products, if you change your product names, you can track those, you can get the customer information, you can change the prices, even your currency can change. You can get the taxes, etc. (and you don't have to manually edit any Stripe Payment Link redirect URLs!).

It's like a real e-commerce tracking integration.

Security..?

Regarding the security here, I'm trying to think of any way someone could be able to do something nasty here. I haven't yet come up with any realistic threats. Having things in the URL for tracking as well as pushing the order values, currencies, etc. to data layer are very common.

Stripe Payment Link Conversion Tracking, Safety Consideration, Screenshot from Claude AI.

Here the intermediary app acts as a safe thing in between the public website and your Stripe. The API key should be restricted. Only thing I can think of would someone could in theory just start testing potential Stripe check out session ids however As they look like this.


cs_test_b1QMpfDgyYH4jYkqil7d2sS1vNOr1RCpiFkHbaJ0yaQDMCP2IGFgXFr31U

If someone just starts polling your webhook with

cs_test_1111111111111111111111111111111111111111111111111111111111
cs_test_1111111111111111111111111111111111111111111111111111111112
cs_test_1111111111111111111111111111111111111111111111111111111113

They are probably not gonna get very far.

However, I would love to have some security experts provide insight into any potential threats. With my experience this is following pretty standard conversion tracking principles.


Hope that was helpful!

I am now partnering up with companies who have even deeper experience in Stripe conversion tracking. So don't hesitate to get in touch whether it's help implementing these methods, a custom setup or something more advanced.

Need help with Stripe conversion tracking?

Get in touch for an easier, more advanced, simpler Stripe tracking system.

We probably have a million times better system already updated from what you see in this blog post here.

Previous
Previous

Why Conversion Tracking Makes Meta’s and Google’s AI Work for You (Instead of Against You)

Next
Next

Google Ads Cross-domain tracking —Google Tag Manager & Conversion Linker