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.

Latest news

  • ProcessWire Weekly #520
    In the 520th issue of ProcessWire Weekly we'll check out some of the latest additions to the ProcessWire module's directory, share some highlights from the latest weekly update from Ryan, and more. Read on!
    Weekly.pw / 27 April 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer