Piwik Proxy Hide URL
This script allows to track statistics using Piwik, without revealing the
Piwik Server URL. This is useful for users who track multiple websites
on the same Piwik server, but don’t want to show the Piwik server URL in
the source code of all tracked websites.
To run this properly you will need
- Piwik server latest version
- One or several website(s) to track with this Piwik server, for example http://trackedsite.com
- The website to track must run on a server with PHP5 support
- In your php.ini you must check that the following is set:
allow_url_fopen = On
- In your Piwik server, login as Super user
- create a user, set the login for example: “UserTrackingAPI”
- Assign this user “admin” permission on all websites you wish to track without showing the Piwik URL
- Copy the “token_auth” for this user, and paste it below in this file, in
$TOKEN_AUTH = "xyz"
- In this file, below this help test, edit $PIWIK_URL variable and change http://your-piwik-domain.example.org/piwik/ with the URL to your Piwik server.
- Upload this modified piwik.php file in the website root directory, for example at: http://trackedsite.com/piwik.php
instead of calling directly the (secret) Piwik Server URL (http://your-piwik-domain.example.org/piwik/).
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script");
<!-- End Piwik Code -->
What’s changed in this code snippet compared to the normal Piwik code?
- the (secret) Piwik URL is now replaced by your website URL
<noscript> part of the code at the end is removed,
since it is not currently used by Piwik, and it contains the (secret) Piwik URL which you want to hide.
- make sure to replace trackedsite-id with your idsite again.
which will then automatically call your (hidden) Piwik Server URL.
At this stage, example.com should be tracked by your Piwik without showing the Piwik server URL.
Repeat the steps 6, 7 and 8 for each website you wish to track in Piwik.