Cratejoy Integration

Learn how to integrate Refersion with your Cratejoy account.

Andre Tan avatar
Written by Andre Tan
Updated over a week ago

Cratejoy is a subscription platform for boxes of gifts and goods that acts as a marketplace for anyone that would like to create box subscriptions. This article outlines the steps necessary to integrate your Refersion account with Cratejoy.

Please note: This integration does not allow you to track subscription renewals; you will only be able to track the initial order placed by a customer if they are purchasing a recurring subscription.

Step 1: Tracking clicks on your site

In order to create conversions for affiliate-driven sales, we’ll first need to track visits from customers that are referred by the affiliate referral link (commonly called “clicks”). This means that, depending on your site’s set-up, you’ll need to either add Refersion’s tracking code snippet to your Cratejoy page or directly to your custom site’s header files.

In order to obtain your tracking code snippet, log into your Refersion account and open our custom tracking documentation in a new tab. Logging into Refersion first will help ensure your account’s credentials are auto-populated in the tracking code snippet.

From that page, under Step 1 - Tracking Visits, copy all of the code from the black box - this is the tracking code snippet you’ll need to add to your site.

Once you have your tracking code snippet, you can add it to your site in one of two ways: for custom domains (i.e. http://www.yoursite.com), then go to step 1a; if you are using a cratejoy.com page, head directly to step 1b.

Step 1a (For Custom Domains)

You’ll need to insert the tracking pixel that you copied above into the <head> section of your website across any pages a customer can land on. Some websites use a main header file; if your site has one, you can add it there. Once you're done with this step, you can skip ahead to Step 2: Tracking Orders.

Step 1b (for cratejoy pages)

If you are using the cratejoy page, then you can insert the tracking pixel into your template directly. First, click Design in the sidebar menu.

Click Designer for the theme that you want to update:

Then, click SEO Settings.

Next, click Site Settings.

Now add the tracking code snippet from above to the footer code box. If you have existing scripts in this box, you can just add this new snippet below. Be sure to enable the E-Commerce Tracking setting (if not already enabled).

Step 2: Tracking Orders

Now that we can track clicks, we’ll need to track the orders placed by customers back to the affiliates that referred them to your site. This will require a second code snippet to send order data to Refersion.

From the main Cratejoy sidebar menu, click “Design” and then “Code”. Navigate down to components → customer→ thank_you → Customer Thank You Content → component.html:

Insert the following code into the component.html file, replacing “SUBDOMAIN” and “YOUR-PUBLIC-KEY” with the specific subdomain and public key from your Refersion account. Those values are within the tracking code snippet you copied previously, or see how to find them in this article.

!! Important Note: This code should be inserted before the closing </section> tab in the component.html template.

<!-- REFERSION TRACKING: BEGIN -->  
<script src="//SUBDOMAIN.refersion.com/tracker/v3/YOUR-PUBLIC-KEY.js"></script>
<script>
_refersion(function(){
_rfsn._addTrans({
'order_id': '{{ order.id }}',
'shipping': '{{ order.total_shipping / 100 }}',
'tax': '{{ order.total_tax / 100 }}',

{% if order.coupons | length > 0 %}
{% for coupon in order.coupons %}
'discount': '{{ coupon.discount_value / 100 }}',
'discount_code': '{{ coupon.code_used }}',
{% endfor %}
{% endif %}
'currency_code': 'USD'
});

_rfsn._addCustomer({
'first_name': '{{ customer.first_name }}',
'last_name': '{{ customer.last_name }}',
'email': '{{ customer.email }}'
});

{% if order.products | length > 0 %}
{% for product in order.products %}
_rfsn._addItem({
'sku': '{{ product.id }}',
'quantity': '{{ product.quantity }}',
'price': '{{ product.price / 100 }}'
});
{% endfor %}
{% endif %}
_rfsn._sendConversion();
});

</script>
<!-- REFERSION TRACKING: END-->

If your store is NOT using USD as their currency, then you MUST also replace the ‘currency code’ in the code snippet above with the 3-letter currency value that pertains to your store (i.e. CAD, EUR, GBP).

Step 3: Place a test order

Once all tracking code snippets are in place, place a test order to confirm everything is working properly. You can use a 100% off/free shipping code (Cratejoy can have one code do both) for your test order. Zero dollar orders still require a credit/debit card so be sure to have one handy.

Once complete a conversion should pop up in your Refersion account. If you don’t see your test order after an extended period of time or if you run into any other issues, please send us an email or start an in-app chat!

Did this answer your question?