RockAnalytics by bernhard

Module to easily include plausible dashboard into the PW backend

RockAnalytics.svg

Integrate plausible analytics or umami into your ProcessWire backend

68747470733a2f2f692e696d6775722e636f6d2f713749495235562e706e67


Quickstart:

  1. Install the module
  2. Setup plausible analytics (either self hosted or paid cloud)
  3. Copy the tracking code into your site's markup
  4. Copy the share URL to your module's config

hr.svg

Support


https://processwire.com/talk/topic/27322-rockanalytics-integrate-plausible-analytics-into-your-processwire-backend/

hr.svg

Donations


img

hr.svg

About plausible analytics


Plausible is a "simple and privacy-friendly Google Analytics alternative". It is open source and you can either self host it or buy one of their hosted services. A live demo of their dashboard and its features can be found here: https://plausible.io/plausible.io

hr.svg

Tracking Snippet


Tracking Snippet with Opt-Out Feature

GDPR allows collecting anonymous usage data without consent, but you need to provide an opt-out link on your privacy page. RockAnalytics comes with TextformatterRockAnalytics that will automatically render the necessary JS code to toggle tracking by the user (saved in localstorage).

It will turn this:

[rockanalytics-toggle]

...into that:

68747470733a2f2f692e696d6775722e636f6d2f465973734c46412e676966

Simply add [rockanalytics-toggle] to any textfield and apply the TextformatterRockAnalytics Textformatter. You can customise the rendered text (in every installed language) in the module's settings.

If you render the plausible script via the dedicated render() method RockAnalytics will only load the tracking script if the user did not opt out from tracking:

// in your main markup file
echo $modules->get('RockAnalytics')->render([
  'domain' => $config->httpHost, // see description on next section
  'src' => 'https://plausible.yourdomain.com/js/plausible.js',
  'onlyGuests' => true, // only load script for guest users
]);

Manual Snippet

The recommended way is to use the dynamic snippet above! This section is kept for reference

When you add a website to your plausible dashboard it will show you a tracking code that you can paste into your site that you want to track. This is what I use to make sure that we only track users on the live site (not on local development) and only logged in users:

if(!$user->isLoggedin()) {
  $src = "https://--yourplausibleinstance--.com/js/plausible.js";
  echo "<script defer data-domain='{$config->httpHost}' src='$src'></script>";
}

Providing a dynamic domain is handy because during development you can add a second website to your dashboard and see if everything works without messing up data of your live site account.

Example: We want to track the site "example.com", so we add this site to our plausible dashboard. Then we add the snippet with the dynamic domain attribute. On local development we have the host "example.com.ddev.site" so all visits will not show up in the plausible dashboard for example.com; Now we add another website to plausible with the domain "example.com.ddev.site" and voila - we will see our dev-websites' visitors in realtime.

hr.svg

Backend Menu Item


By default RockAnalytics will create a menu item at the top level of your backend menu, but you can move that page to any place you like. For example you could move the analytics page under the "setup" page at the top of the screenshot. You can also rename the page if you don't like the label "Analytics".

68747470733a2f2f692e696d6775722e636f6d2f576a6b525531512e706e67

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • New TinyMCE 6.2.0 Inputfield released for ProcessWire— More
    28 October 2022
  • This week we take a look at a new rich text editor for ProcessWire, why we chose it, some highlights, screenshots, and why we think you’ll like it— More
    21 October 2022
  • This week we have ProcessWire 3.0.206 on the dev branch and a new version of the ProDevTools UserActivity module, which we'll take a closer look at in this post— More
    7 October 2022

Latest news

  • ProcessWire Weekly #447
    In the 447th issue of ProcessWire Weekly we'll share the latest core updates, introduce a new third party module called RockVideoThumbnailGrabber, and more. Read on!
    Weekly.pw / 3 December 2022
  • New rich text editor for ProcessWire
    This week we take a look at a new rich text editor for ProcessWire, why we chose it, some highlights, screenshots, and why we think you’ll like it.
    Blog / 21 October 2022
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull