-
Notifications
You must be signed in to change notification settings - Fork 46
added proxy feature for Matomo Tag Manager #79
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| RewriteEngine On | ||
|
|
||
| RewriteRule ^(.*)\.js$ index.php | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <?php | ||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * Matomo Proxy Hide URL | ||
| * | ||
| * @link https://matomo.org/faq/how-to/#faq_132 | ||
| * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
| $configFile = __DIR__ . '/../config.php'; | ||
| if (file_exists($configFile)) { | ||
| include $configFile; | ||
| } | ||
|
|
||
| $calledJsFile = $_SERVER['REQUEST_URI']; | ||
|
|
||
| if (strpos($calledJsFile, 'js') === false) { | ||
| exit(); | ||
| } | ||
|
|
||
| // ----- | ||
| // Important: read the instructions in README.md or at: | ||
| // https://github.com/matomo-org/tracker-proxy#matomo-tracker-proxy | ||
| // ----- | ||
| //// FALLBACK CONFIG IF config.php IS NOT USED | ||
|
|
||
| // Edit the line below, and replace http://your-matomo-domain.example.org/matomo/ | ||
| // with your Matomo URL ending with a slash. | ||
| // This URL will never be revealed to visitors or search engines. | ||
| if (! isset($MATOMO_URL)) { | ||
| $MATOMO_URL = 'http://your-matomo-domain.example.org/matomo/'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| if (! isset($MATOMO_URL)) { | ||
| $MATOMO_TRUSTED_URLS = [ | ||
| // Edit the lines below, and replace http://your-matomo-domain.example.org/matomo/ | ||
| // with your Matomo URL ending with a slash. | ||
| // Also add any other trusted_hosts[] - config you have in config/config.ini.php | ||
| // These URLs will never be revealed to visitors or search engines using the tag manager. | ||
| 'http://your-matomo-domain.example.org/matomo/' | ||
| ]; | ||
| } | ||
|
|
||
| // Edit the line below and replace http://your-tracker-proxy.org/ with the URL to your tracker-proxy | ||
| // setup. This URL will be used in Matomo output that contains the Matomo URL, so your Matomo is effectively | ||
| // hidden. | ||
| if (! isset($PROXY_URL)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here this should also be part of config |
||
| $PROXY_URL = 'http://your-tracker-proxy.org/'; | ||
| } | ||
|
|
||
| $fileName = $MATOMO_URL . $calledJsFile; | ||
| $fileContent = file_get_contents($fileName); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check file exists too ? |
||
|
|
||
| echo str_replace($MATOMO_TRUSTED_URLS, $PROXY_URL, $fileContent); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we add a rule for a specific js ?