Skip to main content

JavaScript affiliate checker

JavaScript affiliate checker

Last updated: 29-Feb-2024
Rate this article:


Use the JavaScript Affiliate Checker to keep track of sales generated by members of the 2Checkout Affiliate Network for services/products that you sell using a third-party eCommerce platform.

  • 3rd party eCommerce provider -> JAVASCRIPT affiliate checker -> detects 2Checkout cookie -> 2Checkout buy-links
  • 3rd party eCommerce provider -> JAVASCRIPT affiliate checker -> does not detect 2Checkout cookie -> 3rd party buy links


In order to use JavaScript Affiliate Checker, the following requirements must be met:

  • The 2Checkout Affiliate Network is enabled for your account.
  • Products sold through a third-party platform and available to 2Checkout Affiliates must be configured within the 2Checkout platform as well, and need to be assigned to commissions lists associated with 2Checkout Affiliates. Make sure to specify a commission you're willing to pay for affiliate referrals.

How does the JavaScript Affiliate Checker work?

Take advantage of the JavaScript Affiliate Checker to customize the content of your online store for those shoppers that feature the 2Checkout affiliate cookie.

Installing the JavaScript Affiliate Checker

To install, copy and customize the 2Checkout Affiliate Checker JavaScript code and place the code between the <head></head> tags on your site.

<script language="JavaScript">
var scriptSRC = '/check_affiliate_v2.js';
var protocol = window.location.protocol;
if (protocol.indexOf("https") === 0) document.write(unescape("%3Cscript src='" + scriptSRC + "' type='text/javascript'%3E%3C/script%3E"));
else document.write(unescape("%3Cscript src='" + scriptSRC + "' type='text/javascript'%3E%3C/script%3E"));
<script language="JavaScript">
var avgParams = _checkAvgParams();
var alreadyChecked = false;
if (avgParams != null) {
_AVGSetCookie('_avgCheck', avgParams);
alreadyChecked = true;
var avgProds = _avgProds(_AVGGetCookie('_avgCheck'), alreadyChecked, vId); //redirect
var AVG_AFF = false;var AVG_PRODS = new Array();
if (avgProds != "-") {
AVG_AFF = true;
if(avgProds != 'all') {AVG_PRODS = avgProds.split(',');}

The JavaScript code inserted into your site will help check and identify shoppers that feature the 2Checkout affiliate cookie and will return a set of results (response JavaScript variables):

  • AVG_AFF - boolean - having the following possible values
    • true - the customer has an active tracking cookie
    • false - the customer does not have an active tracking cookie
  • AVG_PRODS - JavaScript array - an associative array with all products that are tracked by 2Checkout or empty value is a general referral cookie is set.

AVG_AFF = false

AVG_PRODS = empty array, not applicable

AVG_AFF = true

AVG_PRODS = JavaScript array if no general cookie is set and specific product cookies are set

AVG_AFF = true

AVG_PRODS = empty array, general cookie is set

  • AVG_SET_DATE – delivers the date when the cookie was set in the user’s browser
    • Format: YYYY-MM-DDTHH:MM:SS (E.G: 2019-10-18T15:27:54)

Use the results to:

  • Build efficient landing pages for your affiliates;
  • Display custom information on your pages;
  • Prevent affiliate leaks by displaying the correct buy buttons;
  • Get extra information about your affiliate activity.

You will need to use the responses returned by the script in order to redirect shoppers to either the 2Checkout shopping cart, if a 2Checkout affiliate ID is detected, meaning they there were redirected to your website from a 2Checkout affiliate; or to the third-party shopper platform of your choice.

When redirecting customers to the 2Checkout shopping cart, use Buy Links generated via the Control Panel.

Orders placed by shoppers that used the Buy Links from 2Checkout affiliates will immediately be visible in the Order search area of the Control Panel.

Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo