Page Tracking setup
Insert in every web page head (just before the closing </HEAD>; tag) the following Javascript tracking code
<!-- squidanalytics tracker (v1.8) -->
<script type="text/javascript">
var sqtrkq = sqtrkq || [];
(function() {
var sqtrk =
document.createElement('script');
sqtrk.id="sqtrk"; sqtrk.type =
'text/javascript'; sqtrk.async = true;
sqtrk.src = (("https:" ==
document.location.protocol) ? "https" :
"http")+"://aws.tracker.squidanalytics.com/js/t
racker.js";
var selm =
document.getElementsByTagName('script')[0];
selm.parentNode.insertBefore(sqtrk, selm);
})();
<!-- Mandatory parameters -->
sqtrkq.push(['wid', '...']);
var u = new URI(document.location.href);
sqtrkq.push(['dom', '.' + u.domain()]);
<!-- optional parameters, to be call if relevant -->
sqtrkq.push(['uid', 'userId or AccountId for example']);
sqtrkq.push(['post', true|false]);
sqtrkq.push(['ext', encodeURIComponent(jsonString)]);
<!-- Call to the tracker -->
sqtrkq.push(['track']);
</script>
<!-- end squidanalytics tracker -->
This tracking code must be configured:
wid : site account id (provided by squid): different ids for prod, preprod or dev sites to be requested to Squid
dom : the domain to track users on. Typically, this should be your primary domain name prefixed with a dot (ex: ".squidsolutions.com ") which will track users on all your subdomains . Leaving it blank will restrict the tracking to the current subdomain where the page was loaded from, & generate single event sessions. We use the library URI.js to get this domain, in the code above
uid : (optional) user id (you may put here an id associated to the current logged user)
post : (optional) true or false to enable POST requests (handling large requests data). Default is false
ext : (optional) an extra field used to pass extra information to our tracker, preferably a set of key-value pairs sent as a json string or as a URL query string, URI encoded
Automatic Page tracking
Adding this tag in every page, & last, pushing 'track' generates a tracking event, considered as a page display.
Use of extra fields
Examples use of extra fields: categorize pages, give context additional information (account, content, interactions). Please refer to the tracking rules below for normalized information codes
Handling Ad-Blockers
Ad-Blockers are more & more used & most popular ones block by default our tracker. A good way to bypass these restriction is to reverse proxy our 2 resources tracker.js & t.gif between a domain you hosts & our tracker domain aws.tracker.squidanalytics.com
Please find a sample configuration to be added in a vhost on Apache:
Setting the configuration (Apache)
SSLProxyEngine On SSLProxyCheckPeerCN on SSLProxyCheckPeerExpire on RemoteIPHeader X-Forwarded-For ProxyPass "/js/tracker.js" "https://aws.tracker.squidanalytics.com/js/tracker.js" ProxyPass "/t.gif" "https://aws.tracker.squidanalytics.com/t.gif"
Once this has been added to the vhost config, please release it (shell commands):
Activate configuration
a2enmod proxy_http ssl remoteip service apache2 restart
Implementation
Modify the variable sqtrk.src in the script above accordingly to uses the domain configured for your vhost defining the reverse proxy
Event Tracking setup
In addition of the above code, you can implement event based tracking (panel activation, click event, redirect) by adding following type of function & calling it during clicks processing or other interactions you would like to record
JavaScript
<!-- squidanalytics tracker (v1.8) -->
<script type="text/javascript">
function sqclick(data) {
try {
<!-- Generate a json string giving event details-->
jsonString = ...
sqtrkq.push(['event', encodeURIComponent(jsonString)]);
} catch (err) {}
}
</script>
<!-- end squidanalytics tracker -->
jsonString: used to pass event information to our tracker, preferably a set of key-value pairs sent as a json string.
Event tracking vs Page tracking
Pushing 'event' generates a tracking event. Without setting the element 'mut' in the jsonString, (see Tracking rules), this hit is counted as a page display event. Please take this in account if you want to consider an event also as a page load or not.
Also don't forget to setup 'mact' element to indicates what is the interaction you want to record
You should also recall any other element provided at page load (page classification, content, etc ...) so the whole context is recorded in the event