# Tracking Script

The tracking script is one of the methods for tracking traffic and targeted actions on remote sites. The integration is capable of transferring information about clicks and conversions, enabling quick integration of Keitaro with an already operational landing page. The code allows the following actions:

  • Configuring transitions from landing pages to offers for local and remote landing pages. Does not support splitting landing pages, offers, or redirecting to landing, and offer pages.
  • Sending conversions to the tracker from your own site with or without using the partner network using PHP or JavaScript code.
  • Sending conversions upon button click from both local and remote sites.
  • Updating click parameters.

The code for connecting the script is available in the Campaigns > Tracking > Tracking Script .

# Integrating with the Landing Page

  1. Campaign creation

Create a campaign in Keitaro.

  1. Obtaining Tracking Code

Select a domain with HTTPS on the Campaign settings tab. Go to the Tracking tab and copy the tracking code (code for the landing page):

  1. Connect via SFTP (video)

Navigate to the website directory:

Insert the code copied from the campaign into the index.html/php of the website, between the <head> </head> tags.

# Usage Examples

# Sending Postback from a Button for a Local Offer

This method is suitable for sending conversions when a button from a local offer is clicked.

TIP

Placing the Tracking Script in a local offer creates clicks duplicates.

  1. Create a campaign in Keitaro.

  2. The example of a campaign setup: one flow is created. The first flow contains a local offer. Add the tracking code (code for the landing page) to the offer:

  1. Add the postback sending code to the desired button:
<a onclick="KTracking.reportConversion(0, 'lead')" href="http://google.com">link</a>
1

Where google.com is the destination after the click.

# Sending Postback from a Button on a Hosted Website

This method is suitable for sending conversions when a button on a remote site is clicked.

  1. Create a campaign in Keitaro.

  2. The example of a campaign setup: one flow is created. The first flow has an action Do nothing to collect statistics and turn on data retrieval from the site.

  3. Connect via SFTP (video)

Navigate to the website directory:

Insert the code copied from the campaign into the index.html/php of the website, between the <head> </head> tags.

  1. Add the postback sending code to the desired button:
<a onclick="KTracking.reportConversion(0, 'lead')" href="http://google.com">link</a>
1

Where google.com is the destination after the click.

# Sending Postback upon Visiting the Thank You Page

This method is for sending a postback from a remote site after filling out a form. The form opens the 'Thank You' page and sends a postback to the tracker.

  1. Create a campaign in Keitaro.

  2. The example of a campaign setup: one flow is created. The first flow has an action Do nothing to collect statistics and turn on data retrieval from the site.

  3. Connect via SFTP (video)

Navigate to the website directory:

Insert the code copied from the campaign into the thanks.html/php of the website, between the <head> </head> tags.

  1. Immediately after the Tracking Script, add the conversion sending code:
<script>
   const revenue = 0;
   const status = 'lead';
   const tid = Math.floor(Math.random() * 1000000000);
   KTracking.reportConversion(revenue, status, {tid});
</script>
1
2
3
4
5
6

After filling out the form, a click landing on the 'Thank You' page will send a postback to the tracker.

# Counting Non-Unique Clicks

The tracking script counts the first visit. It is possible to turn on counting non-unique clicks or add _new=1 to the links on the integration page.

Example: https://landingpage.com/?_new=1.

Specify directly in the tracking code:

Replace collectNonUniqueClicks: false with collectNonUniqueClicks: true.

# Sending postbacks

# Using offers

TIP

In order for the scheme to work, the thread must contain the offers.

# Getting subid

# Updating Click Parameters

Updating click parameters allows modifying click data – sub_id (1–30). To update a parameter, use the method KTracking.update:

The code must be placed inside your local offer or landing page:

<script>
KTracking.ready(function() {
   KTracking.update({sub_id_1: window.navigator.cookieEnabled})
});
</script>
1
2
3
4
5

It is possible to pass parameters sub_id_1 through sub_id_30.

# Description of the Method KTracking.reportConversion

KTracking.reportConversion(payout, status, params, cb);
1
  • payout. The payout amount.
  • status. The conversion status (lead, sale, or rejected).
  • (Optional) params. The object with parameters (for example, {sub_id_1: 'order-form', sub_id_2: 'submit'}). The sub_id_1 to sub_id_30 parameters are supported.
  • (Optional) cb. The function executed after sending data to the tracker (example, funtion(){ window.alert("Form sent")}).

# Examples

Send a sale conversion:

KTracking.reportConversion(0, 'sale');
1

Send with additional parameters:

KTracking.reportConversion(revenue, 'lead', {sub_id_1: 'johh@gmail.com', sub_id_2: 'John Smith'})
1

Send as rejected conversion:

KTracking.reportConversion(0, 'rejected');
1

Send as resell:

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

tid value must be unique.