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.

You can get the connection code of the script in two ways:

  1. At the page “Integrate > Tracking script”
  2. At the page “Landings > Instruction”. In this case the indicator LP CTR is also monitored.

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. “http://landingpage.com/?_new=1”.

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: 'johh@gmail.com', 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})

And this example sends conversion through postback:

file_get_contents('http://keitaro.com/xxxxxx/postback?sub_id=' . $_COOKIE['s']. '&payout=0.10&status=sale'); 

How to get Subid

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

How to use

The tracking script can work when sending traffic directly to a landing page and after passing traffic through Keitaro.

Source > Landing Page > Offer

This is the case when the traffic goes directly to the landing page. In this case you need to create an empty campaign, add the landing page at the page “Landings” and get the code by clicking on the “Instruction” button. Paste the code at the landing page template between the tags <head>...</head>.

To send to the offers from the campaign stream read the section todo.

Source > Keitaro > Landing page > Offer

In the case where traffic goes through Keitaro, it is necessary to pass the parameter subid in the landing page URL:

http://landing.com/page?subid={subid}

Otherwise, after visiting the landing page a new record of the click will be created.

1. Add the code to the template:

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

2. Call this function in the link:

<a onclick="keitaro_report_conversion(this, 0, 'lead')" href="http://google.com">link</a>

Use the macro {subid} in the links:

<a href="http://offer.com/?id=123123&subid={subid}">go to an offer</a>

How to Send 'subid' in a form?

Add to the form:

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

or

input type="hidden" name="sub_id" />

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['s']:

$subid = $_COOKIE['s'];

Splitting by offers

If streams use schemas “Landing pages” or “Offers” you need to connect a link for sending from the landing page to the offer:

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

How to send users from a landing to the offer

  1. Create a campaign.
  2. Create a stream with a “Landings and Offers” scheme.
  3. Choose an offer or some offers.
  4. Go to “Landings” > “Instruction” and and get a code for adding a tracking script.
  5. Use this link for the offer on a landing page:
<a href="{offer}">Link to offer</a>

Updating the click parameters

To update the parameter use the method KTracking.update:

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

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