The Plausible Analytics Plugin is an extension for Grav CMS. Integrate Plausible Analytics into your Grav site and configure it from your admin panel.
This plugin currently doesn't support self-hosted Plausible instances. Shouldn't be too hard to implement, but I prefer to pay Plausible their very reasonable rates to support that project.
Installing the Plausible Analytics plugin using the GPM (Grav Package Manager) cli, the Grav admin panel, or manually. The GPM and admin panel methods are generally to be preferred.
From the root of your Grav site, enter the following command:
$ bin/gpm install plausiblePlease find the latest instructions on how to add new plugins to your Grav site via the admin panel. In the filter box, search for "Plausible" to narrow your search.
To install the plugin manually, download the zip-version of this repository and unzip it under /your/site/grav/user/plugins. Then rename the folder to plausible. You can find these files on GitHub or via GetGrav.org.
You should now have all the plugin files under
/your/site/grav/user/plugins/plausible
NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its blueprints.yaml file on GitHub.
Before configuring this plugin, you should copy the user/plugins/plausible/plausible.yaml to user/config/plugins/plausible.yaml and only edit that copy.
Here is the default configuration and an explanation of available options:
enabled: true
active: true
data_domain: null
custom_event_goals: false
outbound_link_tracking: false
public_dashboard_visible: false
public_dashboard_url: null
custom_plausible_domain: "https://plausible.io/"
self_hosting: false
custom_domain: nullenabled: true|falsetoggles whether the Plausible Analytics plugin is turned on or off.active: true|falsetoggles whether Plausible Analytics is enabled site-wide or not.data_domain: String?is the domain you wish to track in Plausible Analytics; needs to be registered with Plausible.custom_event_goals: true|falsetoggles whether the global JavaScript functionplausibleis registered, enabling you to trigger custom events.outbound_link_tracking: true|falsetoggles whether the Plausible script snippet that gets loaded is capable of tracking outbound clicks.public_dashboard_visible: true|falsetoggles whether to output a comment in the source of the page comment with a link to your public website stats dashboard.public_dashboard_url: String?is the full URL of your public dashboard, as set out in https://docs.plausible.io/visibility.- To actually output a comment in the HTML source,
public_dashboard_visiblemust betrueandpublic_dashboard_urlmust be a non-empty string. - If these conditions are met, then (e.g.,)
<!-- Plausible Analytics public dashboard URL : https://plausible.io/your-domain-here.com -->is injected before your page content.
- To actually output a comment in the HTML source,
self_hosting: true|falsetoggles whether to enablecustom_domain: String?is the scheme, hostname, and optionally, the port to your self-hosted Plausible instance.- To use a self-hosted instance,
self_hostingmust betrueandcustom_domainmust be a non-empty string.
- To use a self-hosted instance,
Note that if you use the Admin Plugin, a file with your configuration named plausible.yaml will be saved in the user/config/plugins/-folder once the configuration is saved in the Admin.
- Register for an account with Plausible Analytics. No restrictions and no credit card required for their 30-day trial period.
- Add the domain you wish to track to your Plausible account.
- Add the same domain to the
data_domainattribute inuser/config/plugins/plausible.yaml. It's also available as the Domain field in the Admin panel.
Refer to the Plausible docs on Custom event goals for more details.
- Set
custom_event_goalstotrue. (This takes care of the tracking setup step described in Plausible's docs.) - Setup your event listeners to track whatever custom events you're interested in. One way to do this is with the Custom JS Plugin by @dimayakovlev. Shortcode Assets, by the core Grav team, would work, too.
- Follow the Plausible documentation to configure your custom event goal tracking in Plausible.
- Set
outbound_link_trackingtotrue. - Follow the Plausible documentation to create a custom event goal with the name
Outbound Link: Click.
- Follow the Plausible documentation to install and configure your self-hosted instance.
- Set
self_hostingtotrue. - Add the URL to your self-hosted instance, omitting the trailing slash(
/) andjs/plausible.
Plausible Analytics is itself an open source project, licensed under GNU Affero General Public License Version 3 (AGPLv3).
Hat-tip to @divinerites for the idea to add public dashboard information to the page source.
- Handle Plausible's exclusions
- Add option to disable tracking entirely per-page via frontmatter?
- Add capability to add JS to frontmatter (as a list of block scalars?) for custom event tracking
- Add translations to
languages.yaml. - Allow self-hosting configuration