Setup of your affiliate marketing program with Cratejoy



Once you have setup your affiliate program with Affilae, you have to add tracking codes in your website, to track all sales from your affiliates.

To add tracking codes with Cratejoy, please, follow these steps:
=> If you are using redirect tracking, go to step 2.

1 – Add clicks tracking script

In your Cratejoy dashboard, go to “design” > click “code” next to your theme > Select the base.html template.

Add the following code just after the <body>tag at the top of the file

Example :

<script type="text/javascript">
  var _ae = {
    'pid': 'YOUR PROGRAM ID',
    'advertiserFirst': 21600, // 15 days in mins
    'allowSiteUnder': false,
    'allowIframing': false,
    'host': ''
  (function() {
    var element = document.createElement('script'); element.type = 'text/javascript'; element.async = true;
    element.src = '//';
    var scr = document.getElementsByTagName('script')[0]; scr.parentNode.insertBefore(element, scr);

Be carful! Remember to replace PROGRAM_ID with your PROGRAM_ID (retrieve it in your account, menu “config”). Please make sure that your PROGAM_ID is between quotes (').


2 – Add a conversion tag to the order confirmation page

First, go to the code editor and find the file named ‘thank_you.html’. It should look something like this:


This is the page that is displayed once a customer has successfully checked out, so at this point we have access to their order information which we will need in this step.

You will need four things to setup the tracking pixel.

What you need: How to get it: 

  • AMOUNT = {{ order.total_price * 0.01 }} 
  • UNIQUE_ID = {{ }} 

This items are directly available on the thank you page trough the special curly bracket ‘{{}}’ markup. 

Now we’re ready to create the pixel. It’s done by adding an html image element to your thank you page to track the event.

Then you would add this piece of code right above the {% endblock %} on the thank you page: eg. :

<img src="{KEY}&id={{ }}&amount={{order.total_price * 0.01}}&payment=online" width="1" height="1">



Be carful! Remember to replace KEY with your KEY (retrieve it in your account, menu “config”, then “conversion code” green button)



Congratulations, you complete the installation of your affiliate program tracking codes.

You can now test if the tracking is functional by following this documentation.



Need further informations? Contact us.