Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

piwik.js: Add option to override special css classes to ignore #5668

Closed
zawadzinski opened this issue Jun 8, 2008 · 3 comments
Closed

piwik.js: Add option to override special css classes to ignore #5668

zawadzinski opened this issue Jun 8, 2008 · 3 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone

Comments

@zawadzinski
Copy link
Contributor

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
Copy link
Contributor

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_ignoreclasses[i];
+ _pk_ignore_regexp = ‘)(?: |$)’;
+
+ var pk_class = new RegExp(_pk_ignoreregexp);
+
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
Copy link
Member

mattab commented Jan 14, 2009

vipsoft, looks good. you added

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

Thanks

@mattab
Copy link
Member

mattab commented Feb 11, 2009

thanks for patch vipsoft; see 887

I added following documentation in the [javascript tracking page](http://piwik.org/docs/javascript-tracking/); 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);
[…]

@zawadzinski zawadzinski added this to the RobotRock milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

3 participants