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

# Send Data to Google Analytics

> Send user interaction data from MoEngage to Google Analytics via connectors and the GA Measurement Protocol. Works with GA4 and Universal.

Developers can now send data from **MoEngage to Google Analytics tool using our Connectors** via GA Measurement Protocol.

Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers. This in turn enables developers to measure how users interact with their business from almost any environment. Developers can then use the Measurement Protocol to:

* Measure user activity in new environments.
* Tie online to offline behavior.
* Send data from both the client and server.

# Measurement Protocol (Google Analytics 4)

Google Analytics 4 only supports POST calls. To send an event, make a `HTTP POST` request to the following endpoint:

```text theme={null}
POST /mp/collect HTTP/1.1
HOST: www.google-analytics.com
Content-Type: application/json
<payload_data>
```

Data is sent to Google Analytics using the Measurement Protocol Data in two parts:

1. Query parameters
2. A `JSON` `POST` body

### Query Parameters

| Parameter Name    | Description                                                                                                                                                                                                                                                                                                    |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `api_secret`      | **Required.**<br />An `API Secret` that is generated through the Google Analytics UI. An API Secret that is generated through the Google Analytics UI.  <br />To create a new secret, navigate in the Google Analytics UI to:  <br />Admin > Data Streams > choose your stream > Measurement Protocol > Create |
| `measurement_id`  | Optional.  <br />Measurement ID. The identifier for a Data Stream. Found in the Google Analytics UI under:  Admin > Data Streams > choose your stream > Measurement ID                                                                                                                                         |
| `firebase_app_id` | **Required only if using a Firebase app.**<br />Firebase App ID. The identifier for a Firebase app. Found in the Firebase console under:  Project Settings > General > Your Apps > App ID                                                                                                                      |

[Read more](https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=gtag#payload) about the required query parameters of the Measurement Protocol.

### JSON POST body

The payload of your request depends on the events and attributes that you want to track. Below are the required fields:

| Parameter Name    | Description                                                                                                                                                                                                    |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client_id`       | **Required only if using gtag.js.**<br />Uniquely identifies a user instance of a web client. See [send event to the Measurement Protocol](https://developers.google.com/gtagjs/reference/api#get_mp_example). |
| `app_instance_id` | **Required only if using a Firebase app.**<br />Uniquely identifies a specific installation of a Firebase app. This value needs to be retrieved through the Firebase SDK.                                      |
| `events`          | **Required.**<br />An array of event items.                                                                                                                                                                    |

[Read more](https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=firebase#payload_post_body) about the required JSON post-body parameters of the Measurement Protocol.

# Setting up a connector campaign

To create a connector campaign on MoEngage,

1. On the sidebar menu in MoEngage, hover over the **Engage** icon <img alt="Screenshot 2025-06-04 at 4.32.53 PM.png" src="https://mintcdn.com/moengage/_eUNBDpGCEXI_sgZ/images/moengage_a7dd26.png?fit=max&auto=format&n=_eUNBDpGCEXI_sgZ&q=85&s=2764f79fb9cde7c83658ff6e78509adb" style={{ display: 'inline-block'}} width="38" height="32" data-path="images/moengage_a7dd26.png" /> . The **Engage** menu appears.
2. Click **+ New Campaign**. <img src="https://mintcdn.com/moengage/2CGhjk8ZDWEC5ocb/images/moengage_f74486.png?fit=max&auto=format&n=2CGhjk8ZDWEC5ocb&q=85&s=e344b7bc1ab0415136cdde4b0926036d" alt="1.png" width="562" height="474" data-path="images/moengage_f74486.png" /> You can also click **All Campaigns** on the **Engage** menu and then click **+ Create campaign** on the **All campaigns** page.
3. On the **New Campaign** dialog box, under **Connectors**, click **Event Triggered**. <img src="https://mintcdn.com/moengage/2FjM3dGfEH1CYo8k/images/moengage_6377c7.png?fit=max&auto=format&n=2FjM3dGfEH1CYo8k&q=85&s=404a26a988e839fa060e7e149f4f3e13" alt="custom.png" width="1020" height="1104" data-path="images/moengage_6377c7.png" />
4. Give your campaign a name and relevant tags.
5. Configure your trigger criteria. You can optionally choose to add a delay as well. <img src="https://mintcdn.com/moengage/t9d2bz7zij1iE1iP/images/moengage_9e50d3.png?fit=max&auto=format&n=t9d2bz7zij1iE1iP&q=85&s=9bfaa7ce27f1a7865737ba45327305a3" width="1492" height="838" data-path="images/moengage_9e50d3.png" />
6. Choose your target audience. You can also check the count of your audience. <img src="https://mintcdn.com/moengage/fQ0QnP2abFkVAzJ2/images/moengage_4e3e64.png?fit=max&auto=format&n=fQ0QnP2abFkVAzJ2&q=85&s=92957e992d154c4d27934ffc17adb5fe" width="2744" height="626" data-path="images/moengage_4e3e64.png" />
7. Click next to proceed to the next step.
8. On step 2 of the campaign,
   * Select the method as POST.
   * Add Webhook URL as : `https://www.google-analytics.com//mp/collect?api_secret=<api_secret>&measurement_id=<measurement_id>`
   * The URL parameters list should auto-populate. Replace `<api_secret>` with your API Secret Key. You can swap this parameter with `firebase_app_id` if you're using a Firebase app. Replace `<measurement_id>` with the ID of your Data Stream.
   * In Headers, add `Content-Type` as `application/json`.
   * In Body, choose Raw and use the content depending on what events you want to send to Google Analytics. Below is an example:\\
     ```text wrap theme={null}
     {
         "client_id": "<client_id>",
         "user_id": "{{UserAttribute['ID']}}",
         "timestamp_micros": "{{EventAttribute['Event Time (UTC)']}}",
         "user_properties": {
             "email": {
                 "value": "{{UserAttribute['Email (Standard)']}}"
             }
         },
         "events": [
             {
                 "name": "cart_checkout",
                 "params": {
                     "checkout_value": 1000
                 }
             }
         ]
     }
     ```
     * Make sure to replace `<client_id>` with the client ID (if using `gtag.js`). You can also swap this key with `app_instance_id` if you're using a Firebase app.

<img src="https://mintcdn.com/moengage/t9d2bz7zij1iE1iP/images/moengage_9cf6b7.png?fit=max&auto=format&n=t9d2bz7zij1iE1iP&q=85&s=a31b4825e3eb4dae9223f49ff47595e5" alt="" width="2240" height="1408" data-path="images/moengage_9cf6b7.png" />

7. At this point, your campaign should be ready to test and send. You can also test your connector configuration using the Test functionality available in Step 2 of Create Connector Campaign.

<img src="https://mintcdn.com/moengage/-uVFLyK4XoHTd5WE/images/moengage_1492ae.png?fit=max&auto=format&n=-uVFLyK4XoHTd5WE&q=85&s=8543dddfd443d7841ecfcf93a63c67db" alt="Screen_Shot_2022-02-22_at_11.12.42_AM.png" width="2464" height="270" data-path="images/moengage_1492ae.png" />

If your Google Analytics account successfully receives the event, your set-up is good to go. You can go ahead and Publish the campaign.
