Built-in statistics (cookieless, consent-gated visitor history); per-page meta descriptions, NoSnippet
Stats: ipalKit({ stats: true }) adds the stats-visits collection, POST /api/ipal/hit, the
/admin/stats view (30-day visits chart, top/entry pages, referrers, devices), a dashboard card
and a nav link. <PageStats> (or <SiteProviders stats>) sends one beacon per page view. Without
consent nothing is stored on the device and no IP is kept: page views are joined by a hash with
an in-memory salt replaced daily. With analytics consent an ipal_vid cookie links visits across
days (server re-checks the consent cookie and policy version; withdrawal deletes the cookie).
Bots, logged-in panel users and prefetches aren't counted. Retention 90 days.
@payloadcms/next added to peerDependencies (DefaultTemplate). Docs: stats.md with privacy text.
Also in this release: meta.description auto-filled from page blocks, <NoSnippet>,
MetaDescriptionCheck in the SEO tab, data-nosnippet on banner/language switcher, GA4 CSP
wildcards, consent version passed to Analytics' default consent.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
305c564d13
commit
4ec27d9ef0
@@ -17,14 +17,18 @@ declare global {
|
||||
const GTM_SCRIPT = (id: string) => `https://www.googletagmanager.com/gtm.js?id=${id}`
|
||||
const GA4_SCRIPT = (id: string) => `https://www.googletagmanager.com/gtag/js?id=${id}`
|
||||
|
||||
/** Reads the current consent state from cookie, or defaults if none. */
|
||||
function readConsent() {
|
||||
/**
|
||||
* Reads the current consent state from cookie, or defaults if none. `version`
|
||||
* must be the panel's policy version — the same one useConsent checks — or a
|
||||
* valid consent under any version other than 1 reads as "all denied".
|
||||
*/
|
||||
function readConsent(version: number | undefined) {
|
||||
if (typeof document === 'undefined') {return DEFAULT_CONSENT}
|
||||
const raw = document.cookie
|
||||
.split('; ')
|
||||
.find((c) => c.startsWith(`${CONSENT_COOKIE}=`))
|
||||
?.split('=')[1]
|
||||
return parseConsent(raw) ?? DEFAULT_CONSENT
|
||||
return parseConsent(raw, version) ?? DEFAULT_CONSENT
|
||||
}
|
||||
|
||||
function injectScript(src: string) {
|
||||
@@ -121,7 +125,7 @@ export function Analytics(props: AnalyticsProps) {
|
||||
} = props
|
||||
|
||||
// Live consent state — drives the non-Google pixels.
|
||||
const { state } = useConsentContext()
|
||||
const { state, texts } = useConsentContext()
|
||||
const ready = useDeferredReady(defer, deferTimeoutMs)
|
||||
const defaultConsentSet = useRef(false)
|
||||
|
||||
@@ -131,9 +135,9 @@ export function Analytics(props: AnalyticsProps) {
|
||||
useEffect(() => {
|
||||
if (defaultConsentSet.current) {return}
|
||||
if (!ga4MeasurementId && !gtmContainerId) {return}
|
||||
setDefaultConsent(readConsent())
|
||||
setDefaultConsent(readConsent(texts.version))
|
||||
defaultConsentSet.current = true
|
||||
}, [ga4MeasurementId, gtmContainerId])
|
||||
}, [ga4MeasurementId, gtmContainerId, texts.version])
|
||||
|
||||
// --- Google: load once `ready`; Consent Mode handles gating ---
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user