Site-wide page view tracking
A hidden background script runs on every Confluence page for every reader and sends a page view to your Google Analytics 4 property using Google's own gtag.js.
#How it works
The script lives in an invisible iframe that survives Confluence's single-page navigation. It notices navigation by watching the browser history and by re-checking every 3 seconds. Each view carries the page URL, the page title, the space key, the page id, the page type and the page version.
#What it needs
A GA4 Measurement ID (G-XXXXXXXXXX). Nothing else.
#Where you do it
Task | Where |
|---|---|
Open the settings page | Confluence > Settings > Apps > Google Analytics |
Set the Measurement ID and start collecting | View tracking panel > Data stream (if connected) or Measurement ID (manual) |
Turn on search, comment and page-edit events | Enhanced tracking panel > Measurement Protocol API secret |
#Settings that affect this
Setting | Where | What it does |
|---|---|---|
Connect Google Analytics / Disconnect | Settings > Apps > Google Analytics > Connect Google | Starts a Google sign-in popup. The connection is site-level: one admin connects once and the whole Confluence site uses it. Disconnect revokes access at Google and deletes the stored tokens. |
Data stream | Settings > Apps > Google Analytics > View tracking | Picking a web data stream fills in the Measurement ID for you. |
Measurement ID | Settings > Apps > Google Analytics > View tracking | The GA4 tag ID (G-XXXXXXXXXX). This is the single required setting: nothing is collected anywhere until it is set. |
#Worth knowing
Switching GA4 property discards the Measurement ID and the API secret selection, and tracking stays off until you set them again.
#Related
How it actually behaves.
