# Click API Client

# How to Integrate KClient PHP to a Website

  1. Go to Keitaro and open the campaign page.
  2. Now press “Integration” button.
  3. Choose there KClient PHP and follow the instructions.
  4. Insert the code to the index.html file. Put it in the very beginning of a file.
  5. change .html extension to .php > index.php

# 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->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 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
$client->restoreFromQuery() Catches query params _subid and _token without creating new click
$client->restoreFromSession() Restores previous click data from session without creating new click

# Token

To make a request to API you must send “token” to the campaign. You can take it from the campaign's settings page,at the bottom of the page on the left.

# Request Example

curl "http://keitaro.soft.project/click_api/v3?token=ebd928ea"

# Parameters

  • ip — IP address of the IPv4 type
  • user_agent
  • language
  • landing_id
  • uniqueness_cookie — current contents of the cookie
  • log — if you need the log of a click processing (1 or 0)
  • info — return info block (1 or 0)
  • force_redirect_offer — performs offer direct if it is chosen (1 or 0)

# Response

Response is returned in JSON format. Its attributes are:

Attribute Type Description
headers array Array of header responses
body string Body of the response (for example, the page text)
contentType string Response type (In the case of json it is "application/json; charset=utf-8")
uniqueness_cookie string Cookie that you must send in further requests to Click API
cookies_ttl int How many hours to store cookies on website side
log array Contents of the click processing log
info object Container with information by click
info.sub_id string
info.campaign_id int
info.stream_id int
info.landing_id int
info.offer_id array
info.token string
info.uniqueness array
info.uniqueness.campaign boolean
info.uniqueness.stream boolean
info.uniqueness.global boolean
info.is_bot boolean

# Response

curl "http://tracker.com/click_api/v3?token=ebd928ea&log=1&info=1"

    "body": null,
    "contentType": "text/html; charset=utf-8",
    "headers": [
        "Location: http://domain.com/?data=&utm-campaign=aff1"
    "info": {
        "campaign_id": 2,
        "stream_id": 1117,
        "sub_id": "o2q6e42hs08jq",
        "type": "location",
        "url": "http://domain.com/?data=$keyword&utm-campaign=aff1"
    "log": [
        "Processing campaign 2",
        "Referrer: ",
        "Source: ",
        "Keyword: ",
        "UserAgent: HTTPie/0.6.0",
        "Language: ",
        "Is unique in campaign: no",
        "Checking stream #1282",
        "Filter  \"uniqueness\": allow",
        "Filter \"uniqueness\": rejected",
        "Checking stream #1343",
        "Filter \"region\": rejected",
        "Checking stream #1355",
        "Filter  \"limit\": allow",
        "Filter \"ip\": rejected",
        "Checking stream #1117",
        "Accepted by filters",
        "Stream #1117",
        "Send headers: Location: http://domain.com/?data=&utm-campaign=aff1",
        "[Profiler] 0.101 sec.  1 sql queries, 9MB (+7MB)"
    "uniqueness_cookie": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1wic3RyZWFtc1wiOntcIjExMTdcIjoxNDkwNzA1MTQyfSxcImNhbXBhaWduc1wiOntcIjJcIjoxNDkwNzA1MTQyfSxcInRpbWVcIjoxNDkwNzA1MTQyfSJ9._u5H9oOOdyp02VTnDN8VG47oLDoqRHHKyYI3ChxRqw8"
Last Updated: 7/23/2020, 6:24:44 AM