Analytics Dashboard

Pro Feature — The analytics dashboard is available in the Pro and Agency tiers.

Unfold CMS integrates with Google Analytics 4 (GA4) to display traffic data directly in the admin dashboard. This saves you from switching between your CMS and Google Analytics.

Overview

The analytics integration provides:

  • Dashboard widget — Key metrics displayed on the admin dashboard
  • Period selection — View data for different time ranges
  • Cache management — Analytics data is cached to reduce API calls
  • Settings management — Configure GA4 credentials through the admin panel

Configuration

Requirements

To enable the analytics dashboard, you need:

  1. A Google Analytics 4 property
  2. A GA4 Property ID (numeric)
  3. A Google Service Account JSON key file with access to the GA4 property

Configure analytics in Settings > General > Analytics in the admin panel.

Setting Up Google Analytics

Step 1: Create a GA4 Property

  1. Go to analytics.google.com
  2. Create a new GA4 property if you don't already have one

Step 2: Enable the Analytics Data API

  1. Go to Google Cloud Console
  2. Navigate to APIs & Services > Library
  3. Search for Google Analytics Data API
  4. Click Enable — this allows your service account to query GA4 data

Step 3: Create a Service Account

  1. In the same Google Cloud project, navigate to IAM & Admin > Service Accounts
  2. Click Create Service Account
  3. Give it a name (e.g., "Unfold CMS Analytics")
  4. Click Done (no additional roles needed at this step)
  5. Click on the newly created service account
  6. Go to the Keys tab
  7. Click Add Key > Create new key > JSON
  8. Download the JSON key file — you'll upload this in the CMS settings

Step 4: Grant GA4 Access to the Service Account

  1. Go to analytics.google.com
  2. Navigate to Admin > Property > Property Access Management
  3. Click + > Add users
  4. Enter the service account email (found in the JSON file — looks like [email protected])
  5. Grant the Viewer role
  6. Click Add

Step 5: Configure in CMS

  1. Go to Settings > General > Analytics in the admin panel
  2. Enter your GA4 Property ID (numeric, found in GA4 Admin > Property Settings)
  3. Upload the Service Account JSON key file

If You Use Google Tag Manager (GTM)

If you've already added GTM via Code Snippets and configured GA4 inside your GTM container, you do not need to enter the Measurement ID in the CMS analytics settings.

The Measurement ID (G-XXXXXXXXXX) is only needed for the built-in GA4 tracking script (in Settings > General > Analytics). When GA4 is fired through GTM, the tracking is already handled by your GTM container.

However, you still need the Property ID and Service Account JSON in the CMS analytics settings — these are used by the server-side API to fetch analytics data for the admin dashboard widget. The Measurement ID and Property ID serve different purposes:

Field Purpose When Needed
Measurement ID (G-XXXXXXXXXX) Client-side tracking script Only if NOT using GTM for GA4
Property ID (numeric) Server-side API for dashboard widget Always (for the analytics dashboard)
Service Account JSON Authentication for the API Always (for the analytics dashboard)

Dashboard Widget

When enabled, the analytics widget appears on the admin dashboard showing:

  • Page views
  • Unique visitors
  • Session duration
  • Bounce rate
  • Top pages

Period Selection

The dashboard supports different time periods, defaulting to 30 days. Select a different period to view historical data.

Cache

Analytics data is cached to minimize API calls to Google. The cache duration is configurable (default: 60 minutes).

To refresh data immediately, use the Clear Cache button in the analytics widget.

Disabled State

When analytics is disabled or not configured:

  • The dashboard widget shows empty/placeholder state
  • No API calls are made to Google
  • The analytics settings page remains accessible for configuration

Troubleshooting

If the analytics dashboard shows an error banner, here are the most common causes:

Error Message Cause Fix
"Service account does not have access" The service account email hasn't been added to the GA4 property Go to GA4 Admin > Property Access Management, add the service account email as Viewer
"Invalid service account credentials" The JSON key is malformed or expired Re-download the JSON key from Google Cloud Console and re-upload it
"GA4 property not found" The Property ID is incorrect Verify the numeric Property ID in GA4 Admin > Property Settings
"Google Analytics SDK not installed" The google/apiclient-services package is missing Run composer install
"Failed to fetch analytics data" Generic API error Check the Laravel log (storage/logs/laravel.log) for details

Common setup mistakes:

  • Forgetting to enable the Analytics Data API in Google Cloud Console (Step 2)
  • Using the Measurement ID instead of the Property ID — the Measurement ID starts with G-, the Property ID is a plain number
  • Not granting GA4 access to the service account (Step 4) — creating the service account alone is not enough
  • Code Snippets — Alternative: inject GA4 tracking code directly via GTM or standalone
  • Configuration — Analytics settings reference