Adding analytics and scripts to Decidim with consent

Decidim lets you inject analytics and other scripts through its head and header hooks, but scripts only respect consent if you tag them and register your cookies. This page covers the decisions, setup sequence and limits to confirm.

On this page

Adding analytics and scripts to Decidim with consent: what it involves

Scripts for analytics or other third-party services can be added to Decidim through the head extra partial or header snippets, but each one must be tagged with a consent category, and any cookies your own platform sets need categories registered for them. Teams usually need this when a public participation platform wants audience measurement, embedded video, maps or chat widgets, and its privacy notice, regional regulators and procurement reviewers expect visitors to choose which non-essential cookies and trackers run. The work is therefore configuration plus legal review, not a single line of code: someone must decide which tools are allowed, where they load, what they collect and which consent category governs them, then verify that nothing fires before the visitor's choice.

The facts available for this topic do not describe Decidim's consent-category internals, including how categories are named, where they are declared, how the consent banner reads them, or how a script tag is attached to a category. Confirm these against the documentation for the exact Decidim version you run, because the mechanism can differ between minor releases and the upgrade path may affect any custom partials you add. Ask your implementation partner to show the working configuration in a staging environment and to test it with a cleared browser profile, checking the network requests made before and after consent is given.

The legal side also sets the design. Analytics that are limited to anonymous performance measurement can sometimes be exempt from consent in certain jurisdictions, but features such as User ID, heatmaps or session recordings can remove that exemption. The Matomo FAQ on the ePrivacy Directive explains how national authorities approach this, and your data protection officer should confirm the position for each country where you operate.

Which analytics approach fits a public participation platform

Self-hosted Matomo means you install the On-Premise edition in infrastructure you control, so visitor data stays with your organization. Matomo's GitHub repository is licensed under the GNU General Public License version 3 (GPLv3), and the On-Premise Community edition is listed on Matomo's pricing page as free, with unlimited users and hits and forum support. The software is free, but the servers, storage, database administration, updates and backups are not.

  • Software cost: The Community edition has no license fee, so the recurring cost is the infrastructure and the staff or partner time to run it.
  • Sizing: Matomo's requirements FAQ sizes a single server with at least 4 CPUs, 8 GB of RAM and 250 GB of SSD for up to 1 million pageviews a month, and recommends separate app and database servers for larger volumes.
  • Runtime: Matomo 6.0.0 needs PHP 8.1 or newer and MySQL 8.0 or newer or MariaDB 10.6 or newer, so older hosts may need an upgrade first.
  • Data location: You choose where the database and logs live, which helps with data residency rules.
  • Upgrades: You own the upgrade cycle, including the Matomo 6.0.0 beta status shown in the changelog.

Confirm your expected monthly pageviews, the hosting region your legal team accepts, and who patches the server before choosing this route.

Configuration options and when each fits

This table compares the main choices for adding analytics to Decidim with consent, from where the script is loaded to how the tool is hosted. Read each row for when it fits, what it changes in the consent flow, and what to confirm against the Decidim version you run. The main takeaway is that the consent category and the analytics setup must be decided together, because a script that is loaded before consent is given can undo the consent design.

OptionWhen it fitsWhat it changes in the consent flowWhat to confirm in your Decidim version
Head extra partialYou need a script in the document head on every public page, such as a tag loader or a consent-aware measurement snippet.The script runs wherever the partial renders, so it must be wrapped or gated by your consent logic before any tag fires.The partial name and override path in your installed release, and whether your theme or upgrade already overrides it.
Header snippetsYou need a small, fixed snippet in the page header and want it managed from the admin panel rather than in code.Snippet content is output as written, so the consent check has to live inside the snippet itself.Whether your release exposes header snippets in the admin panel and where they render for each organization.
Tagging a script with a consent categoryThe script sets cookies or sends identifiers that a visitor should be able to refuse.The script is only activated after the visitor accepts the matching category, so nothing loads or writes cookies before that choice.How the cookie consent banner reads categories in your release and whether tagged scripts are blocked or only delayed.
Registering custom cookie categoriesYour own cookies or third-party tools do not fit the default categories and must be listed separately for the visitor.Each new category appears as a separate choice, and each script must reference the right category or it will not be controlled.Where categories are defined, the locale keys used for their labels, and whether the cookie policy text needs to be updated to match.
Client-side trackingVisitors' browsers send page views and events directly to the analytics service, the usual setup for a public platform.Consent gating happens in the browser, so the script and the cookies it sets are both subject to the visitor's choice.Whether your consent banner supports blocking browser scripts and how it behaves on pages with embedded content.
Server-side trackingYou want to record requests on the server, for example to avoid browser scripts altogether for a limited set of events.The browser sends no tracking script, but personal data still leaves the server, so the legal basis and retention still need review.Which events your Decidim version exposes to server-side hooks and whether your logging already captures the same data.
Matomo On-PremiseYou want analytics data kept in servers you control, with the community edition and no per-hit fees for the software itself.Consent logic is unchanged, but you become responsible for the hosting, updates and the data flow to your own servers.Matomo version and PHP and database requirements the service supports, checked against the current Matomo requirements page before install.
Matomo CloudYou prefer a managed service and accept that visitor data is processed by a hosted provider.Consent gating is the same in Decidim, but the processor agreement and data location must be reviewed as part of the consent notice.The plan tier that matches your hit volume, the data location stated on the pricing page, and the contract terms for data processing.

How to add a consent-aware script to Decidim

This sequence takes a set of analytics and third-party scripts from an informal list to a tested Decidim installation where each script loads only after the visitor's consent. Each step produces a record or check that the next step depends on, so the result can be reviewed by your privacy and compliance teams.

  1. Inventory every script and cookie

    Your product or privacy lead lists every script, pixel, embed and cookie the platform will set, including those added by vendors, plugins and the theme. For each item, record the vendor, the purpose, the data collected, the retention period the vendor states, and whether it sends data outside your country. Confirm the list against the rendered pages in a browser with developer tools, not only against what you intended to add. The step is done when the inventory matches what a browser actually loads on each public page and in the admin panel.

  2. Decide the legal basis with counsel

    Your legal or data protection counsel decides, for each inventory item, whether it needs consent, falls under an exemption, or can be removed. Counsel also confirms which consent categories you will use and how the notice and withdrawal wording should read. Some national regulators publish conditions under which certain privacy-focused analytics are exempt, but those conditions are narrow and features such as user identifiers, heatmaps or session recordings can remove the exemption, so confirm the exact configuration with counsel. The output is a signed-off table mapping each script to a category and a legal basis.

  3. Locate the injection point in your target version

    Before editing anything, the implementer checks the Decidim documentation for the exact version you run and identifies the supported mechanism for adding content to the document head or header, such as a head extra partial or a header snippet setting. Confirm whether the mechanism exists in your version and where it is rendered for public and admin layouts. Note any differences in the version you are moving to, because the release notes and upgrade guide may change template names. The step is done when you have a written note of the file or setting, the version it was checked against, and a test page that renders it.

  4. Add each script tagged with its category

    The implementer adds each approved script through the supported injection point, wrapping it so that it carries the consent category assigned in the earlier table and does not execute until that category is accepted. Keep one script per block so the category mapping is easy to audit, and store the code in version control so changes are reviewed. Do not place scripts directly in shared layouts where an upgrade may overwrite them. The step is done when the rendered HTML shows each script with its category attribute and the code is committed with a reviewer's approval.

  5. Register custom cookie categories

    For any cookie your own modules or scripts set, the implementer adds a category entry that matches the names used in the script tags, so the consent banner can describe and manage it. Keep category names and descriptions in the locale files your team maintains, and make sure each language version says the same thing. Confirm the category appears in the consent interface for every interface language you enable. The step is done when a cookie set by your custom code appears under the correct category and can be turned on and off independently of the others.

  6. Test that nothing fires before consent

    On a staging copy of the platform, a tester opens a fresh private browser session and loads public pages, admin pages and any page with embedded content. The tester uses browser network and cookie inspection to confirm that no script from the inventory makes a request, and no cookie in a non-essential category is written, until the visitor accepts that category. Repeat the check after each script is added. The step is done when the test log lists every page, every script and the observed result, and any failure has a fix and a retest.

  7. Test that withdrawal stops collection

    The tester accepts a category, confirms the script runs and the cookie is set, then withdraws consent through the banner or preference page. They reload the page and check that the script no longer loads, that no new requests reach the vendor, and that existing non-essential cookies are removed or no longer read by your code. The tester also checks that withdrawal works in every enabled language. The step is done when the withdrawal results are recorded for each category and the staging environment behaves as the counsel-approved table describes.

  8. Repeat the tests on staging before production

    The team applies the same tested configuration to production only after the staging results are signed off by the owner of the legal decision. Deployment uses the same process as other changes, with a record of the version, the commit and the person who approved it. After release, the tester repeats a short set of the checks on production and compares the results with staging. Schedule the inventory review again whenever a script, vendor or Decidim version changes. The step is done when production passes the same checks and the review date and owner are recorded.

Security and operational risks when scripts run on a civic platform

Every script added to a participation platform runs in the browser of citizens who expect their activity to stay with the public body. The cards below cover the risks that follow from that: the scripts themselves, where the data goes, the analytics host, the Decidim version underneath, and the changes that happen over time.

Third-party script compromise

A tag served from an outside host can be changed without your knowledge, and the browser will run whatever arrives. Check each vendor's documented options for Subresource Integrity (SRI) hashes, and confirm whether the vendor publishes versioned files that can be pinned. Where the vendor updates a file in place, decide whether to self-host a copy you control, and record who is alerted when the file changes.

Data sent outside your jurisdiction

A hosted analytics or session tool may store visitor data in a country other than the one whose law governs your public body. Ask the vendor where each data category is stored and processed, which sub-processors receive it, and how transfers are covered. Record the answers in the same register as your other processing activities before the script goes live.

Self-hosted Matomo patching and runtime support

If you run Matomo yourself, it inherits your server's security obligations. Matomo's requirements list specific PHP and database versions for each release line, and newer releases can drop support for older runtimes. Plan who applies Matomo updates, how the PHP and MySQL or MariaDB versions are kept supported, and how the analytics server is patched alongside the Decidim host.

Matomo 6.0.0 minimum
PHP 8.1
Matomo requirements

Decidim supported versions and reporting window

Decidim only applies security updates to its last two minor versions until version 1.0. If your site runs an older line, the scripts and the platform beneath them are no longer covered. Check the project's security policy for how vulnerabilities are reported and how long implementers have to apply patches, and assign someone to watch the security advisories for the version you run.

Supported with security updates
2 minors
Decidim security policy

Script change control across upgrades

Head partials and header snippets live outside the core code path, so a Decidim upgrade can change the surrounding markup and quietly break or duplicate a tag. Keep a written inventory of every script, its consent category and its owner, and re-test the consent banner and tag firing after each minor-version upgrade. Treat any new script as a change that needs review, not a configuration tweak.

Keeping scripts and consent settings working through Decidim upgrades

Every script, head partial and consent category you add to Decidim is a customization that must be re-checked at each minor version upgrade, not just when it is first installed. The Decidim update docs direct implementers to move one minor version at a time, for example 0.30 to 0.31 before 0.32, and to follow each release's upgrade instructions because some releases change database structures. Back up the database before every step. After each step, load a public page in a private browser session, confirm the analytics tag fires only after the visitor accepts the matching category, and confirm the cookie banner still lists your own cookie categories. Treat this check as part of the upgrade acceptance criteria, next to login and component tests.

Decide who owns the consent text and the category list before the first upgrade. The privacy notice, the banner wording and the mapping between each script and its category are legal content as much as technical configuration, so they need a named owner in your organization, usually the data protection lead, with the platform team responsible for the code that applies them. Keep a written register that lists each script or pixel, the category it belongs to, the data it collects, and the vendor's documented settings, such as anonymization or a disabled user identifier. Review that register at every upgrade and whenever the analytics vendor changes its configuration.

A script added without a category can silently break compliance after an upgrade. If a template change, a changed partial name or a new Decidim release moves the surrounding markup, a tag that was once gated may load on every page, and nothing in the platform will report it. Confirm with your own team how uncategorized scripts are blocked by default, and test that they do not load before consent. Ask your consent tooling vendor or your implementation partner to show the exact failure mode, then add a regression check that loads the public pages after each upgrade and inspects which third-party requests are made before any choice is recorded.

Limits to confirm in your environment before going live

Analytics and consent work breaks down at the edges: the Decidim version you run, the Matomo release you choose, the tools you import data from, and the countries where your users sit. The cards below list the limits to verify with your legal review and your own test environment before any tag fires for a real participant.

Consent categories in your version

Confirm that the consent mechanism in your Decidim version supports the categories you need, such as one for analytics and one for your own cookies. Check whether the categories you tag scripts with are the ones the banner actually offers visitors, and whether a visitor who declines still gets a working page. Test this on a staging copy with a fresh browser profile, not only with cookies left over from development.

Decidim installation docs

Google Analytics importer limits

The importer brings in aggregated report data only, not raw visit and action data. Visitor Log, Ecommerce Log, Custom Reports and Segmentation do not work for imported reports, and some reports such as Funnels are not imported. Ask the stakeholders who read the old reports which views they need, and confirm that each one exists after import before you retire the Google Analytics property.

Matomo import limits FAQ

National exemption criteria

Some French, Italian, Dutch and Spanish authorities exempt certain privacy-focused analytics from consent when strict criteria are met. Matomo's guidance says the exemption can be lost when features such as User ID, heatmaps or session recordings are added. Your counsel should map the exact criteria to the countries where your participants live, because the exemption depends on the configuration you ship, not only on the tool.

ePrivacy national implementations FAQ

Matomo 6.0.0 beta versus 5.x stable

Matomo 6.0.0 is in beta, while the changelog lists 5.14.1 as the latest stable release. Matomo 6.0.0 requires PHP 8.1 or newer and MySQL 8.0 or newer or MariaDB 10.6 or newer, so check your server and database versions before choosing a branch. For a public consultation platform, a stable release with a documented upgrade path is usually the safer starting point, and you should confirm the support window with the Matomo team.

Matomo changelog

Importer and premium plugin licensing

The Google Analytics Importer is a free GPL v3+ plugin for Matomo On-Premise. The Heatmap and Session Recording plugin is a paid premium plugin under the InnoCraft EULA, not the GPL, and it is sold per number of users with a free trial. Have your legal team review both licenses before installation, and confirm whether the premium terms are compatible with your data processing agreements and your privacy notice.

Heatmap plugin listing

Questions buyers ask before adding analytics to Decidim

How much effort does adding analytics to Decidim with consent take?

Effort depends on how many scripts you add, how many organizations share the installation, and how much legal review the consent setup needs. A single analytics tool on one organization is a small change in the head extra partial. Each additional script, each tenant with its own tracking rules, and each cookie category you define adds testing and documentation. Legal review is often the longest step, because the consent categories must match what each script actually collects. Ask any partner to break the quote into script inventory, consent mapping, template changes, testing across organizations and documentation of what was configured.

Can our own team add analytics to Decidim without a partner?

Yes, if your developers know Ruby on Rails and your Decidim version, and your legal owner can define the consent categories. The technical part is adding markup through the head extra partial or header snippets and tagging each script with a category. The harder part is making sure scripts load only after consent, that every cookie your platform sets is declared, and that the change survives upgrades. Teams without Rails experience usually take longer and need a staging environment to test changes before production. A partner can take on part of the work, such as the build and testing, while your team keeps the decisions on what is tracked.

How long does it take to add analytics and consent controls?

No duration figure is available for this topic, and the time depends on scope. The main drivers are the number of scripts, the number of organizations, whether consent categories already exist, and how quickly your legal owner can approve the mapping. Ask for a timeline that lists the steps, the staging test window and the approvals each step needs, so you can see which part depends on your team rather than on the implementation work.

What does the work need from our organization?

Three things are needed before work starts. First, a named legal or privacy owner who decides which consent categories apply and signs off on the mapping. Second, a script inventory listing every analytics tool, embed, pixel and third-party widget, with the data each one collects and where it runs. Third, staging access that mirrors production closely enough to test consent behavior, including a test organization if you run a multi-tenant install. Without the inventory, scope cannot be fixed in writing, and the work tends to expand during testing.

Is Matomo free to use with Decidim?

Matomo's On-Premise Community edition is free to download and run, with unlimited users and hits and forum support, according to Matomo's pricing page. You still pay for the server, storage, database, backups and the people who operate them. Matomo Cloud is a paid hosted service with plans starting at 29 per month (excluding tax) for the smallest tier, according to the same page. Premium plugins such as Heatmap and Session Recording are sold per number of users under a separate license. Adding those features also removes the consent exemption that some privacy-focused analytics can rely on, so budget the legal review as well.

Does DeployOpen issue compliance certifications for our consent setup?

No. DeployOpen does not issue audit reports, attestations or certifications. It prepares the systems, consent controls and evidence that your compliance team and independent auditors or regulators review. For a consent setup, that evidence can include the script inventory, the consent category mapping, the tested behavior before and after consent, and the configuration records. Whether a given setup meets a national rule is a legal question for your counsel or the relevant data protection authority, and you should confirm it with them.

What breaks when Decidim is upgraded after consent changes?

Changes made in the head extra partial or header snippets can be overwritten or conflict with template changes during a Decidim upgrade. Decidim's update guide says to upgrade one minor version at a time and to follow each release's instructions, so consent markup should be tested on each step in staging. Keep the script inventory and consent mapping under version control, and re-run the consent tests after every upgrade and after any change to a tracked script.

What DeployOpen checks in the consent setup

The most useful check on a consent setup happens on a staging copy before anything reaches production. DeployOpen's review of the Decidim head extra partial and header snippets starts with script load order: the consent banner must load and its state must be readable before any analytics tag runs, and every tag that was tagged with a consent category must wait for that category to be accepted. We record the order in which scripts execute on a clean page load, on a page after acceptance, and on a page after withdrawal, because a tag that fires early on one path often goes unnoticed in a manual click-through. Confirm with your own team which pages carry the snippets, since Decidim renders public, admin and system layouts differently.

The second check is network calls before consent. With browser developer tools and a proxy or request log, we list every outbound request made before a visitor chooses anything, including requests from the analytics host, font or map providers, and embedded widgets. We then compare the cookies set before and after consent, and again after the visitor withdraws consent, and confirm that withdrawal removes or stops the cookies in your own categories. Cookies created by your own code need a category entry in the consent configuration, and a cookie without one is a finding. If you run a self-hosted analytics product such as Matomo, confirm with its vendor documentation which of its features would change the consent analysis before you configure it.

The third output is evidence for the compliance team. DeployOpen packages the test scope, the request and cookie inventory, screenshots or recordings of each state, the configuration diff, and a list of open issues with owners. This record helps your privacy and compliance staff answer questions from a data protection authority, an internal auditor or a customer's security review. DeployOpen prepares systems, controls and evidence for compliance assessments. It does not issue audit reports, attestations or certifications, and the conclusions about lawfulness belong to your legal and privacy team and, where relevant, to an independent auditor.

How DeployOpen works on this

DeployOpen plans, implements, integrates, documents and supports self-hosted open-source platforms inside the client's own infrastructure. For Decidim, that means agreeing in writing which analytics and third-party scripts load, how each one is tagged to a consent category, and how the consent controls are tested before anything reaches production.

How we scope

  • Inventory every analytics, embed and third-party script the Decidim platform should load, with its owner and purpose.
  • Map each script to a consent category, and agree with your legal or privacy team which categories and wording apply.
  • Confirm the delivery method, either the head extra partial or header snippets, and which organizations in a multi-tenant install are affected. Engagements are fixed-scope, with the scope agreed in writing before work starts.

How we build

  • Add scripts through the agreed partial or snippet configuration so that upgrades and custom code stay separate and traceable.
  • Tag each script with its consent category and define your own cookie categories, then test that nothing loads before consent is given.
  • Test the consent behavior across public and admin pages, supported locales and the browsers your participants use.

How we hand over

  • Deliver a written record of each script, its consent category, its data flow and the configuration files involved.
  • Document how to add a new script or cookie category, and who must approve changes before they go live.
  • Walk your administrators and privacy staff through the setup and the test results so they can review it themselves.

How we support

  • Retest consent behavior after each Decidim minor version upgrade, since upgrades can change the surrounding templates.
  • Ongoing support, upgrades and continuous testing are available as a retainer, scoped in writing.
  • Ask any support provider to confirm how they will track script changes and re-run consent tests after each change.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.