Skip to main content
All CollectionsIntegrationsOther
Better Cart Integration
Better Cart Integration

Follow these guidelines to integrate with Better Cart

Andre Tan avatar
Written by Andre Tan
Updated over 3 years ago

Better Cart is an app that can be integrated into your Shopify store to enable post-purchase upsells, a customized checkout and more. Because Better Cart has its own checkout distinct from the Shopify checkout, you’ll need to integrate Refersion directly with Better Cart in order to track conversions.

To get started, open your Better Cart dashboard and click the gear icon on the left navigation menu. From here, scroll down to the “Custom Scripts” section and click New Custom Script. A new popup will appear.

Configure the settings in the popup to match the below:

  • For the dropdown menu, select “Thank you page”. We’ll need this to run when the customer completes their order.

  • For the “Name” field, enter “Refersion Conversion Tracking” or something similar.

  • Important! Please disable the “Load Asynchronously” option (you’ll know this option is disabled when the option switcher is light grey instead of dark grey). This is important because some of the code you’ll be pasting needs to run when your thank you page is fully loaded.

Here is how your settings should look so far:

Next, please copy and paste the below code snippet into the code box in the popup. You’ll need to add your Refersion SUBDOMAIN and PUB_KEY into the snippet, replacing the holder text (SUBDOMAIN and PUB_KEY) that you’ll see towards the bottom of the code snippet. You have two options to grab these values from your Refersion account:

  • If you’re logged in, visit our tracking instructions page - this page will have your unique snippet (since you’re logged in). Just copy the section that matches the highlighted portion below and paste.

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

Once you’ve located and replaced your subdomain and public key, paste the entire code snippet below into the code box.

<script>
function loadRfsnScript(e){let t=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e,t.appendChild(n),n.onload=function(){_refersion()}}

function sendOrdertoRefersion() {
setTimeout(function(){
if(typeof _refersion !== undefined) {
_refersion(function() {
_rfsn._setSource('RFSN_JS_V3');
_rfsn._addTrans({
'order_id': window.bcData.order.order_number,
'shipping': typeof window.bcData.order.total_shipping !== undefined ? window.bcData.order.total_shipping : 0,
'tax': typeof window.bcData.order.total_taxes !== undefined ? window.bcData.order.total_taxes : 0,
'discount': typeof window.bcData.order.total_coupons_amount !== undefined ? window.bcData.order.total_coupons_amount : 0,
'discount_code': typeof window.bcData.order.coupon.coupon_code !== undefined ? window.bcData.order.coupon.coupon_code : '',
'currency_code': typeof window.bcData.order.currency !== undefined ? window.bcData.order.currency : 'USD'
});
_rfsn._addCustomer({
'first_name': typeof window.bcData.order.shipping_address.first_name !== undefined ? window.bcData.order.shipping_address.first_name : '',
'last_name': typeof window.bcData.order.shipping_address.last_name !== undefined ? window.bcData.order.shipping_address.last_name : '',
'email': typeof window.bcData.order.customer.email !== undefined ? window.bcData.order.customer.email : '',
'ip_address': ''
});
for (let key in window.bcData.order.line_items) {
if (window.bcData.order.line_items.hasOwnProperty(key)) {
_rfsn._addItem({
'sku': window.bcData.order.line_items[key].sku,
'quantity': Number(window.bcData.order.line_items[key].quantity),
'price': Number(window.bcData.order.line_items[key].price)
});
}
}
_rfsn._sendConversion();
});
}
}, 2000)
}

loadRfsnScript("https://SUBDOMAIN.refersion.com/tracker/v3/PUB_KEY.js")
document.addEventListener('DOMContentLoaded', sendOrdertoRefersion())
</script>

Lastly, click the create button to save your new script.

Please note: If you signed up for Refersion after July 2020, please reach out to our team at [email protected] before placing a test order. We’ll need to make a small change on your account to enable conversion tracking through the Better Cart checkout.

Did this answer your question?