JavaScript Integration

Connect your store with ReferralCandy using a JavaScript code

Caye Arahan avatar
Written by Caye Arahan
Updated over a week ago

JavaScript Integration involves adding a JS code to your store's purchase completed page that will send the necessary customer checkout information to ReferralCandy. This integration type tracks purchases and referrals more accurately than Email Integration.

Before you begin integration:

  • JavaScript Integration requires experience in programming. If you are not a developer, either consult one or try Email Integration. Unfortunately, we do not provide debugging support for this.

  • Check that dynamic checkout variables are available on your eCommerce store's platform.

For the list of supported platforms and instructions on how to integrate, please refer to our Setup page. Not sure if ReferralCandy will work on your platform? Check out the following links:


Setting up JavaScript Integration

  1. On your ReferralCandy dashboard, go to Integrations and click Standalone.

  2. Choose JavaScript Integration as your connection type. Click Next.

  3. Copy the code snippet provided in the next step.

  4. Go to your store's dashboard and paste the code snippet before the closing </body> tag on your purchase completed page.

  5. Edit the code by replacing the dummy fields with the dynamic checkout variables from your store platform:

    • data-fname: Customer First Name

    • data-lname: Customer Last Name

    • data-email: Customer Email Address

    • data-amount: Invoice Amount

    • data-currency: Invoice Currency (3 letter code)

    • data-timestamp: Purchase Timestamp (UNIX time)

    • data-external-reference-id: Invoice Number

    • data-signature: Calculated from the MD5 digest of a string containing the email address, first name, invoice amount, order timestamp, and secret key (in that order) separated by commas. Please double check that this is done properly otherwise it will result in a checksum error.

    Note: The MD5 signature is calculated based on the following items: MD5(EMAIL,FIRST_NAME, INVOICE_AMOUNT,TIMESTAMP,ACCOUNT_SECRET)

  6. Save the changes.

The JavaScript snippet contains two parts: an HTML div element that contains invoice information and a script element. The code snippet will also require you to specify your App ID and Secret Key.

The App ID and Secret Key are in the "Plugin tokens" section of your My Profile page.

See a sample

Here's a worked example for your reference:

App ID: THISISMYID

Secret Key: THISISMYKEY

If you have the following invoice:

Name: John Smith

Invoice Amount: USD$10.20

Order Timestamp (in UNIX time): 1396927808

In this example, MD5("john@example.com,John,10.20,1396927808,THISISMYKEY") = eacb54f62a2d989bed54d02f4a171e94

The corresponding div element should therefore be:

<div id="refcandy-mint" data-app-id="THISISMYID" data-fname="John" data-lname="Smith" data-email="john@example.com" data-amount="10.20" data-currency="USD" data-timestamp="1396927808" data-locale="en" data-signature="eacb54f62a2d989bed54d02f4a171e94"></div>


How do I know that the integration is working?

You pasted your tracking code on your site and want to know if your integration is working. Here's how you can test your integration:

First, make a test purchase at your store and look for these signs:

  • Does the purchase show up on your Purchases & Referrals page?

    If there is no purchase on the page, it means that we couldn't detect purchases and referrals on your site. Looking at Checksum Errors might help you to troubleshoot.

  • Are there checksum errors?

    Go to your Integrations page and view the Debug Checksum Errors section. If you don't see any transaction, it means either the purchases are being tracked correctly, or you have not sent any purchases to us.


๐Ÿ’ฌ Need help? Click the chat widget on the right to start a conversation. Learn more


Did this answer your question?