This guide will help you integrate your Refersion and Chargebee account, allowing you to track affiliate orders generated from your Chargebee platform.

 Please note: If you are using a lightbox as your checkout page, then you'll need to make sure you are using a redirected thank you page. You'll need to follow the [b] directions during steps 5 and 6.

Below are the required steps to connecting Refersion to Chargebee: 

Step 1 Add Tracking: Add Chargebee as an ecommerce platform to your Refersion account

Step 2 Install the Tracking Script: Install Refersion's tracking script in the header section of your site. This usually means all marketing/content pages except for the checkout and thank you pages 

Step 3 Configure Webhooks: This sends order information to Refersion

Step 4 Paste in the keys and subdomain: Configure the Refersion integration in Chargebee

Step 5a [Self-Hosted Thank You Page only] Adding parameters: This sends Refersion the subscription ID

Step 5b [Checkout page has a Light box] Adding parameters: This sends Refersion the subscription ID
   
Step 6a [Self-Hosted Thank You Page only] Add the code snippet: This sends Refersion the click ID

Step 6b [Checkout page has a Light box] Add the code snippet: This sends Refersion the click ID

Step 7 Run a Test Order

Step 1: Add Tracking

If you just signed up to Refersion and are still on the Select your ecommerce platform to begin page, click on Chargebee and follow the instructions below. If you are no longer in the Start Guide, navigate to Account > Settings > Tracking click + Add Tracking and select Chargebee from the list of platforms:

Choose if your Thank You Page is Hosted or Self-Hosted. You probably already know this, if not here is a Chargebee help article explaining the difference. Essentially this comes down to your checkout page: does the URL change to be a Chargebee URL (Hosted) or does it stay as your site's domain (Self-Hosted). Enter your Shop URL and Chargebee Site URL. The rest of the setup will take place in your Chargebee account.

Step 2: Install the Tracking Script

Install Refersion's tracking script in the header of your site. By installing the script in the header of your site, you can rest assured that the script will run when a customer visits the page. Be sure to replace both SUBDOMAIN and PUB_KEY with the Refersion Subdomain and Public Key from the step above. If you navigated away from that page, that information can also be found on our Tracking Page (be sure you are signed in to Refersion to have the appropriate PUB_KEY populated!) or go here for instructions on how to find them. This is a slightly modified version of the script on the tracking page.

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

Step 3: Configure Webhooks

This step allows Chargebee to send Refersion order data via webhook. This should be done automatically for you in Step 1, but it is a good idea to make sure it has been added. To do this, log in to your Chargebee account and navigate to Settings > Webhook Settings (listed under API & WEBHOOKS). 

Click Add New Webhook and input the Webhook Name and the following Webhook URL, replacing SUBDOMAIN, PUB_KEY and SEC_KEY from above, and be sure no additional spaces are added. If you navigated away from that page, instructions on how to find pub_key and private_key can also be found here.

All the other settings stay as they are. Click Create Webhook when done. You will get a V2 confirmation, click Confirm.

https://inbound-webhooks.refersion.com/chargebee/v2/orders/paid?public_key=PUB_KEY&private_key=SEC_KEY

Step 4: Paste in the keys and subdomain

Next, we need to configure the Refersion Integration. In Chargebee, go to Settings > Refersion. Paste in your PUB_KEY, SEC_KEY, and your Refersion subdomain. For Version, select V2

If you navigated away from that page, instructions on how to find pub_key and private_key can also be found here.

If you have a Hosted thank you page (i.e. your Thank You Page is on a chargebee.com site) you are all done! Run a test order to make sure everything is tracking properly.

If not, and your Thank You Page is on your own domain, continue with the steps below.

Continue below if you have a Self-Hosted Thank You Page:

Step 5a : Adding parameters

Add the following URL parameter to your redirect url in your Chargebee Settings page: 

?rfsn_ci=#{{subscription.id}}

Step 5b: [Checkout box is a Lightbox] Adding parameters

Add the following URL parameter to your redirect url in your Chargebee Settings page: 

?rfsn_cti=#{{subscription.id}}

Step 6a: Add the code snippet:

Add this code snippet to your thank you page. Again, be sure to replace SUBDOMAIN, PUB_KEY and SEC_KEY from above, and be sure no additional spaces are added. If you navigated away from that page, instructions on how to find pub_key and private_key can be found here.

<!-- REFERSION TRACKING: BEGIN -->
<script src="//SUBDOMAIN.refersion.com/tracker/v3/pub_key.js">
</script><script>function rfsn_getQS(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)"),n=t.exec(location.search);return n==null?"":decodeURIComponent(n[1].replace(/\+/g," "))}
if (rfsn_getQS('rfsn_ci')) {
_refersion(function(){
_rfsn._addCart(rfsn_getQS('rfsn_ci'));
_rfsn._setSource("CHARGEBEE");
});}</script>
<!-- REFERSION TRACKING: END —>

Step 6b: [Checkout page is a lightbox] Adding parameters

Add this code snippet to your thank you page. Again, be sure to replace SUBDOMAIN, PUB_KEY and SEC_KEY from above, and be sure no additional spaces are added. If you navigated away from that page, instructions on how to find pub_key and private_key can be found here.

<!-- REFERSION TRACKING: BEGIN -->
<script src="//SUBDOMAIN.refersion.com/tracker/v3/pub_key.js">
</script><script>function rfsn_getQS(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)"),n=t.exec(location.search);return n==null?"":decodeURIComponent(n[1].replace(/\+/g," "))}
if (rfsn_getQS('rfsn_cti')) {
_refersion(function(){
_rfsn._addCart(rfsn_getQS('rfsn_cti'));
_rfsn._setSource("CHARGEBEE");
});}</script>
<!-- REFERSION TRACKING: END —>

Step 7: Run a Test Order

Run a test order to make sure everything is tracking properly. If the above directions do not fit your exact parameters for your site, then please shoot us an email and we'll be glad to help! 

Did this answer your question?