Support » Plugin: WP-Matomo (WP-Piwik) » Built-in tracker proxy

  • It would be very convenient if this WordPress plugin also ships the Matomo tracker proxy.
    Currently, the tracker proxy script files have to be manually placed into site root or
    some other server configuration used for making the tracker proxy available.
    Even better, if the plugin makes the tracker proxy configuration in WordPress available.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author braekling

    (@braekling)

    Hi @strarsis,

    the proxy script is already part of WP-Matomo. If you configure WP-Matomo to add the tracking code, you can choose “use proxy script”. This will change the tracking code to use the included proxy script.

    But it would worth a try to test it and also to compare it to the latest proxy script from Matomo, because I’m not using this myself and so I may miss some changes. Any feedback is appreciated!

    @braekling: So I set up the WP-Matomo plugin to use the proxy script.
    However, the browser is unable to download the file /app/plugins/wp-piwik/proxy/matomo.js, which seems to be a proxy related JavaScript.

    @braekling: Please help! Currently nothing is tracked at all with WP Matomo. 🙁

    Plugin Author braekling

    (@braekling)

    I wonder why the browser tries do download a file in /app/ instead of /wp-content/? And it should be matomo.php or piwik.php instead of matomo.js. Please check the generated tracking code.

    @braekling:
    Injected tracker code:

    <!-- Matomo -->
    <script type="text/javascript">
      var _paq = window._paq || [];
      /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
      _paq.push(['trackPageView']);
    _paq.push(['trackAllContentImpressions']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="//www.example.com/app/plugins/wp-piwik/proxy/"
        _paq.push(['setTrackerUrl', u+'matomo.php']);
        _paq.push(['setSiteId', '2']);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <!-- End Matomo Code -->

    @braekling: Any additional information I could provide to help you debug this issue?
    It would be great if the tracking proxy works properly so Matomo can finally track visitors.

    Plugin Author braekling

    (@braekling)

    Can you explain /app is used instead of your wp-content folder? Maybe this will help to understand what’s happening here.

    This is the code I get when I switch to proxy tracking:

    <!-- Matomo -->
    <script type="text/javascript">
      var _paq = window._paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="//www.example.com/wp-content/plugins/wp-piwik/proxy/"
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', '1']);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.php'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <!-- End Matomo Code -->

    Just to be sure: Are you using the auto-generated code for proxy tracking or did you configure it manually?

    @braekling: The plugin shows an autogenerated code and I haven’t changed it.
    The reason for why /app is used that a roots.io Bedrock WordPress installation is used that changes some paths.
    However, these paths are customizable in WordPress core and the issue probably results from using hardcoded paths instead the right WordPress constants and functions for retrieving the plugin, theme, uploads, etc. folder paths/URLs, see https://developer.wordpress.org/reference/functions/content_url/.

    • This reply was modified 2 weeks, 2 days ago by strarsis.
    Plugin Author braekling

    (@braekling)

    Please have a look at the latest master provided via Github:
    https://github.com/braekling/WP-Matomo/archive/master.zip

    There I added handling for matomo.js/.php files if Matomo does not deliver piwik.js/.php anymore.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.