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

# Google Analytics

> Add a bot to Google Analytics using the official integration.

[Open in Hub](https://studio.botpress.cloud/home?exploreHub=1\&hubItemId=intver_01HXS7S3FCANEG2EN5FKKWH722)
*v0.2.4*

The official Google Analytics integration allows your bot to interact with your GA4 data stream.

## Setup

> [!NOTE]
>
> You will need:
>
> * A [published bot](https://botpress.com/docs/get-started/quick-start.md)
> * A [Google Analytics](https://analytics.google.com) account
> * A [GA4 property](https://support.google.com/analytics/answer/10089681?hl=en\&ref_topic=14089939\&sjid=6192877767184430915-NC) with at least one [data stream](https://support.google.com/analytics/answer/9303323?hl=en#streams\&zippy=%2Cin-this-article)

**1. Install the integration in Botpress**

First, install the integration to your bot:

1. In Botpress Studio, select \*\* Explore Hub\*\* in the upper-right corner.
2. Search for the **Google Analytics** integration.
3. Select **Install Integration**.

In the **Configuration** menu, you should see two fields:

* **Measurement ID**: The Measurement ID for your Google Analytics 4 property
* **API secret**: The API Secret for your Google Analytics 4 property

Leave these empty for now—you'll come back to them after completing the setup in Google Analytics.

**2. Get your measurement ID**

Next, get your GA4 measurement ID:

1. Log in to [Google Analytics](https://analytics.google.com).
2. In the bottom-left corner, select **Admin**.
3. Under **Property settings > Data collection and modification**, select **Data streams**.
4. Select the data stream you want to interact with.
5. Copy its **Measurement ID**. It should start with `G-`.

**3. Get your API secret**

Now, get your GA4 API secret:

1. In the same data stream menu, select **Measurement protocal API secrets**.
2. If you haven't reviewed the terms yet, select **Review terms**.
3. Select **Create** and give the secret a nickname.
4. Copy the secret's value.

**4. Configure the integration in Botpress**

Now, you can finish setting up the integration in Botpress:

1. In the **Measurement ID** field, paste the ID you copied earlier.
2. In the **API secret** field, paste the secret you copied earlier.
3. Select **Save Configuration**.

> [!TIP]
>
> Your Google Analytics integration is ready. You can use the integration's [Cards](#cards) to interact with your data stream.

## Cards

{/* vale off */}

Here's a reference for all [Cards](https://botpress.com/docs/studio/concepts/cards/introduction.md) available with the integration:

### Track Event

Track event in Google Analytics

**input** `object`

**userId** `string` *required*

The user ID to track

**eventName** `string` *required*

The event name to track

**eventPayload** `string`

The properties of the event as a JSON String

**output** `object`

This Card has no output.

### Track Node

Tracks when a node has been triggered, recording it as a page view in Google Analytics.

**input** `object`

**userId** `string` *required*

The user ID to track

**nodeId** `string` *required*

A unique ID representing the Node being tracked

**output** `object`

This Card has no output.

### Update User Profile

Updates the User's profile in Google Analytics

**input** `object`

**userId** `string` *required*

The user ID of the profile you want to update

**userProfile** `string`

JSON String of a user's metadata (e.g., email, name)

**output** `object`

This Card has no output.


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