Skip to main content

Stripe Integration

Track affiliate-driven recurring subscription revenue from your Stripe account

Written by Shakima

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

  1. Your store is directly integrated with Stripe either by using Stripe's hosted checkout or building your own checkout with Stripe's billing products/Subscriptions API/API Libraries. This means you, not another platform, hold the Stripe account and control the checkout it runs through. If your checkout runs on a different platform and Stripe just happens to be one of the payment options it offers you, this integration isn't for you. Check our integrations list for one built for your specific platform instead.

  2. You primarily sell recurring subscriptions to your customers directly on your website. One-time charges are not tracked through this integration. For non-subscription orders, see Order Tracking Overview for our custom integration instructions.

Getting Started

  1. Connect your Refersion account to Stripe. Go to Your Name > Settings > Tracking, click Add Tracking, choose Stripe, select your account, and click Connect (or choose Stripe from the Start Guide if you're new to Refersion).

  2. Next, decide how you want affiliates to promote. See below.

Choose Your Affiliate Promotion Strategy

There are several ways Refersion can track recurring subscription revenue from affiliate referrals. You can combine more than one of these; they're not mutually exclusive.

  • By link: the affiliate's referral link is clicked, and the resulting customer's subscription is tracked through your website.

  • By coupon: the customer uses a unique coupon code tied to an affiliate at checkout.

  • By email: the customer's email at checkout matches an email you've already associated with an affiliate.

  • By SKU: the customer purchases a specific product (Stripe Price ID) tied to an affiliate (useful for royalty-style commission agreements).

Tracking Link-Based Subscription Referrals

Use this option if you'd like your affiliates to drive traffic through referral links. If you don't plan to have affiliates drive traffic to your site with a referral link, you can skip ahead to the promotion method sections.

Link-Based Tracking Overview

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.

Tracking link-based referrals requires adding two tracking scripts directly on your website, wherever affiliates will be referring customers. Below is an overview of the whole end-to-end tracking flow.

Step 1 (client-side) - Track visits

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.

<!‐‐ REFERSION TRACKING: BEGIN ‐‐>
<script>
! function(e, n, t, i, o, c, s, a) {
e.TrackingSystemObject = "r", (s = n.createElement(t)).async = 1, s.src = "https://cdn.refersion.com/refersion.js", s.onload = function() {
r.pubKey = "YOUR-PUBLIC-KEY", r.settings.fp_off = !1;
r.initializeXDLS().then(() => {
r.launchDefault()
})
}, (a = n.getElementsByTagName(t)[0]).parentNode.insertBefore(s, a)
}(window, document, "script");
</script>
<!-- REFERSION TRACKING: END -->

Step 2 (client-side) - Identify visits

In order to create conversions in Refersion, you’ll need to send us the Stripe Customer ID. In order to do this, you’ll need to place a snippet of JavaScript on your “Thank you” or confirmation page. This links the affiliate's click to the Stripe customer, so Refersion can attribute the initial charge and every renewal to the right affiliate. It's best to add this code snippet towards the very bottom of the page, usually before the closing </body> tags.

<!‐‐ REFERSION TRACKING: BEGIN ‐‐>
<script>
const rfsn = {
cart: "STRIPE-CUSTOMER-ID",
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.id, rfsn.url, rfsn.aid, rfsn.cs);
</script>
<!‐‐ REFERSION TRACKING: END ‐‐>

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

You’ll need to add the customer ID from when the customer was created in Stripe. The customer ID looks something like cus_ABcdeF1rbnpsupp. There are two ways to obtain the customer ID from Stripe:

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 the tracking scripts are in place, jump ahead to the Test Your Setup section for instructions on confirming your integration.

Tracking by Coupon Promotion Method

Use this if affiliates promote with unique coupon codes (works well for Instagram/TikTok/Social Media influencers). No script installation needed for this step if this is the only way affiliates will promote.

In order to track subscription orders through unique coupon codes, you'll manually create individual coupons (not promotion codes) in your Stripe dashboard, one per affiliate, with the coupon ID set to match that affiliate's coupon code promotion method in Refersion. See how to create coupon codes for the Refersion side.

Please Note: The coupon ID must be manually filled in to match the one you'll assign to the affiliate. Otherwise, if left blank, it will be auto-generated by Stripe. The auto-generated code will not create conversions. Always replace it with the one meant for the affiliate to promote.


If you want and have the technical know-how, then you may be able to automate creating the codes in Stripe for new affiliates to reduce manual work. Here's Stripe's API for coupon code creation. Same as the UI, you'll need to ensure ID is set in the request as the code that matches the affiliate's conversion code.

Tracking by Email Promotion Method

Use this if affiliates submit can customer emails directly for attribution, or you want to grant lifetime commission on a customer's future orders.

Tracking by SKU Promotion Method

Use this to credit an affiliate every time a specific product is purchased (a royalty-style commission). No script installation needed.

Refersion receives the Stripe Price ID as the SKU for each transaction. So when setting up product level commissions or SKU promotion methods, use the Price ID, not your internal product SKU.

Test Your Setup

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.

Please 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 or if you need help with testing or troubleshooting the integration, then please feel free to email helpme@refersion.com for assistance!

Disconnect the Stripe Integration

In your Stripe dashboard, go to Apps > Overview > Connect Extensions, find Refersion, click Revoke, and confirm.

Did this answer your question?