Sitecore XM Cloud - Google Analytics Marketplace Module
September 3, 2025 ยท View on GitHub
A Sitecore XM Cloud Marketplace module that enables seamless Google Analytics integration within the XM Cloud environment. This module provides real-time analytics data visualization, including page views and active user metrics, directly within your Sitecore experience.
๐ Features
- Real-time Analytics Dashboard: View Google Analytics data directly in XM Cloud
- Interactive Data Visualization: Dynamic charts for page views and active users
- Responsive Design: Modern UI built with Chakra UI and Sitecore Blok theme
- Flexible Date Ranges: Analyze data from 1 to 90 days
- Site-specific Analytics: Automatic filtering based on current XM Cloud site context
- Easy Configuration: Streamlined setup process within XM Cloud environment
- Marketplace Integration: Full integration with Sitecore Marketplace SDK
๐ Prerequisites
Sitecore Environment
- Sitecore XM Cloud environment.
Google Analytics Setup
- Google Analytics 4 (GA4) property
- Google Cloud Project with Analytics Reporting API enabled
- Service Account with appropriate permissions
๐ง Installation & Setup
1. Deploy to XM Cloud
This module is designed to be deployed as a Marketplace module within Sitecore XM Cloud.
2. Configure Google Service Account
Create Google Cloud Project & Service Account
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Analytics Reporting API
- Create a Service Account under APIs & Services > Credentials
- Download the JSON key file for the service account
Add Service Account to Google Analytics
- Go to Google Analytics Admin panel
- Navigate to your GA4 property
- Go to Property Settings > Property Access Management
- Add the service account email with Read & Analyze permissions
3. Environment Configuration
Set up the following environment variables in your XM Cloud environment:
GA_CLIENT_EMAIL=your-service-account@project.iam.gserviceaccount.com
GA_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour-Private-Key-Here\n-----END PRIVATE KEY-----"
Finding your GA4 Property ID:
- Go to Google Analytics > Admin > Property Details
- Find the Property ID in the top right corner
๐๏ธ Development
Local Development Setup
- Clone the repository:
git clone [repository-url]
cd marketplace-google-analytics
- Install dependencies:
npm install
- Set up environment variables:
Create a
.env.localfile with your Google Analytics credentials:
GA_CLIENT_EMAIL=your-service-account-email
GA_PRIVATE_KEY=your-private-key
- Run development server:
npm run dev
The application will be available at http://localhost:3000, but needs to be loaded with in the Sitecore Marketplace extension points to run correctly.
๐ License
This project is licensed under the Apache License 2.0 LICENSE.md.
๐ Issues
If you encounter any issues or have suggestions for improvements, please open an issue on the repository.