GA Analytics
docs
Plugin

Introduction

sanity-plugin-ga-dashboard brings a full GA4 dashboard into Sanity Studio — so your content team sees analytics right where they write, with zero context switching.

Why this plugin?

Content teams shouldn't need to tab over to Google Analytics to check if a post is performing. This plugin surfaces the data they care about — pageviews, traffic sources, real-time users — directly inside the Studio, helping editors make faster, data-driven decisions.

Features

Analytics

Overview Metrics

10 KPIs — users, sessions, pageviews, bounce rate, engagement rate, session duration.

Traffic & Channels

Time series & hourly charts plus channel grouping.

Content & Pages

Top 15 pages and 10 landing pages with session counts.

Audience

Audience & Devices

Device, browser & OS breakdown, new vs returning.

Geography

Top 10 countries and cities by active users.

Events & Acquisition

Top 15 events, traffic sources, referrers.

Platform

16 Parallel Queries

All data fetched at once via Promise.allSettled() — fast first load.

Smart Caching

5-min public cache + 1-hour in-memory token cache.

Date Ranges

7, 14, 30 or 90 day views.

Service Auth

JWT-based GCP service account — no OAuth required.

Full TypeScript

Exported types for all API data structures.

Dashboard Tabs

Seven sections, all loaded in a single API call.

01
Overview

10 KPIs, daily time-series area chart, hourly traffic bar chart, and a live active-user badge showing the last 30 minutes.

02
Traffic

Channel grouping donut, daily sessions trend, top-10 traffic sources table, and top referrer URLs.

03
Content

Top 15 pages by screen page views and top 10 landing pages by sessions — ranked tables with sparkline indicators.

04
Audience

Device category split, browser & OS distribution charts, and a new vs returning visitor ratio gauge.

05
Geography

Top 10 countries and top 10 cities ranked by active user count with session percentages.

06
Events

Top 15 GA4 events — automatically collected and custom — with event count and unique user count per event.

07
Acquisition

Traffic sources by session/medium pair, channel grouping breakdown, and top external referrer URLs.

Quick Example

sanity.config.ts
import { defineConfig } from 'sanity'
import { googleAnalyticsPlugin } from 'sanity-plugin-ga-dashboard'

export default defineConfig({
  name: 'my-project',
  title: 'My Project',
  projectId: 'your-project-id',
  dataset: 'production',
  plugins: [
    googleAnalyticsPlugin(),  // GA4 dashboard is now live
  ],
  schema: { types: [/* your schemas */] },
})