• Extensions
  • FriendsOfFlarum Analytics - tracking user visits

FriendsOfFlarum Analytics

MIT license Latest Stable Version Total Downloads OpenCollective

A Flarum extension that adds Google or Matomo analytics features to your forum.

Screenshot

Google Analytics

Piwik

Imgur

Goals

  • Allow Google and Matomo analytics service.
  • Use Google Optimise to quickly understand how your community can be improved.

Installation

composer require fof/analytics:*

Configuration

  • Matomo's URL should not end with an /, ex: domain.com or domain.com/matomo.
  • Visit the admin panel to configure your analytics services.
  • If enabled, visit the Analytics page in admin to see your Matomo analytics results.

Links

An extension by FriendsOfFlarum.

    Awesome! Been hoping for a piwik extension

    Installed fine and activated.
    I see in the html

        <script type="text/javascript">
      var _paq = _paq || [];
      //1st
      _paq.push(['setDocumentTitle', document.domain + '/' + document.title]);
      //3rd
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="//domain.tld/";
        _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.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <noscript><p><img src="//domain.tld/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>

    From this part -> _paq.push(['setSiteId', 1]);
    It looks like it defaults to being set as SiteId 1
    I'm tracking multiple sites and my flarum one is currently site ID 4 (according to my piwik admin spot)

    Looking at my "tracking code" in the piwik admin it shows this: (notice the site id is 4)

    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="//domain.tld/";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', 4]);
        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.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <noscript><p><img src="//domain.tld/piwik.php?idsite=4" style="border:0;" alt="" /></p></noscript>
    <!-- End Piwik Code -->

    So unfortunately this won't work for me atm 🙁
    However! if you're just tracking one site it should default to site id 1 and be fine.

      luceos changed the title to Flagrow analytics extension - tracking user visits .
      11 days later
      9 days later

      santiagobiali I successfully got it working!
      With piwik, If you're using a https flarum install and sending the tracking through http for the piwik.js, it won't work.
      Had to get a cert for my piwik install so it could use https and suddenly everything worked ?

      Also, site id works perfectly!

        Kulga thanks for the reply.
        The extension uses the same protocol of the forum, if you are using https you browser blocks http connections as a safety measure.

        Glad you got it working ?

        0.3.3 is out.

        Great Changes, a page in admin was added, it shows piwik's(only, for now) dashboard in flarum.
        You can add/remove/move the blocks and let it the way you want!

          Looks like it uses Widgetize in Piwik

          Display any Piwik report in your website or app with a simple Embed HTML tag.

          Despite the user being used (per the auth token) I notice it only displays the correct (current) site even though it has view permissions for other sites. That's really good ?

            Kulga it choses the site by the site Id that is being used to display the tracker in the forum. So it displays the dashboard of the forum that the extension is tracking.

              17 days later

              Just a suggestion: a good choice for the next integration might be https://segment.com/

              We use them to send tracking data to a bunch of services simultaneously. They've gotten extremely popular in the startup world, and it would allow you to say you support "all" of the analytics providers for people who are willing to use a 3rd party service.

              They're also open source, so integration is pretty simple, e.g.:

                5 days later

                No problem! Thanks for all of your hard work, Flarum is really looking great.