Analytics

PostHog integration, event tracking, and consent management

PostHog

Configured

Self-hosted on Azure Container Instances

Azure AD

Configured

Identity resolution via /.auth/me endpoint

Consent

Configured

PECR/UK GDPR compliant, deny-by-default

UTM Tracking

Configured

7 parameters captured (5 standard + 2 custom)

Event Tracking Schema

19 events defined in lib/analytics/posthog.ts

Tool Lifecycle

tool_viewTOOL_VIEWFired when an adviser navigates to a tool page
tool_startTOOL_STARTFired on first input interaction (adviser begins using calculator)
tool_completeTOOL_COMPLETEFired when a calculation is run or result is generated
tool_errorTOOL_ERRORFired on invalid input or calculation failure (includes error_type, error_message)
tool_abandonTOOL_ABANDONFired when adviser leaves a tool page without completing (unload event)

Result Actions

result_printRESULT_PRINTAdviser prints calculation results
result_copyRESULT_COPYAdviser copies results to clipboard
result_downloadRESULT_DOWNLOADAdviser downloads results as PDF or CSV
result_shareRESULT_SHAREAdviser shares results via a share action

Navigation

tool_navigateTOOL_NAVIGATEInter-tool navigation tracked for journey analysis
external_linkEXTERNAL_LINKClick on link to external resource or Guardian main site

Consent

consent_grantedCONSENT_GRANTEDUser grants analytics consent via banner
consent_deniedCONSENT_DENIEDUser denies analytics consent via banner

CPD / Webinar

webinar_startWEBINAR_STARTAdviser starts watching a CPD webinar
webinar_completeWEBINAR_COMPLETEAdviser completes a CPD webinar (reaches end)
quiz_startQUIZ_STARTAdviser begins a CPD assessment quiz
quiz_completeQUIZ_COMPLETEAdviser completes CPD quiz (includes pass/fail)
certificate_downloadCERTIFICATE_DOWNLOADAdviser downloads CPD certificate after passing quiz

Persistence

calculator_state_savedN/A (inline)Calculator inputs/results saved to localStorage for return visits

Consent Categories

Three-tier consent model, all optional

analytics

Page views, tool usage, event tracking

sessionReplay

Session recording for UX analysis (inputs masked)

featureFlags

Feature flags and A/B test bucketing

Default state: deny all (PECR compliant). Analytics only fire after explicit consent.

UTM Parameters

Campaign attribution via URL parameters

ParameterExamplePurpose
utm_sourceguardian_emailTraffic source
utm_mediumemailMarketing medium
utm_campaignspring_2026Campaign name
utm_contentcta_buttonContent variant
utm_termincome_protectionSearch term
firmacme_ifaCustom: referring firm
regionsouth_eastCustom: adviser region

Identity Resolution

Anonymous Phase

All users start anonymous. PostHog assigns a distinct_id via localStorage. No cookies required for basic tracking.

Azure AD Login

On authentication via Azure SWA, the user ID is SHA-256 hashed and passed to PostHog identify(). All prior anonymous events are stitched to the identified user.

Firm Grouping

Identified advisers are grouped by firm using PostHog groups. Enables firm-level analytics dashboards and cohort analysis.

Privacy note: Raw PII is never sent to PostHog. User IDs are SHA-256 hashed client-side before identification. Input values in session replays are masked by default.