ClickTale Support Forums

All times are UTC - 6 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Jul 05, 2009 9:22 am 

Joined: Wed Mar 25, 2009 7:17 pm
Posts: 213
Usually, you can just set different tracking codes with different recording ratios on the various pages of your website. But when using content management systems like Joomla or WordPress, the code appears on all pages identically. Other case might also require parsing the URL in order to ascertain the appropriate recording ratio. Here is an example of a code which does this:

Instead of your regular bottom part, place this:
             <!-- ClickTale Bottom part -->
<div id="ClickTaleDiv" style="display: none;"></div>
<script src="" 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 =, 0);
    if(typeof urls == "string") {
        urls = [urls];
    var escapedUrls = [],
    for(var i = 0; i < urls.length; 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 (see for more details).

var recordingratio = 0;

if (urlPathIs ("","","","")) {
    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!]);
<!-- ClickTale end of Bottom part -->

You can also set the ratio by other values, such as the referrer (document.referrer property).

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group