# KClient JS
KClient JS works the following way:
- KClient JS requests the campaign from the tracker.
- KClient JS tries to execute the stream action. It can be a landing page.
As a result, a new content is displayed on the original site under the same domain.
The script is suitable for online site builders, where it is not possible to use KClient PHP
# Getting KClient JS
- Go to Integrations tab in a campaign's settings.
- Select "KClient JS".
KClient JS is available only if campaign is assigned to a domain with HTTPS feature.
After you select KClient JS solution on Integrations tab you'll see basic settings:
- Save only unique clicks - this feature allows saving only unique clicks in Keitaro stats.
- Convert to base64 - converts integration code to base64 which makes the code unique and protects the code from blocking with browser extensions.
- Integration Code - the final piece of the code you need to insert
If Save only unique clicks is turned on, and you need to test your campaign, add to the page URL new parameter
# Integrating with site builders
Open your store and go to Themes → Actions → Edit code.
Select the page you need in the menu on the left. In case you need the main page, select theme.liquid.
Add the code from Keitaro to
Save the changes. The campaign is integrated.
Create your page, and go to the Settings → General →Insert HTML code:
Use plain JS
Opt-out Convert to base64 option before coping the integration code.
Save the changes.
Create your site and open the list of the pages, click Settings
Go to Additional page and scroll down to HTML code to add inside HEAD field.
Add the JS code.
This feature is available only for paid plans:
After adding the code publish the changes.
Create your site and go to Settings in the upper menu.
Click Code Injection and check Before closing tag.
Import your code here:
# GitHub Pages
Create a new repository.
Open Index and insert JS code:
Save and deploy. Now, when somebody opens a page from your repository, JS code will be executed.
# KClient JS FAQ
How to filter bots?
The basis of the standard case includes a campaign with two streams, where the first stream will have filters for bots and the action "Do nothing", which will leave the bot on the site where the script is put. The second stream with the target action, for example local landing page.
In the "Bot Protection" stream add any set of filters to catch bots.
In "Stream 2" add the target action. If a local landing page is selected in the stream, then this landing page, or offer will be uploaded to your site with integration without redirecting and changing the domain for the traffic which does not get into the bot stream.
What are the incompatible site builders?
Nothing happens while visiting the site with the code
First, go to your campaign in Keitaro, click the Log button above the streams and check if there is a record of your click. If the log is empty that means there's no any inquiries to Keitaro, JS is not executed.
Make sure you put the integration code correctly. The code must be inserted to
<head> tag. Check if there are
mistakes, if you added extra characters when copying, or if there are symbols not allowed for JS.
Also make sure that the site and the tracker have domains with SSL certificates installed (the work is carried out within the HTTPS protocol) and the JS script in the tracker was generated with the ssl domain (that means you use https domain in Keitaro as default).
The click is recorded in Keitaro log, but nothing happens when visiting the site
Read the traffic log and check if the click got to the necessary stream, and whether the action which the click performed coincides with the one you set in the stream. If the log says that there was a redirect, but in fact it wasn't there, or it worked incorrectly (the site loaded without styles or with a floating layout), then make sure that you work with HTTPS protocols in both cases (the site and the tracker).
Eternal redirect when you visit a site with KClient JS
Check the streams if there is a link to your site with integration. This site URL shouldn't be added to a stream. This causes an eternal redirect, since the visit to the site launches your campaign, in which the stream again contains a link to the site with the KClient JS code. It turns out to be a vicious circle.
MIXED CONTENT error in a browser console when visit a site with KClient JS
Make sure that you work with HTTPS protocols in both cases (the site and the tracker). If #1 does not help, check the browser console and find the resources that are used with http, and change their URLs to HTTPS If you work with a domain through Cloudflare, make sure that "Flexible or Full" settings of SSL are set in CloudFlare configuration.
CORS error in browser console, incorrect site loading
Open Maintenance > Status > Installation method. If the version is lower than 2.12 you need to upgrade your server's configuration.
Connect to your server via ssh and run the command:
curl https://keitaro.io/install.sh > run; bash run -rt upgrade