Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Becker <halfdan@xnorfz.de>2013-03-13 22:29:10 +0400
committerFabian Becker <halfdan@xnorfz.de>2013-03-13 22:29:10 +0400
commit37914ad57377345dcbbe29293f2eef74b6c77672 (patch)
treede9acbffa64f79820ed59842939f6f66ba255b38 /misc/proxy-hide-piwik-url
parentd8a87d1d933fb2ffd316b746614ac93ec7ec12c9 (diff)
Extract and format description for Piwik Proxy script.
Diffstat (limited to 'misc/proxy-hide-piwik-url')
-rw-r--r--misc/proxy-hide-piwik-url/README.md53
-rw-r--r--misc/proxy-hide-piwik-url/piwik.php58
2 files changed, 61 insertions, 50 deletions
diff --git a/misc/proxy-hide-piwik-url/README.md b/misc/proxy-hide-piwik-url/README.md
new file mode 100644
index 0000000000..9c365201db
--- /dev/null
+++ b/misc/proxy-hide-piwik-url/README.md
@@ -0,0 +1,53 @@
+## 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.
+
+### Requirements
+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"
+
+### How to track trackedsite.com in your Piwik without revealing the Piwik server URL?
+
+1. In your Piwik server, login as Super user
+2. create a user, set the login for example: "UserTrackingAPI"
+3. Assign this user "admin" permission on all websites you wish to track without showing the Piwik URL
+4. Copy the "token_auth" for this user, and paste it below in this file, in $TOKEN_AUTH = "xyz"
+5. In this file, below this help test, edit $PIWIK_URL variable and change http://piwik-server.com/piwik/ with the URL to your Piwik server.
+6. Upload this modified piwik.php file in the website root directory, for example at: http://trackedsite.com/piwik.php
+ This file (http://trackedsite.com/piwik.php) will be called by the Piwik Javascript,
+ instead of calling directly the (secret) Piwik Server URL (http://piwik-server.com/piwik/).
+7. You now need to add the modified Piwik Javascript Code to the footer of your pages at http://trackedsite.com/
+ Go to Piwik > Settings > Websites > Show Javascript Tracking Code.
+ Copy the Javascript snippet. Then, edit this code and change the last lines to the following:
+
+ ```
+ [...]
+ (function() {
+ var u=(("https:" == document.location.protocol) ? "https" : "http") + "://trackedsite.com/";
+ _paq.push(["setTrackerUrl", u+"piwik.php"]);
+ var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
+ g.defer=true; g.async=true; g.src=u+"piwik.php"; s.parentNode.insertBefore(g,s);
+ })();
+ </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
+ * the "piwik.js" becomes "piwik.php" because this piwik.php proxy script will also display and proxy the Javascript file
+ * the <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.
+
+ 8. Paste the modified Piwik Javascript code in your website "trackedsite.com" pages you wish to track.
+ This modified Javascript Code will then track visits/pages/conversions by calling trackedsite.com/piwik.php
+ which will then automatically call your (hidden) Piwik Server URL.
+ 9. Done!
+ 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.
diff --git a/misc/proxy-hide-piwik-url/piwik.php b/misc/proxy-hide-piwik-url/piwik.php
index b1971fdaae..d35099a9ea 100644
--- a/misc/proxy-hide-piwik-url/piwik.php
+++ b/misc/proxy-hide-piwik-url/piwik.php
@@ -1,53 +1,11 @@
<?php
-/*
- == Description ==
- This script allows to track statistics using Piwik, without revealing the
- Piwik Server URL. This is useful for users who track multiple websites
- in the same Piwik server, but don't want to show in the source code of all tracked
- websites the Piwik server URL.
-
- == Requirements ==
- 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"
-
- == How to track trackedsite.com in your Piwik without revealing the Piwik server URL? ==
-
- 1) In your Piwik server, login as Super user
- 2) create a user, set the login for example: "UserTrackingAPI"
- 3) Assign this user "admin" permission on all websites you wish to track without showing the Piwik URL
- 4) Copy the "token_auth" for this user, and paste it below in this file, in $TOKEN_AUTH = "xyz"
- 5) In this file, below this help test, edit $PIWIK_URL variable and change http://piwik-server.com/piwik/ with the URL to your Piwik server.
- 6) Upload this modified piwik.php file in the website root directory, for example at: http://trackedsite.com/piwik.php
- This file (http://trackedsite.com/piwik.php) will be called by the Piwik Javascript,
- instead of calling directly the (secret) Piwik Server URL (http://piwik-server.com/piwik/).
- 7) You now need to add the modified Piwik Javascript Code to the footer of your pages at http://trackedsite.com/
- Go to Piwik > Settings > Websites > Show Javascript Tracking Code.
- Copy the Javascript snippet. Then, edit this code and change the last lines to the following:
- [...]
- (function() {
- var u=(("https:" == document.location.protocol) ? "https" : "http") + "://trackedsite.com/";
- _paq.push(["setTrackerUrl", u+"piwik.php"]);
- var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
- g.defer=true; g.async=true; g.src=u+"piwik.php"; s.parentNode.insertBefore(g,s);
- })();
- </script>
- <!-- End Piwik Code -->
-
- What's changed in this code snippet compared to the normal Piwik code?
- A) the (secret) Piwik URL is now replaced by your website URL
- B) the "piwik.js" becomes "piwik.php" because this piwik.php proxy script will also display and proxy the Javascript file
- C) the <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.
- 8) Paste the modified Piwik Javascript code in your website "trackedsite.com" pages you wish to track.
- This modified Javascript Code will then track visits/pages/conversions by calling trackedsite.com/piwik.php
- which will then automatically call your (hidden) Piwik Server URL.
- 9) Done!
- 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.
-*/
+/**
+ * Piwik - Open source web analytics
+ * Piwik Proxy Hide URL
+ *
+ * @link http://piwik.org/faq/how-to/#faq_132
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
// Edit the line below, and replace http://piwik-server.com/piwik/
// with your Piwik URL ending with a slash.
@@ -103,7 +61,7 @@ foreach($_GET as $key=>$value) {
header("Content-Type: image/gif");
$stream_options = array('http' => array(
'user_agent' => @$_SERVER['HTTP_USER_AGENT'],
- 'header' => sprintf("Accept-Language: %s%s\r\n", @str_replace(array("\n","\t","\r"), $_SERVER['HTTP_ACCEPT_LANGUAGE'])),
+ 'header' => sprintf("Accept-Language: %s%s\r\n", @str_replace(array("\n","\t","\r"), "", $_SERVER['HTTP_ACCEPT_LANGUAGE'])),
'timeout' => $timeout
));
$ctx = stream_context_create($stream_options);