# KClient PHP pro business

KClient PHP is a ready client (an integration script) that is based on a Click API V3. KClient PHP already has the basic methods of the Click Api v3 work and the automatic click transfer and the description of the tracker's response.

# Features

  • Passing information about the current visitor to Keitaro.
  • Passing parameters from the address bar.
  • Receiving click's subid.
  • Processing and execution of Keitaro instructions: displaying a text, executing a redirect.

Read our full manual.

# How to integrate KClient PHP to a website

  1. Go to Keitaro and open the campaign page.
  2. Go to Integrations tab.
  3. Choose there KClient PHP and follow the instructions.
  4. Insert the code to the index.html file. Put it to the very beginning of a file. change .html extension to .php so it is now an index.php file.

# Client initialization

$client = new KClient('https://domain_tracker/api.php?', 'token');

# Client's methods description

Method Description
$client->sendAllParams(); Passing parameters from an address bar
$client->forceRedirectOffer(); Enables redirects to offers. If offer is chosen in the stream, it will be performed redirect to it. In other case, you must use getOffer()()
$client->params('param1=c&param2=b'); Passing parameters string
$client->param('extra_param_5', '123'); Alternative method of passing a parameter
$client->sendUtmLabels(); Passing utm-labels from the address bar
$client->debug(); Displaying the debugging information
$client->currentPageAsReferrer(); Send the current page address as a referrer
$client->keyword('KEYWORD'); Using the 'KEYWORD' value as a keyword
$client->execute(); Executing Keitaro instructions with the continuation of the page code execution
$client->executeAndBreak(); Executing Keitaro instructions with stoppage of the page execution. If the action “Do Nothing” is passed in the stream, there will be no stoppage
$client->getOffer(); Returns the offer link. The campaign must contain streams with schema 'Offers'. In other case, you'll receive 'no_offer'. Use this method if you don't want to perform automatic redirect to offer.
$client->getBody(); Get 'body' value
$client->getSubId(); Returns SubId
$client->getHeaders(); Get 'headers' value (array)
$client->isUnique(level); Uniqueness (level variations: stream, campaign, global)
$client->isBot(); Bot status
$client->disableSessions(); Disable PHP session cookie (without this cookie restoreFromSession wouldn't work)
$client->restoreFromQuery(); Catches query params _subid and _token without creating new click
$client->restoreFromSession(); Restores previous click data from session without creating new click

This is example to use offer link in the page template:

require_once dirname(__FILE__) . '/kclient.php';
$client = new KClient('https://domain_tracker/api.php?', 'wzbfwg3dxlmttkvt5v63mbw3x');
<a href="<?php echo $client->getOffer() ?>">CLICK!</a>

You have to use Landing Pages and Offers scheme in a stream.

If you need a particular offer send offer_id parameter:

<a href="<?php echo $client->getOffer(array('offer_id' => 123), '#');?>">LINK</a>

In case there are chanses the tracker won't return an offer, you can put a a default link as the second parameter:

<a href="<?php echo $client->getOffer(null, 'https://google.com');?>">LINK</a>

# How to prevent a website from loading after the code





# How to Send Postbacks

To send a postback you will nedd a subid. To get a subid use $client->getSubid(); and put it to the session:

$_SESSION['subid'] = $client->getSubid();

Then take the subid from the session on a page where you send the postback:

$url = 'http://tracker.com/POSTBACK_KEY/postback?payout=100&status=sale&subid=' . urlencode($_SESSION['subid']);

# KClient PHP FAQ

# How to Integrate KClient PHP with Wordpress

Use WordPress plugin.

# How to send title as a keyword

You need to learn how to get title in php scripts. You need to send the keyword with $client->keyword('...') method:


$myTitle - is the example of how thw variable content is transferred as a keyword.

# How to Show the Content From the Stream in the Specific Place

  1. Delete or comment the lines $client->execute(); and $client->executeAndBreak();.

  2. Add $GLOBALS['client'] = $client;.

  3. Put the code in the necessary place <?php echo $GLOBALS['client']->getContent() ?>.

# How to solve issues with Click Client

First of all check if the clicks get into the tracker. Check the traffic log and campaign's Clicks Report.

If there are no clicks add to the end of integration code:


After $client->execute() and $client->executeAndBreak().

This will show the debug info on the page.

If there's no log add the following before the integration code (after <?php):

ini_set('display_errors', 'on');

# How to Leave Users on the Website

Use action “Do Nothing” in the stream.

# How to check if Keitaro defines the user as a bot

client incialization code
if ($client->isBot()) {
   echo 'bot';
} else {
   echo 'not bot';

# How to insert the path to kclick_client.php if there are folders

Check your website directory and put an obsolete path:

require '/path_to_the_website/kclick_client.php';

# Why is there a php-code on a website and it's not performed

  1. Make sure the index file is with php extension.
  2. The code itself should has tags:

# There's an http-redirect in a traffic log but actually it's not executed

The reason is that the index.php file is saved in utf-8 with BOM header.

Check if there are any spaces or symbols before the code. Delete this symbole or space, or save the file in UTF-8 without BOM.

Important! Not all editors can see this symbol or a space.

# How to send postbacks with KClient PHP

Subid can be received with $client->getSubId() method:

$url = 'https://domain_tracker/85474/postback?payout=0&status=lead&subid=' . urlencode($client->getSubId());

# How to get a subid on secondary pages

The subid content is saved into a session:


You can use the following piece of code in your scripts:

session_start(); // if the session wasn't used earlier it's better to launch it.
$data = array(
 'sub1' => $_SESSION['sub_id'],
 'name' => $_POST['name'],

# How to use Click Client on inner pages

Enable Click Client on an inner page adding $client->restoreFromSession(); :

require_once dirname(__FILE__) . '/kclick_client.php';
$client = new KClickClient('http://..../api.php?', 'TOKEN');


Now you can call the same methods without creating a new click:

<a href="<?php echo $client->getOffer()">offer link</a>

# Request error codes

  • [REQ_ERR: 400] - This response means that server could not understand the request due to invalid syntax

  • [REQ_ERR: 401] - The client must authenticate itself to get the requested response

  • [REQ_ERR: 403] - The client does not have access rights to the content

  • [REQ_ERR: 404] - The server can not find the requested resource

  • [REQ_ERR: 405] - The request method is known by the server but has been disabled and cannot be used

  • [REQ_ERR: 407] - The authentication is needed to be done by a proxy

  • [REQ_ERR: 408] - Request timeout

  • [REQ_ERR: 410] - The requested content has been permanently deleted from the server, with no forwarding address

  • [REQ_ERR: 429] - The user has sent too many requests in a given amount of time

  • [REQ_ERR: 500] - The server has encountered a situation it doesn't know how to handle

  • [REQ_ERR: 501] - The request method is not supported by the server and cannot be handled

  • [REQ_ERR: 502] - The server, while working as a gateway to get a response needed to handle the request, got an invalid response

  • [REQ_ERR: 503] - The server is not ready to handle the request. Common causes are a server that is down for maintenance or that is overloaded

  • [REQ_ERR: 504] - The server is acting as a gateway and cannot get a response in time

  • [REQ_ERR: 505] - The HTTP version used in the request is not supported by the server

  • [REQ_ERR: UNSUPPORTED_PROTOCOL] - The URL you passed used a protocol that this cURL does not support

  • [REQ_ERR: FAILED_INIT] - Very early initialization failed. This is likely to be an internal error or problem, or a resource problem where something fundamental couldn't get done at init time

  • [REQ_ERR: BAD_URL] - The URL was not properly formatted

  • [REQ_ERR: COULDNT_RESOLVE_PROXY] - The given proxy host could not be resolved.

  • [REQ_ERR: COULDNT_RESOLVE_HOST] - The given remote host was not resolved. Check DNS settings of the domain.

  • [REQ_ERR: COULDNT_CONNECT] - Failed to connect to host or proxy. Check if server where Keitaro installed is up.

  • [REQ_ERR: PARTIAL_FILE] - A data transfer was shorter or larger than expected. Check Keitaro system log.

  • [REQ_ERR: READ_ERROR] - There was a problem reading a data

  • [REQ_ERR: OUT_OF_MEMORY] - A memory allocation request failed. You must increase memory_limit on the client server.

  • [REQ_ERR: OPERATION_TIMEDOUT] - The specified time-out period was reached according to the conditions

  • [REQ_ERR: HTTP_POST_ERROR] - Internal post-request generation error

  • [REQ_ERR: BAD_FUNCTION_ARGUMENT] - A function was called with a bad parameter

  • [REQ_ERR: TOO_MANY_REDIRECTS] - When following redirects, client hit the maximum amount

  • [REQ_ERR: GOT_NOTHING] - Nothing was returned from the server

  • [REQ_ERR: SEND_ERROR] - Failed to send network data

  • [REQ_ERR: RECV_ERROR] - Failure with receiving network data

  • [REQ_ERR: BAD_CONTENT_ENCODING] - Unrecognized transfer encoding

  • [REQ_ERR: SSL] - SSL error. You must check Cloudflare settings (section SSL).

  • [REQ_ERR: UNKNOWN] - Unknown error. Check Keitaro logs.

  • Features
  • How to integrate KClient PHP to a website
  • Client initialization
  • Client's methods description
  • How to get the offer link
  • How to Send Postbacks
  • KClient PHP FAQ