# Google Analytics (GA4)

## Google Analytics 4 (GA4) Setup for Realty AI

Realty AI tracks chatbot interactions and lead events in your Google Analytics 4 property using the GA4 Measurement Protocol. This is a server-side integration, no additional scripts or tags need to be installed on your website.

To enable this, we just need two things from your GA4 account: your **Measurement ID** and a **Measurement Protocol API Secret**.

***

### What You'll Need

* Access to your Google Analytics 4 property (Admin permissions required)
* Your GA4 **Measurement ID** (starts with `G-`)
* A **Measurement Protocol API Secret**

***

### Step 1: Find Your Measurement ID

* Log in to [Google Analytics](https://analytics.google.com)
* Click **Admin** (gear icon) in the bottom-left corner
* Under your property, click **Data Streams**

<figure><img src="/files/G0yW8UEEsjtPpDIyO6Ai" alt=""><figcaption></figcaption></figure>

* Click on your **web data stream** (the one for your website)
* Your **Measurement ID** is displayed in the top-right of the stream details panel — it starts with `G-` followed by a mix of letters and numbers (e.g., `G-9S8LHBZMK7`)
* Click the copy icon next to it to copy it

<figure><img src="/files/AEazkJCmB8gGuVLr0qmj" alt=""><figcaption></figcaption></figure>

### Step 2: Create an API Secret

1. On the same Data Stream page, click **Measurement Protocol API secrets**
2. Click **Create**, name it `Realty AI`, then click **Create**
3. Copy the **Secret value**

<figure><img src="/files/gc5Wjv3XEgR2pCgwUk5D" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/mvYKCvuDoiZZU5C5fM91" alt=""><figcaption></figcaption></figure>

### Step 3: Copy Both to Realty AI Dashboard

<figure><img src="/files/BFVIbfoAdIzBK8tB1JfP" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/TC3SPy2xRKaigJpbJIf4" alt=""><figcaption></figcaption></figure>

| Field              | Example                   |
| ------------------ | ------------------------- |
| **Measurement ID** | `G-9S8LHABCD6`            |
| **API Secret**     | `l4PN-81m4stW64zUg1skfdi` |

**Step 4: Mark `chatbot_contact_created` as a Key Event (Required for Google Ads)**

Once Realty AI is connected, chatbot events will begin appearing in your GA4 property, including `chatbot_opened`, `chatbot_conversation_started`, `chatbot_message_sent`, and `chatbot_contact_created`. The most important of these is `chatbot_contact_created` -- this fires when a lead is captured by the chatbot.

To use this for Google Ads conversion tracking:

1. In GA4, go to **Admin > Data Display > Events**
2. Find `chatbot_contact_created` in the event list
3. Click the **star icon** to the left of the event name to mark it as a Key Event
4. In Google Ads, link your GA4 property under **Tools > Conversions** and import the Key Event

> Note: It may take **24-48 hours** for the event to appear in your list after the chatbot starts receiving conversations, and another **24-48 hours** after marking it as a Key Event for it to show up in Google Ads.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://realty-ai.gitbook.io/realty-ai-support-docs/crm-integration/google-analytics-ga4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
