> ## Documentation Index
> Fetch the complete documentation index at: https://dhiwisepvtltd-5e04e6a4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics

> Add Google Analytics 4 to your Rocket.new app to track page views, conversion events, traffic sources, and campaign attribution from chat.

Describe what you want to measure in chat and Rocket wires up the tracking tags, custom events, and e-commerce data layer automatically.

## What you can do

> **Traffic and page view tracking**
>
> See which pages users visit most, where they come from, and how long they stay.

> **Conversion goals**
>
> Track key actions like signups, form submissions, and purchases as GA4 conversion events.

> **E-commerce tracking**
>
> Send product views, add-to-cart actions, and purchase events to GA4 for revenue reporting.

> **Audience insights**
>
> Understand your user demographics, devices, and geographic distribution.

> **Custom event tracking**
>
> Track any interaction as a custom GA4 event with parameters you define.

## Before you connect

You need your **Measurement ID** from Google Analytics. It starts with `G-`, for example `G-XXXXXXXXXX`.

> **Find your Measurement ID** from the Google Analytics help center.
>
> [Open](https://support.google.com/analytics/answer/12270356?hl=en)

Go to **Admin > Data Streams**, click your stream, and copy the **Measurement ID**.

> [!NOTE]
>
> Google Analytics is a **task-level** connector. Each Rocket task connects to its own Measurement ID independently.

## Connect Google Analytics

**Web Browser**

You can connect from two places. Both do the same thing.

**Option 1: From chat**

Type a prompt that mentions Google Analytics, for example `Connect Google Analytics and track page views on every route`. Rocket detects the intent and shows a **Connect** button inline. Click it to open the credentials popup.

![Rocket chat panel showing a Connect prompt for Google Analytics.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-chat-light.webp)

![Rocket chat panel showing a Connect prompt for Google Analytics.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-chat-dark.webp)

Google Analytics connection prompt in chat

**Option 2: From the Connectors tab**

Click the **`...`** button in the preview toolbar, then select **Connectors**.

Open Connectors from the toolbar

Click the **Google Analytics** card, then click **Connect**.

![Connectors panel showing the Google Analytics card with a Connect button.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-connectors-tab-light.webp)

![Connectors panel showing the Google Analytics card with a Connect button.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-connectors-tab-dark.webp)

Google Analytics card in the Connectors panel

**After clicking Connect**

A popup opens. Enter your **Measurement ID**, then click **Connect**.

![Connect Google Analytics popup with Measurement ID field.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-popup-light.webp)

![Connect Google Analytics popup with Measurement ID field.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-popup-dark.webp)

Connect Google Analytics popup

A green dot appears next to Google Analytics when the connection is active.

**Update or disconnect**

Open [**Connectors > Google Analytics**](#connect-google-analytics) and click the card. Click **Edit** to update your Measurement ID or **Disconnect** to remove the integration from this task.

![Google Analytics card showing Edit and Disconnect buttons.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-disconnect-light.webp)

![Google Analytics card showing Edit and Disconnect buttons.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/google-analytics/web-browser/google-analytics-disconnect-dark.webp)

Edit and Disconnect options on a connected Google Analytics card

**Mobile App**

You can connect from two places. Both do the same thing.

**Option 1: From chat**

Type a prompt that mentions Google Analytics. Rocket detects the intent and shows a **Connect** button inline. Tap it to open the credentials screen.

**Option 2: From the Connectors tab**

1. Tap the **More** button in the header.
2. Tap **Integrations**.
3. Tap the **Google Analytics** card, then tap **Connect**.

**After tapping Connect**

A popup opens. Enter your **Measurement ID**, then tap **Done**.

A green dot appears next to Google Analytics when the connection is active.

**Update or disconnect**

Go back to the **Google Analytics** card in Integrations. Tap **Edit** to update your Measurement ID or **Disconnect** to remove it from this task.

## Example prompts

| What you want | Prompt to use |
| :- | :- |
| Page views | `Track page views on every route and send them to Google Analytics automatically.` |
| Button clicks | `Track clicks on the Sign Up and Contact Sales buttons as GA4 custom events.` |
| Form submissions | `Send a conversion event to GA4 when users submit the contact form.` |
| E-commerce purchase | `Track completed purchases with order total, product names, and quantities in GA4.` |
| Scroll depth | `Track when users scroll past 25%, 50%, 75%, and 100% of the page.` |
| Outbound links | `Track clicks on external links as GA4 events with the destination URL.` |
| Search tracking | `Send a search event to GA4 when users use the site search bar, including the query.` |
| Video engagement | `Track play, pause, and completion events for embedded videos in GA4.` |
| UTM attribution | `Parse UTM parameters from the URL and forward them to GA4 as campaign data.` |
| User properties | `Set GA4 user properties for plan type and signup date when users log in.` |

## Tips

* **Tracking only works on deployed tasks.** Google Analytics does not fire events in the Rocket preview. Deploy your task and test on the live URL.
* **GA4 data has a processing delay.** Real-time reports update within seconds, but standard reports may take 24 to 48 hours to fully populate.
* **Only GA4 Measurement IDs are supported.** IDs start with `G-`. Universal Analytics (`UA-`) was sunset in 2024 and no longer processes data.
* **Ad blockers may prevent tracking.** Some users run browser extensions that block Google Analytics scripts. Keep this in mind when evaluating traffic numbers.
* **One Measurement ID per task.** Each Rocket task connects to one Google Analytics property. Use different tasks for different properties.

## What's next?

> **[Mixpanel](https://dhiwisepvtltd-5e04e6a4.mintlify.site/build/connectors/mixpanel.md)**
>
> Need deeper event-level analytics? Add Mixpanel for funnel analysis and user segmentation.

> **[Stripe](https://dhiwisepvtltd-5e04e6a4.mintlify.site/build/connectors/stripe.md)**
>
> Track checkout conversion rates and revenue attribution with Stripe and GA4 together.

> **[AdSense](https://dhiwisepvtltd-5e04e6a4.mintlify.site/build/connectors/adsense.md)**
>
> Monetize your traffic with Google AdSense display ads.

> **[Netlify](https://dhiwisepvtltd-5e04e6a4.mintlify.site/build/connectors/netlify.md)**
>
> Deploy your task so Google Analytics can start collecting real data.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.