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.

Refersion’s integration with Stripe assumes your store has integrated Stripe's billing products into your website directly, or that your store uses Stripe’s Subscriptions API/API Libraries to power subscriptions.

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 the SUBDOMAIN and PUB_KEY within the snippet with the unique Subdomain and Public Key from your Refersion account. You have two ways to get this done:

  • If you’re logged into Refersion, you can visit our tracking instructions page - this page will have your unique snippet (since you’re logged in). Just copy and paste.

  • If you’re not logged in, you can locate your public key and subdomain by following these instructions.

Save these values since you’ll need them again in step 3.

<!‐‐ REFERSION TRACKING: BEGIN ‐‐>
<script src="//SUBDOMAIN.refersion.com/tracker/v3/PUB_KEY.js"></script>
<script>_refersion();</script>
<!‐‐ REFERSION TRACKING: END ‐‐>

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. Use the code snippet below, but replace SUBDOMAIN and PUB_KEY with the same values you saved from Step 1 above.

<!‐‐ REFERSION TRACKING: BEGIN ‐‐>
<script src="//SUBDOMAIN.refersion.com/tracker/v3/PUB_KEY.js"></script>
<script>_refersion(function(){ _rfsn._setSource("STRIPE"); _rfsn._addCart("STRIPE-CUSTOMER-ID"); });</script>
<!‐‐ REFERSION TRACKING: END ‐‐>

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, 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?