Analytics

Adds a GA4-backed analytics dashboard inside the Payload admin, with KPIs, sessions, and lead-action tracking driven by the GA4 Data API and gtag.js.

Community 16 215/wk MIT v1.2.2

Installation

pnpm add @focus-reactive/payload-plugin-analytics

About

This plugin brings Google Analytics 4 data directly into the Payload CMS v3 admin. The `analyticsPlugin()` function injects a dashboard view at `/admin/analytics` and a set of REST endpoints under `/api/analytics/*`. Those endpoints read reports from the GA4 Data API using a Google Cloud service account. No analytics data is written to your database, so GA4 remains the single source of truth. The client half is a React provider. `AnalyticsProvider` paired with `ga4Provider()` wraps your front end, injects `gtag.js`, and tracks `page_view` events on initial load and on every route change. The `Track`, `TrackPage`, and `TrackLeadAction` components plus the `useAnalytics` hook let you fire engagement events and `lead_action` conversion events. Lead action types are configurable (for example `phone_click`, `email_click`, `form_submit`). The dashboard surfaces KPIs, traffic trends, top pages, sources, events, devices, geography, sessions, and journeys, along with a Lead Actions tab. An optional A/B tab integrates with the sibling `@focus-reactive/payload-plugin-ab` package. The dashboard layout is extensible through custom blocks, and endpoint access is configurable via an access function. A mock mode lets you develop against the dashboard locally without hitting GA4. Setup requires a GA4 property, a Measurement ID, and a service account with the Google Analytics Data API enabled. The service account needs Viewer access on the GA4 property. Event-scoped custom dimensions (`fr_session_id`, `fr_lead_type`, and others) and the `fr_elapsed_ms` custom metric must be registered in GA4 for the dashboards to populate. Reports inherit GA4 sampling and its data-freshness latency, so new events take a few minutes to appear.

Package info

Package name
@focus-reactive/payload-plugin-analytics
Latest version
1.2.2
Unpacked size
1.5 MB
License
MIT
Weekly downloads
215
Last publish
Jul 8, 2026

More from focusreactive

View profile

Similar plugins

More in Analytics