# Google Analytics via Webhook

### Find your Google Measurement ID and API Secret

To configure Google Analytics 4 via Webhook, you will need your Google Measurement ID and API Secret. Note that the Measurement ID and the API Secret should be selected from the relevant data stream.

* Log in to [Google Analytics](https://analytics.google.com/).
* Click on Admin.
* Under 'Property', go to Data Streams.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FmDdQRKHFW8qpNHZICuqM%2FGA4_DataStreams.png?alt=media&#x26;token=c8365d07-9a8b-4124-9845-ed92a760cd57" alt=""><figcaption></figcaption></figure>

* Click on the Data Stream you wish to connect to CrossEngage.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2F3CgQht5ydyccqJuwYQls%2FGA4_ChooseStream.png?alt=media&#x26;token=3fdf5e0b-a477-499d-b01e-ed5d5c4aaba5" alt=""><figcaption></figcaption></figure>

* Copy your measurement ID. This will be needed in CrossEngage.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2F83zOZ8OvarJJXbQN8izW%2FGA4_MeasurementID.png?alt=media&#x26;token=18bb86f0-6152-48eb-bdd5-bf71d676d5fd" alt=""><figcaption></figcaption></figure>

* Scroll down to events. Click on 'Measurement Protocol API Secrets".
* If you have not yet created an API Secret, create a new Secret.
* Copy your API Secret. This will be needed in CrossEngage.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2F5dvNbCKTHwwHse38Njpk%2FGA4_APISecret.png?alt=media&#x26;token=28c775fe-49b0-44c0-b776-f0d987d51f05" alt=""><figcaption></figcaption></figure>

### Configure Google Analytics via Webhook

* In the CrossEngage app, navigate to `Settings` > `Integrations`.
* Click the `Add new integration` button in the top right corner of the page.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FAgS47R9XoM50Wg0ysO8G%2FIntegrations_new.png?alt=media&#x26;token=f0b23923-4d5f-4b08-85d8-b97df995be9f" alt=""><figcaption></figcaption></figure>

* Search for 'webhook'  and click **Set up.**

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FAssbCrU7pujLgNzQoowO%2FIntegrations_Webhook.png?alt=media&#x26;token=eda410c6-53ac-4d81-9fde-3a085d2b64c9" alt=""><figcaption></figcaption></figure>

Using this information, you can now complete the setup form.

* Method: POST
* Destination URL: [https://www.google-analytics.com/mp/collect?measurement\_id=\<yourMeasurementId>\&api\_secret=\<yourAPISecret>](https://www.google-analytics.com/mp/collect?measurement_id=yourMeasurementId\&api_secret=yourAPISecret)
* Authentication: No authentication
* Content type: application/JSON

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FsacZ97Qg41FLfwg6AdCM%2FIntegrations_WEbhook_Form_GA4.png?alt=media&#x26;token=ed4668d0-9c69-438d-bfab-3dc061729f2f" alt=""><figcaption></figcaption></figure>

In the JSON text, paste the following JSON body:

```
{
    "client_id": "handlebar to fetch client id",
    "user_id": "handlebar to fetch user id",
    "events": [
        {
            "name": "event name",
            "params": {
                "param1": "xyz",
                "param2": "xyz"
            }
        }

]

}
```

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FwpHg8P2a8mhTFsOTsa2L%2F4adf02ab-efcc-4038-8c32-fd5475d4182d.png?alt=media&#x26;token=4ff0c37a-a29a-4144-9ce2-b363b31adc78" alt=""><figcaption></figcaption></figure>

* Click 'Apply'.

You can now use this integration in a campaign. When using the integration in a campaign, update the campaign message with the handlebars, event name, and parameters.&#x20;


---

# 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://documentation.crossengage.io/data-and-engagement-platform/messages/integrations/channels/webhooks/google-analytics-via-webhook.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.
