Support » Plugin: Tracking code for Matomo, by Sergio Santos » Enabling the use of the piwik.php proxy to hide Piwik host

  • Resolved batteriesInc

    (@batteriesinc)


    Hi,

    Wonderfully simple plugin – it took but seconds to install and get working because it just uses the site ID. Recommended.

    One question, though: would it be possible to add an option to use the Piwik proxy “piwik.php” (as shown on the Piwik site)? That way, the tracker does not give away the location of the server that collects the statistics.

    Thnx!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi, @batteriesinc !

    Thanks for the review! (Perhaps you meant to write it here, though?)

    Interesting request. I didn’t know one could do that with Piwik, but i totally agree it’s something important. (The documentation you refer to is here and here, right?)

    There is another feature request i plan to implement as soon as possible. I’ll see if i can implement the proxy feature too. I just ask that you be patient, as i have a lot on my plate right now – it may take weeks before i can look into this.

    Thanks for the feedback!

    Cheers,
    @sergiorcs

    Hi Sergio,

    Thanks for the quick reply :).

    1 – the review is well earned, and I’m happy to repeat that wherever you want it posted. The “other” WP Piwik implementation gives you a stats panel right in WP but its setup is thus as a consequence more involved (it needs an API Authentication Token for each individual website). Yours could only be simpler if you leave the protocol (http/https) attached to the URL :).

    2 – yes, correct, that’s the piwik.php proxy script I was thinking of, but it needs all sorts of API token shenanigans to work so maybe you could find a simpler but still safe approach for that too.

    As for needing time: hey, it’s holiday season! Relax, and enjoy the sun.

    And thanks for writing this plugin!

    Cheers, Binc

    Hi, @batteriesinc ,

    It’s been a while, i know.

    I’ve had time to give this some deeper consideration over the last few weeks. Here is my trail of thought:

    • “If i were to include the proxy PHP file alongside the plugin’s files, it might be blocked by security measures, like the ones from Sucuri.”
    • “Ok, then perhaps i could do like Wordfence and have my plugin install a file at the root of the website, on demand. But not all servers may allow this kind of thing, and i’d have to write a lot of extra code.”
    • “Maybe i can just check for the presence of a file named “piwik.php” at the root of the website, then. By default, the plugin would display a disabled checkbox on the dashboard; but when said file is present, the option becomes available. That would be simple enough and it could work.”
    • “Then again, though i’d very much like to include this feature on my plugin, very few people have requested it. Plus, i’d like to keep things as simple as possible.”

    I’ve been juggling this in my head. Then, yesterday it hit me: there’s one fairly easy way to have my plugin use the piwik.php proxy, without me having to add any extra feature! Have a look at these here steps:

    1. Follow these steps to create a piwik.php proxy file. (I strongly suggest that you set the config options directly inside piwik.php, to keep everything in one single file.)
    2. As described in the guide, put the PHP file at the root of the website to track.
    3. Ensure that you can access the file on the site, by opening it on your browser. (Don’t expect much of a result. Just see that it’s not a 4xx or 5xx server error page.)
    4. Open the WordPress Dashboard on said site. Browse to my plugin‘s settings page.
    5. Set the “Address” option to the same domain as the website you wish to track. (You should be able to just copy and paste it directly from the browser’s address bar, at that moment.)

    Yup, it’s that simple! (Or not, depending on what you were expecting.)

    Now, if you’re thinking something like “I knew that! I was just hoping for a better solution!” or “Thanks, Captain Obvious. That’s what i’ve been doing.”, that’s just because it’s the simplest, most efficient way to use a proxy with this plugin.

    @batteriesinc, i’m going to mark this as resolved, but that doesn’t mean we can’t keep exchanging ideas on this subject. I can even lend you a hand in implementing this on any of your websites, if you like. (I haven’t tested this procedure as thoroughly as i’d like. Any feedback is welcome.)

    Let me know what you think.

    Cheers,
    @sergiorcs

    PS: If you’re also thinking “How come it took you all this time to reach a solution that seems so simple and obvious?”… well… “i ain’t the sharpest tool in the shed”. 😀

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Enabling the use of the piwik.php proxy to hide Piwik host’ is closed to new replies.