SaasCore Docs
  • Get Started
  • Configuration
    • Database
    • Stripe
      • Product ID and Price ID
      • API keys
      • Stripe Webhook
    • Emails
      • Cron Jobs
    • Claudinary
    • Chat plugin
    • Upstash Redis
    • OAuth with Google and GitHub
    • Subscription types and plans
    • Affiliate program
    • Google Analytics Api
  • Landing page
    • Header
    • Hero
      • Discount
      • AvatarCircles
    • Other components
  • Authentication Flow
    • For Admins
    • For Clients
      • OAuth
      • Credentials
    • For Affiliates
  • Payments
    • Payment Flow Scenarios
      • Scenario 1: Registered Client
      • Scenario 2: Direct Subscription from Home Page
      • Upgrading/Downgrading/Canceling Subscriptions
    • Pricing Table
  • Component Protection
  • Pending ...
Powered by GitBook
On this page
  1. Configuration

Google Analytics Api

Setting Up Google Analytics Variables for GA4 Integration

PreviousAffiliate programNextLanding page

Last updated 4 months ago

The Analytics section is built using the Google Analytics API. Below are the variables you need to configure to make it work:

  • GOOGLE_ANALYTICS_GA_ID=

  • GOOGLE_ANALYTICS_CLIENT_EMAIL=

  • GOOGLE_ANALYTICS_PRIVATE_KEY=

  • GOOGLE_ANALYTICS_PROPERTY_ID=

Retrieving GOOGLE_ANALYTICS_GA_ID:

  1. Go to .

  2. Set up a new GA4 property and obtain the Measurement ID (e.g., G-XXXXXXX).

Retrieving GOOGLE_ANALYTICS_PROPERTY_ID:

  1. In Google Analytics 4 (GA4), select your property.

  2. Click the gear icon (⚙️) at the bottom left to open Admin settings.

  3. In the Property column (middle section), click Property Settings.

  4. Your Property ID will be displayed at the top of the page in this format: XXXXXXXXX.

Retrieving GOOGLE_ANALYTICS_CLIENT_EMAIL and GOOGLE_ANALYTICS_PRIVATE_KEY:

Steps:

  1. Enable the Analytics Data API:

    • Go to the Google Cloud Console.

    • Create or select a project.

    • Enable the Analytics Data API.

  2. Create a Service Account:

    • In the Google Cloud Console, go to IAM & Admin → Service Accounts.

    • Create a new service account and download the JSON key file.

    • In the JSON file:

      • client_email corresponds to GOOGLE_ANALYTICS_CLIENT_EMAIL.

      • private_key corresponds to GOOGLE_ANALYTICS_PRIVATE_KEY.

Final Step: Share GA4 Access with the Service Account

  1. In your GA4 property, go to Admin → Account Access Management.

  2. Add the service account email (e.g., service-account-name@project-id.iam.gserviceaccount.com) with Viewer or higher permissions.

Google Analytics