Skip to main content
knowledgecenter.avangate.com

JavaScript affiliate checker

Overview

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

  • 3rd party ecommerce provider -> JAVASCRIPT affiliate checker -> detects Avangate cookie -> Avangate buy links
  • 3rd party ecommerce provider -> JAVASCRIPT affiliate checker -> does not detect Avangate cookie -> 3rd party buy links

Requirements

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

  • The Avangate Affiliate Network is enabled for your account.
  • Products sold through a third-party platform and available to Avangate Affiliates must be configured within the Avangate platform as well, and need to be assigned to commissions lists associated with Avangate 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 Avangate affiliate cookie.

Installing the JavaScript Affiliate Checker

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

<script language="JavaScript">
var vId = 'UNIQUE CODE FOR YOUR ACCOUNT';
var scriptSRC = '/check_affiliate_v2.js';
var protocol = window.location.protocol;
if (protocol.indexOf("https") === 0) document.write(unescape("%3Cscript src='https://secure.avangate.com/content" + scriptSRC + "' type='text/javascript'%3E%3C/script%3E"));
else document.write(unescape("%3Cscript src='http://content.avangate.com" + scriptSRC + "' type='text/javascript'%3E%3C/script%3E"));
</script>
<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(',');}
}
</script>

The JavaScript code inserted into your site will help check and identify shoppers that feature the Avangate 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 Avangate 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

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 Avangate shopping cart, if an Avangate affiliate ID is detected, meaning they there were redirected to your website from an Avangate affiliate; or to the third-party shopper platform of your choice.

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

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