> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextd.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics

> Integrate Google Analytics 4 (GA4) for comprehensive website analytics, user behavior tracking, and data-driven insights.

## Overview

This guide will help you integrate Google Analytics 4 (GA4) in your website projects on the Nextd platform to achieve professional website data analytics and user behavior tracking.

## Feature Overview

Through Google Analytics integration, you can:

* Track website traffic and user behavior
* Analyze page view data and user paths
* Monitor conversion rates and business metrics
* Get real-time access statistics

## Prerequisites

Before starting integration, please ensure the following conditions are met:

* **Website Published**: Your website project has been successfully published on the Nextd platform and is accessible via domain
* **Google Account**: Have access to Google Analytics account permissions
* **Domain Access**: Confirm the published website domain is accessible

## Quick Start

### Step 1: Access or Create Google Analytics Account

1. Visit the official [Google Analytics](https://analytics.google.com/) website

**If you already have a Google Analytics account:**

* Log into your Google Analytics console
* Skip to Step 2 to configure your property

**If this is your first time using Google Analytics:**

* Click the **"Start measuring"** button to create a new account
* Complete basic configuration following the setup wizard:
  * Set account name and region timezone
  * Select industry category and reporting objectives
  * Configure data sharing settings

### Step 2: Configure Google Analytics Property

**If you already have a suitable property:**

1. Select your target property and go to the **"Admin"** panel
2. In property list, select **"Data collection and modification"** → **"Data streams"**
3. Skip to Step 3 if you have an appropriate web data stream, or continue to create a new one

**If you need to create a new property or data stream:**

1. In the platform selection stage, choose the **"Web"** option
   > **Note**: Nextd currently only supports website projects, do not select iOS/Android apps

2. Configure web data stream information:
   * **Website URL**: Enter the complete domain of your website published on Nextd
   * **Stream Name**: Set an easily identifiable name (recommended format: project-name-environment)
   * Click **"Create stream"** to complete setup

### Step 3: Get Google Analytics Tracking Code

**For new data streams:**

* After creation, the system will automatically display the Google Tag (gtag.js) installation code

**For existing data streams:**

1. Click on your existing web data stream to enter the details page
2. Find the **"Google tag"** area
3. Click **"View tag instructions"**
4. Switch to the **"Install manually"** tab

You will see code similar to this:

```html theme={null}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>
```

### Step 4: Configure Integration in Nextd

1. Copy the complete Google Tag code from Step 3
2. Return to your Nextd project management interface
3. Go to **"Integration Management"** page in project settings
4. Find the Google Analytics integration option
5. Paste the copied code into the input box
6. Click **"Connect"** button to generate new version

### Step 5: Republish Website

> **Critical Step**: After configuration, you must republish the website for Google Analytics to start collecting data

## Verification and Testing

After completing integration configuration, please perform the following verification:

1. **Google Analytics Side Verification**:
   * Click **"Test connection"** on data stream page
   * Check if test data can be received normally

2. **Browser Side Verification**:
   * Open published website
   * Use browser developer tools to check Network panel
   * Confirm successful requests to `googletagmanager.com`

3. **Real-time Data Confirmation**:
   * View **"Realtime"** reports in Google Analytics
   * Visit website and observe real-time user data changes

## Data Analysis & Insights

<CardGroup cols={2}>
  <Card title="Real-time Reports">
    * Current active users and live activity
    * Real-time page views and events
    * Geographic user distribution
    * Traffic source monitoring
  </Card>

  <Card title="Historical Analysis">
    * Long-term traffic trends and patterns
    * User acquisition and retention metrics
    * Conversion tracking and goal analysis
    * Revenue and e-commerce insights
  </Card>
</CardGroup>

## Data Processing Timeline

**Real-time Data:** Updates within 1-5 minutes\
**Standard Reports:** 24-48 hour processing delay\
**New Integrations:** Allow several hours for complete data population

## Frequently Asked Questions

<Accordion title="Must I republish after configuration?">
  **Yes, absolutely.** Every time you update Google Analytics configuration in Nextd, you must republish the website for changes to take effect. This ensures the tracking code is properly embedded in your live site.
</Accordion>

<Accordion title="Why can't I see data?">
  **Troubleshooting checklist:**

  * Confirm website has been republished after configuration
  * Verify Google tag code format is complete and correct
  * Allow processing time (new integrations need several hours)
  * Check real-time reports for immediate connection verification
  * Use browser developer tools to confirm script loading
</Accordion>

<Accordion title="Can I just use the measurement ID?">
  **No.** You must paste the complete JavaScript code provided by Google Analytics, not just the measurement ID (G-XXXXXXXXXX). The full code includes necessary initialization and configuration.
</Accordion>

<Accordion title="How do I track custom events?">
  **After successful integration, you can:**

  * Use `gtag('event', 'event_name', parameters)` function
  * Configure enhanced measurement in Google Analytics
  * Set up custom dimensions and metrics
  * Refer to GA4 documentation for advanced event configuration
</Accordion>

<Accordion title="Multi-environment support?">
  **Best practice:** Create separate data streams for different environments:

  * Development: `mysite-dev.nextd.app`
  * Staging: `mysite-staging.nextd.app`
  * Production: `mysite.com`

  This prevents data mixing and enables proper team collaboration.
</Accordion>

***

*Need assistance with your Google Analytics integration? Our technical support team is ready to help you get up and running.*
