Tracking script

What is Tracking Script?

The tracking script is a small js-library that can pass information about clicks and conversions. This allows you to quickly connect Keitaro to the already running landing page, so that you don't have to redirect traffic and change links. It is also possible to use it on the final landing pages where lids are collected.

How to use

Please see page Landing Pages.

How to count non-unique clicks?

In the default settings, the tracking script counts only the first visit, after which the script keeps all the information about this click in cookies. To count non-unique clicks, add _new=1 parameter to the page link, where the script is installed, e.g. “”.

There is another one option. You can switch collectNonUniqueClicks to true:

collectNonUniqueClicks: true

Is param is included in the tracking script snippet

if (!window.KTracking){window.KTracking={collectNonUniqueClicks: true, R_PATH:...

Sending conversions

Conversions are sent by using the method KTracking.reportConversion. Here are some examples.

Making a sale:

KTracking.reportConversion(revenue, 'sale');

Instead of “revenue” enter the amount of income or “0”.

Sending a conversion with parameters:

KTracking.reportConversion(revenue, 'lead', {extra_param_1: '', extra_param_2: 'John Smith'})

Cancellation of conversion:

KTracking.reportConversion(revenue, 'rejected');

With passing the parameters:

KTracking.reportConversion(revenue, 'sale', {sub_id_10: 'order 1'})

You can send parameters sub_id_1..10 and extra_param_1..10.

For upsells and rebills send a unique (for subid) tid:

var tid = Math.floor(Math.random() * 1000000000);
KTracking.reportConversion(revenue, 'sale', {tid: tid})

Sending postbacks on PHP

There are two ways to get subid for the postback:

  1. Insert subid in the links or the form
  2. Get subid from the cookies

Here's how you can get subid from the cookies

file_get_contents('' . $_COOKIE['subid']. '&payout=0.10&status=sale'); 

1. Add the code to the page:

function keitaro_report_conversion(link, revenue, status, tid) { 
   KTracking.reportConversion(revenue, status, tid, function() { 
       window.location = link.href; 
    return false; 

2. Add to the links:

<a onclick="keitaro_report_conversion(this, 0, 'lead')" href="">link</a>

How to get 'subid'

KTracking.ready(function(subid, token) {
    alert('SubId: ' + subid + ', Token: ' + token);

Use the macro {subid} in the links:

<a href="{subid}">go to an offer</a>

How to add 'subid' to a form?

Add input with name subid to the form:

<input type="hidden" name="subid" />

How to send 'subid' in PHP

You must have at least 2 pages:

  1. Landing page (with installed tracking script)
  2. Submit page

On the submit page you can get current 'subid' in variable $_COOKIE['subid']:

$subid = $_COOKIE['subid'];

Use macro {offer} in the links:

<a href="{offer}">Link to offer</a>

Make sure, that campaign streams contain offers.

Use macro {offer} with parameter offer_id=ID in the links:

<a href="{offer}&offer_id=1">Link to offer 1</a>
<a href="{offer}&offer_id=2">Link to offer 2</a>

Updating the click parameters

To update the parameter use the method KTracking.update:

KTracking.ready(function() {
   KTracking.update({sub_id_1: window.navigator.cookieEnabled})

You can update parameters sub_id_1..15