Click API Client


  • Passing information about the current visitor to Keitaro;
  • Passing parameters from the address bar;
  • Processing and execution of Keitaro instructions: displaying a text, executing a redirect;

How to Integrate Click API Client v2 to a Website?

  1. Go to Keitaro and open the campaign page.
  2. Now press “Integration” button.
  3. Choose there “Click API Client v2” and follow the instructions.

Client Initialization

Here is an example of initialization KClickClient class.

require_once 'kclick_client.php'; // file must be uploaded into the same directory as the page  
$client = new KClickClient('API address', 'campaign token');

Description of methods

Method Description
$client->sendAllParams(); Passing parameters from address bar
$client->params('param1=c&param2=b'); Passing string parameters
$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 value 'KEYWORD' 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->getSubId(); Returns SubId
$client->getBody(); Get 'body' value
$client->getHeaders(); Get 'headers' value (array)
$client->isUnique(level); Uniqueness (level variations: stream, campaign, global)
$client->isBot(); Bot status

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

require_once 'kclick_client.php'; 
$client = new KClickClient('http://example.con/api.php', 'token');
$offerLink = $client->getOffer();
<a href="<?php echo $offerLink ?>">CLICK!</a>

You have to assign offers and one landing page to the stream.

How to Make Link for Particular Offer?

require_once 'kclick_client.php'; 
$client = new KClickClient('http://example.con/api.php', 'token');
<a href="<?php echo $client->getOffer(['offer_id' => 123]) ?>">CLICK!</a>

How to Send Postbacks?

To get your postback your, add new affiliate network. You'll get there the postback URL.

On your website, call this code to send a postback

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

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

Instead of using $client->execute(); use $client->getContent(). Example

<?php echo $client->getContent() ?>

How to Integrate KClick Client with Wordpress?

  1. Upload file “kclick_client.php” to home directory of wordpress website.
  2. Copy and paste the initialization code to the file index.php at the beginning.
  3. Choose the more appropriate for you case:
    • If you want to call redirects, use code $client->executeAndBreak(); in “index.php”.
    • If you need to show any contents in some website block. For example, banners. Use execute(); ?> in your templates file.

In case you want to call Keitaro only in single post, add to header.php of your wordpress theme

$postIds = array(100, 200, 300);  // Posts IDs
if (is_single() && in_array(get_the_id(), $postIds)) { 

How to Leave users on the Website?

Use action “Do Nothing” in the stream.