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

Added more functionalities: custom piwik.js, piwik.php and _paq JS #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

brusch
Copy link

@brusch brusch commented Apr 18, 2016

Added the possibility to customize the name of piwik.js, piwik.php, the _paq JS variable.

See also:

image

@jbrule
Copy link
Owner

jbrule commented Apr 18, 2016

Thank you for the code contrib. I'll give it a run through and see how it works. I assume the main desire of these options is to avoid detection by ad blockers?

@brusch
Copy link
Author

brusch commented Apr 18, 2016

Yep, correctly :-) Thanks!

$trackingCode = str_replace("piwik.php", $settings["piwikPhp"], $trackingCode);
}

file_put_contents($trackingCodeFile, $trackingCode);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes webserver has write permissions to file. Need to check permissions or handle failure and provide instruction to user. User would need to either SSH in to do the process manually or set write perm for web server process.

@jbrule
Copy link
Owner

jbrule commented Apr 25, 2016

Bernhard,

I'm been testing this out and it looks like omitting /piwik/, piwik.js, and piwik.php from the URL does the trick of avoiding getting blocked by the EasyPrivacy list using Ublock Origin and Adblock+. I'm not sure, at least at this point, if rewriting the piwik.js file is necessary. I think a cleaner approach would be to have the plugin create symlinks to piwik.js and piwik.php with the new filenames.

Do you know of blocklists/programs that analyze the piwik.js file was may block if it isn't rewritten?

There are some other issues to address

  • The patch currently assumes the webserver process has write access to the piwik.js to the Piwik root directory and files which may not be the case. Manual instruction for creating symlinks may be required in that case.
  • The log analytics tool requires an extra param for setting a non-standard tracker file name (I use log-analytics in Production as I can scale it higher that real-time). Some hint setting this option should be provided.

Thank you,
Josh

@brusch
Copy link
Author

brusch commented Apr 26, 2016

Hi Josh,

Thanks for your feedback!
Regarding your question about rewriting piwik.js:
The primary intention of this feature is to allow multiple Piwik trackers on the same page, without using a different tracking approach as described here: https://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers

So you can still just copy & paste the code as it is and you won't face any issues caused by overwriting the _paq JS variable.
But maybe it is also a helpful feature in the future to get around AdBlock+, ..., who knows ;-)

I'll provide a fix for the remaining 2 issues as soon as possible.

@brusch
Copy link
Author

brusch commented Apr 26, 2016

Just pushed the fixes and some more optimizations.

This is how it looks when /piwik.js is not writable:
image

@jbrule
Copy link
Owner

jbrule commented Sep 2, 2016

I see 2.16.2 added some functionality to the Javascript API to allows easier setup of multiple trackers. Does that help your use case any?

@brusch
Copy link
Author

brusch commented Sep 5, 2016

Yep, I've seen this too, but my primary intention was to allow careless copy & paste as well as bypassing known tracking blockers. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants