@pmeweb/plugin-audience
v1.1.0
Published
PmeWeb audience plugin: Google Analytics 4, loaded only after the visitor grants « Mesure d’audience » in the @pmeweb/consent card.
Readme
@pmeweb/plugin-audience
Google Analytics 4 for a PmeWeb site, loaded only after the visitor grants « Mesure d’audience »
(the analytics purpose) in the @pmeweb/consent card. Replaces the GA4 part of phase 1's
@pmeweb/plugin-consent.
- Installed and inactive by default. Listed in
pmeweb.jsonpluginswith noga4, it renders nothing, and@pmeweb/consentbuilds no card for it. Settingga4turns it on. - Nothing in the page but one « use » tag.
<Audience>renders<script type="application/json" data-pmw-consent-use>with the public id and the URL ofdist/load.js. The decider of@pmeweb/consentimports that module once the purpose is granted (afterloadand an idle moment on a page still loading, at once on a click) and callsload({ ga4 }), which addsgtag.jsand configures the property. No inline code (inlineBudget: 0), nothing at page open, nothing off the site's real hosts. - Measurement only. The decider grants
analytics_storagefor this purpose; nothing here grants anad_*signal, so Google Signals and Ads linking get no consent from it. Using GA4 for advertising is a decision for when a client asks, not a setting.
Config (pmeweb.json plugins.audience)
| Key | Pattern | Meaning |
|---|---|---|
| ga4 | ^G-[A-Z0-9]+$ | The GA4 measurement id. Its presence is what makes the plugin active. |
| ga4Retention | 2 or 14 | Months GA4 keeps event data, as set in the client's GA4 property: Administration > Collecte et modification des données > Conservation des données (default: 2 months). Required with ga4 (requiredWith, checked by check-plugins); it fills {ga4Retention} in the privacy text. |
Read the retention in the property itself, or ask the client; never assume the default.
The client sets both in the portal, « Contenu › Modules › Mesure d’audience » (manifest
portal.config, plugin system phase 4): a change is a draft that ships with « Publier ».
One source of GA4
If the site also has a Google Tag Manager container (@pmeweb/plugin-advertising), that container
must NOT configure the same GA4 id: every page view would count twice, and the GA4 tag inside GTM
would run under the advertising purpose instead of analytics. The operator removes that tag
from the container; this plugin is the one source of GA4.
Privacy
privacy/fr.json and privacy/en.json ({ heading, paragraphs }), rendered by
<PluginPrivacy> of @pmeweb/consent on the site's privacy page when the plugin is active. The
text is the package's, approved once by the operator, identical on every site; a site never edits
it. Provider: Google, outside Quebec (manifest.json privacy.providers).
CSP
cspHosts({ ga4 }) from @pmeweb/plugin-audience/csp: www.googletagmanager.com (script, img,
connect), *.google-analytics.com and *.analytics.google.com (img, connect). {} when inactive.
Check after a deploy
@pmeweb/consent's README « Check after a deploy », analytics case: nothing before answering;
after « Accepter » (or « Personnaliser » with only « Mesure d’audience »), gtag/js goes out,
_ga appears, and dataLayer holds consent update with analytics_storage: granted and no
ad_* granted.
