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.
<!‐‐ 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 - 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.
<!‐‐ 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 ‐‐>
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.
Step 4 - Place a Test Order
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 [email protected] for assistance!
Optional Step 5 - Coupon Code Tracking
Refersion can be used to track and attribute coupon sales. Click here to read more about how to create coupon conversion triggers for your affiliates.
At this time, Refersion's integration with Stripe does not include coupon creation, so you would have to manually create coupon codes (NOT promotion codes) for your affiliates in your Stripe dashboard. If you choose to do this, then make sure to use individual codes in Stripe with the coupon's ID personalized to match the coupon trigger in Refersion. Below is an image referencing the field in Stripe that you'll need to match to the affiliate's coupon trigger in Refersion.
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 trigger.
Optional Step 6 - Product Level Commissions and SKU Tracking
In Refersion you can set different commission rates on different products using our product level commissions feature. You can also award commission to an affiliate everytime a specific product is purchased (like a royalty payment) using SKU conversion triggers.
Both of these features rely on you providing us information on specific SKUs in your store. For our integration, please note that Stripe sends us the Price ID as the SKU in each transaction. So when assigning PLCs or SKU triggers in Refersion, just be sure to use the Price ID!