Useful Snippets


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at

RSS Latest posts from my personal blog

Most viewed posts

Subscribe to RSS feed

Hiding Piwik tracker URL by using an PHP script

Stanislav KhromovStanislav Khromov

It’s easy to hide the Piwik tracker URL by proxying it through a PHP script.

First, get the proxy PHP script from here: proxy-hide-piwik-url on Github
(The file is also available in your Piwik install at /piwik/misc/proxy-hide-piwik/piwik.php)

There is great documentation at the link above. Use it to configure the piwik.php file.

The differences that I wanted to accomplish was:

This is done by renaming the script (pi.php) and uploading it to another server (

The resulting JavaScript to put on your page should be as shown below. (The site we’re tracking is, with side id 1)

<script type="text/javascript">
  var _paq = _paq || [];

  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://";
    _paq.push(["setTrackerUrl", ""]);
    _paq.push(["setSiteId", "1"]);
    var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
    g.defer=true; g.async=true; g.src=""; s.parentNode.insertBefore(g,s);

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
Twitter Profile
Visit my other blog

Comments 2