@zawadzinski opened this issue on June 8th 2008

We can customize Piwik in different ways (http://piwik.org/javascript-tag-documentation/), but we can add further options: - define an array of css class names that we do not track (outlink tracking - now we can use only default 'piwik_ignore' option) - we can do the same with 'piwik_download' and 'piwik_link'

eg. Everytime a visitor clicks on one of my image gallery images it gets counted as a "download". I cannot easily force them away from downloads because they do not use special "class" attributes, but they do use rel="lightbox". It would be nice to specify rel="lightbox" as not being downloads in piwik js settings.

@robocoder commented on January 12th 2009

Something along the lines of this patch?

+       var _pk_ignore_regexp = '(?:^| )(piwik_ignore';
+       for( var i=0; i < piwik_ignore_classes.length; i++)
+               _pk_ignore_regexp += '|' + piwik_ignore_classes[i];
+       _pk_ignore_regexp += ')(?: |$)';
+
+       var _pk_class = new RegExp(_pk_ignore_regexp);
+
        if (document.getElementsByTagName) {
                linksElements = document.getElementsByTagName('a')
                for (var i = 0; i < linksElements.length; i++) {
-               if( linksElements[i].className != 'piwik_ignore' )
-                       _pk_add_event(linksElements[i], 'mousedown', _pk_click, false);
+                       if( !_pk_class.exec( linksElements[i].className ) )
+                               _pk_add_event(linksElements[i], 'mousedown', _pk_click, false);
                }
        }
@mattab commented on January 14th 2009

vipsoft, looks good. you added

can you please provide full patch, as well as adding a test case in misc/testJavascriptTracker/ ?

Thanks

@mattab commented on February 11th 2009

thanks for patch vipsoft; see [887]

I added following documentation in the javascript tracking page; please let me know if this is accurate.

Disable the download & outlink tracking for specific CSS classes

You can disable automatic download and outlink tracking for links with specific CSS classes:

[...] piwik_url = http://yourwebsite/piwik/piwik.php; // do not track links <a href= class=no-tracking> piwik_ignore_classes = ["no-tracking"]; piwik_log(piwik_action_name, piwik_idsite, piwik_url); [...]

This issue was closed on August 4th 2009
Powered by GitHub Issue Mirror