Idea: Insight dashboard

A dedicated LGD module that brings analytics, call centre data and user feedback into the content admin view of LocalGov Drupal, so content designers can see how their pages are performing and act on it without leaving the site they are editing

Councils already hold a wealth of useful insight, but it is scattered. Page analytics sit in Google Analytics or Matomo, call reasons sit in a CRM, and citizen feedback sits in a survey tool or a shared inbox. A content designer with a page to improve has neither the time nor the permissions to join those sources up, so the data goes unused and the content problems persist.

This proposal is different from most Community Fund pitches in one important respect: much of the hard engineering is already done and in the open. Croydon Council built an analytics tab for their own site, contributed the code, and are now committing to the shared modules directly. We have generalised their work and written the Matomo integration that the Drupal contrib module has lacked since 2018. What we are asking the community to fund is the work that turns proven code into a supported product: the remaining report types, documentation, accessibility review, automated testing and Drupal.org contribution.

We want to launch something quickly, and build on it over time. We have costed completing and hardening the Matomo and Google Analytics reporting, and a simple on-page feedback form. There is a list of other sources we could include below, and we encourage everyone to let us know which are essential for launch.

User stories

Seeing how a page is performing 

As a content designer

  • I need to look at analytics reports for a page without needing to open a different window to look at analytics
    So that I can see the performance of the page I am currently editing
     
  • I need to see how a page has performed over time (views, entrances, exits and average time on page)
    So that I can tell whether a rewrite actually improved it
     
  • I need to see what citizens did next after landing on a page
    So that I can judge whether the page answered their question or sent them somewhere else

As a communications or web manager
I need to identify the pages that are performing badly at a glance
So that I can prioritise which content to review first with a limited team

Understanding demand the website is not meeting

As a customer services manager
I need call centre volumes shown alongside web analytics for the same service
So that I can see where citizens give up online and phone instead

As a service manager
I need to see whether a page helped, in the citizen's own words
So that I can understand the reason behind the numbers rather than guessing at it

As a web manager
I need to see who is using a service by device and channel (and by demographic group where consent allows)
So that I can check we are reaching the people who most need the service

Work

A 'page analytics' feature

A 'page analytics' feature will be created that will allow analytics reports to be added to a tab on pages of content. This will contain configurable sections that can have analytics reports of different types added to them.

We want to make the display mechanism as agnostic of what analytics technology is being used as possible. It will then be possible to plug different reports about the page into the system. A mechanism to display analytics reports in a tab on pages of content, with the following report types in scope:

  • Matomo reports - available at launch
  • Google Analytics reports - phase 1, further development of the existing integration
  • Citizen feedback reports - phase 2
  • Mautic profile and demographic reports - phase 3
  • Call centre reports - phase 4

Google Analytics reporting is in scope. Croydon's existing Google Analytics integration is the starting point, and it is developed alongside the Matomo reporting so that both report types are available to councils from launch. The display mechanism is technology-agnostic by design, so either can be extended independently as a separate block plugin.

This is not a hard-coded tab with a fixed set of graphs. Each report is a block, and blocks are grouped into 'sections' that are configurable content entities in their own right, each with a label, a weight and an ordered set of blocks. A council decides which sections appear and in what order, and each section becomes its own subtab automatically. Because the tab structure is derived rather than hand-built, a supplier or council developer can add a new report type by writing a block plugin, without touching the mechanism that displays it. 

Matomo reporting

Matomo is open source, can be self-hosted, and has a comprehensive reporting API. Building on it first means councils are not locked into a single commercial analytics vendor, and councils that already run Matomo can use the feature immediately.

Drupal's existing Matomo Reporting API module provides the authentication and the API client, but it has no Views integration. This is an issue first raised in 2018 and stalled, in part because Views external schemas are not widely understood. We have written that integration, and it is the most substantial piece of new engineering in this proposal. It provides:

  • A Views query plugin that translates a View into Matomo API calls and maps results back into rows
  • A Views wizard, so a report can be created through the standard Drupal UI rather than in code
  • Field and argument plugins, including an argument default that resolves the current page's path automatically, which is what allows the same View to report on whichever page you happen to be editing
  • Filters for date, period, segment, numeric and string values
  • A row normaliser and a method manager, so Matomo's response formats are handled in one place
  • A decorator for the upstream module's config handler, so we extend the contrib module rather than forking it, and upstream improvements land cleanly
  • Unit test coverage for the query builder and the row normaliser

We have tested this against a live Matomo instance, and raised the underlying module bug upstream with our workaround documented so other councils and integrators benefit.

What's already built

Three components exist, are public, and are working today. Node Analytics also carries the Google Analytics display code Croydon contributed, which the phase 1 Google Analytics work builds on. All are developed in the open on Code Enigma's GitLab and intended for contribution to Drupal.org:

Node Analytics - which adds an Analytics tab to content pages, built on a configurable 'section' config entity, with local task derivatives generating the tab and subtab structure, a block renderer service, and an admin interface using table drag for ordering. Subtab content is served in the admin theme. Requires Drupal 10 or 11, and is written entirely with object-oriented hooks with Drupal 12 compatibility in mind. Covered by a kernel test, with a test module supplying blocks both with and without the required node context.

Matomo Reports - the Views integration described above, also covering Drupal 10 and 11, with its own config schema and unit tests.

Matomo Analytics Reports - a Drupal recipe that installs both modules plus the Charts module with the Chart.js library, and configures a working setup out of the box: a 'web page performance' section, an empty 'demographics' section ready to be populated, and a Visits View. A council can install the recipe and have a report rendering without writing configuration by hand.

Building on work councils have already funded

Croydon Council built an equivalent analytics tab for their own site, using Google Analytics and Netcall Liberty Create data, and contributed that code to the community. Our approach takes their display pattern, keeps the useful parts, and strips out the CRM-specific code so that it works for any council.

This is now a live collaboration rather than a one-off handover: Croydon's developer has contributed to the shared Node Analytics module directly, including a recent improvement to subtab behaviour and a forward-compatibility review for the next major Drupal version. This means the community is not paying twice for the same idea. The councils that pledge are funding the generalisation of something already proven in a live authority (ie. Croydon) and remain invested in its future.

Delivered in phases

Discussed with the LGD product team, the work is deliberately staged so that value arrives early and each phase can be funded and shipped on its own:

1.     Matomo integration: launch-ready reporting: the demographics integration, a library of standard page reports, hardening, and contribution to Drupal.org

2.     Citizen feedback: a simple feedback form on content pages, with a traffic-light style summary of whether the page helped

3.     Mautic integration: consented profile and demographic data surfaced as reports

4.     Call centre reports: CRM and contact reason data injected as report blocks

Accessibility and usability

This is not a public facing tool, but all work will still meet WCAG 2.2 Level AA accessibility requirements. It will also be tested thoroughly with councils who pledge to fund this work.

Reports are built from blocks and Views within the existing administrative theme, so they inherit its accessibility behaviour. Where charts are used (via the Charts module with the Chart.js library) each will carry a text equivalent, so a report is never conveyed by colour or shape alone.

Privacy and security

Consent before profiling: demographic and profile data is only surfaced where the citizen has consented to it. Where consent is absent, the report shows the aggregate only, or nothing at all.

Data protection impact assessment: a feedback form introduces personal data and a retention question. We will work through a DPIA with pledging councils and make retention configurable, rather than assuming a period.

Spam and abuse: an on-page feedback form is a public write endpoint. We will build in rate limiting and spam protection from the outset. One council recently received around a thousand spam submissions in a single day.

Cacheability: a feedback form on a Drupal page can defeat page caching and cost performance. The form will be delivered in a way that does not compromise response times for anonymous visitors.

Credentials: analytics API credentials are held in private file storage and never exposed through configuration exported to code.

Least privilege: the module ships with its own permissions, so the right to view analytics on a page can be granted separately from the right to edit it. A council can show reports to a communications team without giving them write access to content.

Estimated time/cost

To follow, once the spec finalised.

Get involved!

We're now opening this to everyone in the community to hear your comments. Please contact Greg Harvey at Code Enigma via the LocalGov Drupal Slack or hello@codeenigma.com, or Will Callaghan via the LocalGov Drupal Slack or will@localgovdrupal.org:

  • with thoughts on the launch spec and possible later features (listed below)
  • about legal and compliance requirements, particularly data retention for the feedback form
  • if you have already built something similar and would rather contribute it than see it rebuilt

Possible later features

Google Analytics enhanced reporting: the phase 1 Google Analytics work covers bringing the existing integration to launch quality, following Croydon's implementation. Deeper GA4 reporting (additional dimensions and metrics, and the consent model around them) can be extended later as a further phase, funded separately.

Demographic reporting from Matomo: a 'demographics' section already exists in the recipe but is deliberately shipped empty, because the Views integration does not yet expose Matomo's demographic reports. Filling it would let councils see age, location and device breakdowns without leaving Drupal, subject to the consent position above.

FOI statistics: the proposed FOI disclosure log will generate numbers worth surfacing. This would include volumes, refusal rates, response times against the 20 working day deadline. These could appear as a report block alongside page analytics.

Media engagement: Matomo's API can report on video watch duration. A report block showing how far citizens actually watch an embedded video would change how councils commission and place video content.

Site-wide and cross-council dashboards: the same report blocks, assembled outside the content page, to give a web manager a service-level or whole-site view. A shared, anonymised benchmark across pledging councils could show how similar pages perform in different authorities.

 Scheduled digests: email summaries of the pages that have degraded most in the past month, sent to content owners, so improvement work is pushed rather than waiting to be discovered.

Reinstating the CRM connector: the Netcall Liberty Create integration was removed from Croydon's contributed code to keep the module generic. It can return as an optional sub-module for councils using that platform.

Configurable report types by anyone: report blocks are already pluggable by design, and new reports can be generated by anyone. A library of community-contributed reports is the natural end state.