How do I integrate the Tsuiseki Tracking into my PHP site?
Conditions
Necessary conditions for a successful integration of Tsuiseki:
- No Javascript error on the website, otherwise Tsuiseki will not run correctly.
- The Tsuiseki Key should have been delivered by us and will be entered into the configuration file.
- Links that are to be logged, should have a CSS class or a CSS ID.
Integration in 3 steps
Step 1
Download the PHP integration files (
http://tsuiseki.com/plugins/xajax/tsuiseki_xajax-1.0.tar.gz).
Step 2
Place the PHP integration files in a folder that your website has access to, e.g.
Step 3
Edit your main template file or all files Tsuiseki will be integrated in.
- If no session has been started at this point, add the following code at first:
<?php session_start(); ?>
- Now the Tsuiseki PHP files have to be reloaded, therefore add this code to the files:
<?php
require('js/xajax_core/xajaxAIO.inc.php');
require('inc/tsuiseki.inc.php');
tsuiseki_tracking_buffer_data();
?>
- Then XAjax has to be configuered:
<?php
$xajax = new xajax();
$xajax->setFlag('debug', false);
$xajax->configure('javascript URI', 'js');
$xajax->register(XAJAX_FUNCTION,'tsuiseki_tracking_click');
$xajax->register(XAJAX_FUNCTION,'tsuiseki_tracking_view');
$xajax->processRequest();
?>
- Now the Javascript files of Tsuiseki are reloaded and the call within the HTML header of the website will be started:
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/tsuiseki_tracking.js"></script>
<?php $xajax->printJavascript(); ?>
<?php tsuiseki_tracking_generate_javascript(); ?>
</head>
- Generate the block for the tracking of tsuiseki views at the end of the page:
<?php tsuiseki_tracking_generate_block(); ?>
See the
complete example here.
After loading the website all views and all clicks on the configured links will be logged.
The Tsuiseki import only runs once an hour, that is why you see your data on Tsuiseki with up to one hour delay.
Configuration
To use Tsuiseki correctly, it has to be adapted to your website. You can make various settings that will now be addressed briefly. All settings available, can be found in this file:
inc/tsuiseki.inc.php.
- The Tsuiseki Key has to be entered at TSUISEKI_TRACKER_KEY. You should have received that key from us.
- Then you define which links should be logged (as a CSS selector, e.g. 'a.tsuiseki,a.products'), several selectors can be separated with a comma.
Default: a.tsuiseki-link
- The TSUISEKI_TRACKER_HMAC_KEY has to be changed. Therefor type in a combination of (exactly 64) letters, numbers and characters. This serves the security of the cookies.
- If you don't want Tsuiseki to be loaded on certain sites, you can enter those URLs in the array: $tsuiseki_excluded_uris (e.g. mydereferer/out.php or administration/*).
- The network parameters (to identify traffic from one network) can be adapted in this function:
_tsuiseki_tracking_get_network_names.
Just change the name of the parameter or add more.
Default: site (e.g. url.de?site=google-search).
- You can adapt the identification of sub-affiliates of a network in this function:
_tsuiseki_tracking_get_partner_id_names.
If these occur together, they are combined and stored with a dash.
Default: ref, quelle (e.g. url.de?ref=foo&quelle=bar).
- The keyword parameters (searchquery) can be adapted in this function:
_tsuiseki_tracking_get_query_names.
Default: qe, target_passthrough, query (e.g. url.de?query=apple).
Causes of Errors
If your data do not appear on https://tsuiseki.com within one hour, this may have one of the following causes:
- Are all paths correct? Look up the source code of your website and see if there were any errors and if everything is loaded correctly.
- Is your Tsuiseki Key correct? Maybe it was not entered completely?
- Is Tsuiseki configured correctly? Does Tsuiseki load in the actual website or has it been blocked at $tsuiseki_excluded_uris?