Stripe Integration

Track affiliate sales that come through your Stripe account

Shakima avatar
Written by Shakima
Updated over a week ago

Once you’ve integrated Refersion with Stripe, you’ll be able to seamlessly track recurring subscription revenue generated by your affiliate network within Refersion.

Before you get started, it’s important to note that this integration requires some technical know-how, and if you are unsure of any of the steps we suggest you consult with your web developer.

NOTE: Refersion's integration with Stripe is only set up to track recurring subscriptions (not one-time charges). This is because we're only listening for and processing the invoice.payment_succeeded webhook topic from Stripe. One-time charges often create other webhooks we're not accounting for such as payment_intent.succeeded or charge.succeeded.

Also, your store must be directly integrated with Stripe either by using Stripe's hosted checkout or building your own checkout. Ways to integrate include integrating Stripe's billing products into your website directly, or using Stripe’s Subscriptions API/API Libraries.

Step 1 ‐ Install Refersion's Tracking Script

To track when a customer visits your site from clicking an affiliate’s link, you’ll need to add Refersion’s tracking scripts to your site. The tracking script should be installed on all pages a customer can land on and is typically installed in the header or <head> section of your site.

The necessary code snippet is below, but you’ll first need to replace YOUR-PUBLIC-KEY within the snippet with the Public Key from your Refersion account. You can locate your public key by following these instructions.

Make a note of your public key since you’ll need it again in step 3.

! function(e, n, t, i, o, c, s, a) {
e.TrackingSystemObject = "r", (s = n.createElement(t)).async = 1, s.src = "", s.onload = function() {
r.pubKey = "YOUR-PUBLIC-KEY", r.settings.fp_off = !1;
r.initializeXDLS().then(() => {
}, (a = n.getElementsByTagName(t)[0]).parentNode.insertBefore(s, a)
}(window, document, "script");

Step 2 - Connecting your Refersion account to Stripe

Next, you’ll need to connect your Stripe account to Refersion so we can track your subscription orders. Once connected, anytime a customer is billed successfully for a recurring subscription (whether it’s the first charge or any subsequent charge), we’ll receive the transaction data via a webhook from Stripe.

Note: Our integration will only listen for invoice.payment_succeeded events indicating payment for the subscription was successful.

If you have just signed up for Refersion, choose Stripe from the Start Guide. If you've already signed up, go to Account > Settings > Tracking, click + Add Tracking and choose Stripe from there.

Enter your shop's URL (including the http/https), check the installation box, and click Connect with Stripe.

Click Sign in with Stripe to connect and follow the instructions.

Step 3 ‐ Tracking Conversions

In order to create conversions in Refersion, you’ll need to send us the customer’s ID after the customer is created in Stripe. In order to do this you’ll need to place a snippet of Javascript on your “Thank you” or confirmation page. It's best to add this code snippet towards the very bottom of the page; usually before the closing </body> tags.

const rfsn = {
id: localStorage.getItem("rfsn_v4_id"),
url: window.location.href,
aid: localStorage.getItem("rfsn_v4_aid"),
cs: localStorage.getItem("rfsn_v4_cs")
r.sendCheckoutEvent(rfsn.cart,, rfsn.url, rfsn.aid, rfsn.cs);

The value STRIPE-CUSTOMER-ID will need to be dynamically populated from your website based on how your store is integrated with Stripe.

What value do I need to use for the STRIPE-CUSTOMER-ID?

You’ll need to add the customer ID from when the customer is created in Stripe. The customer ID looks something like “cus_ABcdeF1rbnpsupp”.

There are two ways to obtain the customer ID from Stripe:

  • Get the customer ID using Stripe Checkout. Get all the details from Stripe’s guide here.

  • Get the customer ID using Stripe’s API / API Libraries. See Stripe’s API reference for more details.

IMPORTANT: In order for tracking to work the click tracking code installed in Step 1 must be on the same domain and security level (http/https) as the Thank You/Confirmation Page.

Once you’ve completed the above steps, run a test order to confirm the conversion is tracked in Refersion. (You can use a 99% discount code to prevent having to pay full price during testing.)

Note: Free trials will not be tracked in Refersion until the trial is over and the customer is charged. If your store only offers subscriptions with free trials, then you will need to manually end the trial when placing the test order.

If you have any questions, shoot us an email!

Did this answer your question?