Nonce Piwik Plugin
This module automatically adds the Piwik PRO analytics tracking script to your Drupal site while ensuring it is secure by generating a unique nonce for Content Security Policy (CSP) on each request. It allows configuration of tracking settings, visibility, and cookie options to integrate seamlessly with your existing analytics setup.
Nonce Piwik Plugin integrates Piwik PRO analytics with Drupal's Nonce Generator module. It renders the Piwik PRO tracking bootstrap with a fresh Content Security Policy (CSP) nonce on every request.
Features
- Adds the Piwik PRO tracking script automatically to the page.
- Applies a CSP nonce to the inline bootstrap script and the dynamically loaded tracking script.
- Configures the Piwik PRO container URL, site ID, data layer name, and cookie security options.
- Controls tracking visibility by request path, user role, and content type.
- Supports Drupal 10 and Drupal 11.
Post-Installation
Install and enable Nonce Generator and this module. Configure this module at /admin/config/security/nonce-piwik-plugin. Enter the Piwik PRO container URL and site ID, enable tracking, and review the visibility and cookie settings. Configure your site's CSP separately so it permits the configured Piwik PRO host in the directives required by your tracking setup.
Additional Requirements
- Nonce Generator (required).
- Drupal core's Path Alias module.
- A Piwik PRO account and container.
Recommended modules/libraries
No other additional modules or libraries are required. A CSP configuration that allows the configured Piwik PRO endpoints is recommended.
Similar projects
Piwik PRO is the related general-purpose Drupal integration for Piwik PRO. Nonce Piwik Plugin is focused on nonce-aware tracking through the Nonce Generator plugin system and is intended for sites that need this CSP integration.
Supporting this Module
Please report bugs and feature requests in the Drupal.org issue queue.
Community Documentation
See the project README and the configuration help provided by the module. Contributions and documentation improvements are welcome.