Selective recordings
From ClickTale Wiki
Contents |
[edit] Selective recording via URL parameter
This method is particularly useful for preventing you or others (such as your company staff) from generating recordings on your ClickTale account, thus saving credits and reducing irrelevant information. Forcing a recording can also help you test ClickTale as it lets you see results faster, without waiting for visitors to arrive and generate recordings based on the tracking code's recording ratio.
If your website's URL is http://www.example.com/ then:
- To force a recording, visit http://www.example.com/?ct=enable.
- To disable recording, visit http://www.example.com/?ct=disable.
The above calls will set a persistent cookie to keep track of your selection. You will be recorded or not recorded for as long as the cookie is in place (subject to recording quota).
Please note: If your domain is not checked in "Domain Management" page in your account, then the recording will be blocked even though the status window will report that recording has started.
[edit] The debug parameter
Adding the debug parameter opens a window which enables you to view the recording initialization process. It can also be used in conjunction with the parameters listed above:
- http://www.example.com/?ct=enable,debug.
- http://www.example.com/?ct=disable,debug.
[edit] Selective recording via PHP control script
The ClickTale PHP control script is intended to help you filter the visitors you want to record. It allows you to set filters based on the following visitor metrics:
- Time
- Day of the week
- IP address (including IP mask)
- Country
- Referrer
- URL
The filters can control which visitors are being recorded and which are not.
For more information, please see the PHP control script page.
[edit] Advanced selective recording via customized tracking code
The following example is of a tracking code which records or does not record based on the page URL, however it can be modified to use any visitor parameter which can be discerned during the visit (such as browser, referrer, etc.).
Please note: This code alters the tracking code's recording ratio. The ratio is only taken into account when the visitor is not classified (has no WRUID cookie), if a visitor arrives at a page with a WRUID value of !=0 he will be recorded, even if the recording ratio is 0. And similarly if a visitor arrives at a page with a WRUID value of 0 he will not be recorded, even if the recording ratio is !=0.
So used alone (without an additional code) , this code is useful in situations where you want different ratio for different landing pages for your website (so for instance 95% of visitors arriving from landing page A will be recorded, while only 15% of visitors arriving from landing page B).
Instead of your regular bottom part, place this:
<!-- ClickTale Bottom part -->
<div id="ClickTaleDiv" style="display: none;"></div>
<script src="http://s.clicktale.net/WRb.js" type="text/javascript"></script>
<script type="text/javascript">
function escapeRegex(text) {
if (!arguments.callee.sRE) {
var specials = [
'/', '.', '*', '+', '?', '|',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('|\\') + ')', 'g'
);
}
return text.replace(arguments.callee.sRE, '\\$1');
}
function urlPathIs(urls) {
/// <summary>Check if the current url matches any of the given urls passed</summary>
/// <param name="urls" type="Array[String]|String">A url or an array of urls to test against</param>
/// <returns type="Boolean">True if the the current location matches any of the passed urls, false otherwise</returns>
if(arguments.length > 1) {
urls = Array.prototype.slice.call(arguments, 0);
}
if(typeof urls == "string") {
urls = [urls];
}
var escapedUrls = [],
regexp;
for(var i = 0; i < urls.length; i++) {
escapedUrls.push(escapeRegex(urls[i]));
}
regexp = new RegExp("^(?:"+escapedUrls.join("|")+")/?(?:\\?|$|#)","i");
return regexp.test(window.location.href);
}
The next stage is to continue the bottom part with if/else statements (or a switch statement) which determines the recording ratio according to the current URL. This next bit is an example of a user who wants to record 100% of visitors to his homepage and his contact page, and non of the visitors to other pages. You can also set other value to the recording ratio.
var recordingratio = 0;
if (urlPathIs ("http://domain.com","http://www.domain.com","http://domain.com/contact","http://www.domain.com/contact")) {
recordingratio = 1;
}
Finally, once the ratio is determined, you can place it in the recording function as it appears on your original tracking code (in this case it's for a regular page, https pages and other special cases require a different code but the concept is the same):
if(typeof ClickTale=='function' && recordingratio>0) ClickTale([!YOUR PROJECT ID!],recordingratio,[!PARTITION!]); </script> <!-- ClickTale end of Bottom part -->
The [!YOUR PROJECT ID!] and [!PARTITION!] parameters should be replaced with the ones that appear in your regular tracking code.

