# How to connect Batch to Google Analytics?

Batch allows you to track Google Analytics users who interact with your push notifications or In-App messages. This is helpful to understand what your users do in your app/website, tracking transactions and e-commerce conversions.

## A. Tracking Web Push Notifications <a href="#a-tracking-web-push-notifications" id="a-tracking-web-push-notifications"></a>

You can easily track your web push opens in Google Analytics by following these two steps:

### Adding UTM Tags to Your Deeplink <a href="#id-1-adding-utm-tags-to-your-deeplink" id="id-1-adding-utm-tags-to-your-deeplink"></a>

The first thing you need to do is to add UTM tags to the deeplink of your push campaign. This can be done from the campaign editor or when calling the Campaigns / Transactional API:

<figure><img src="/files/jMSCTklX9jqiNzaAFCXO" alt="Adding UTM Tags in your Deeplink"><figcaption><p>Adding UTM Tags in your Deeplink</p></figcaption></figure>

Each UTM tag includes two main elements:

* A parameter (e.g: utm\_source)
* A value (eg: newsletter)

There are several parameters you can use (more information [here](https://support.google.com/analytics/answer/1033863?hl=en\&ref_topic=1032998)):

* **Campaign Name (utm\_campaign)**: This can be the name (e.g. salejuly) or the category of your push campaign (e.g. onboarding).
* **Campaign Source (utm\_source)**: This parameter allows you to define where your content comes from (e.g. Batch\_Android, Batch\_iOS)
* **Campaign Medium (utm\_medium)**: This parameter allows you to identify the medium used by the user is coming from (e.g. push)

You can build easily add UTM tags to your deeplink by using Google's [Campaign URL Builder](https://ga-dev-tools.appspot.com/campaign-url-builder/#related-resources):

<figure><img src="/files/gk4G2yYkhsalKNC44TpX" alt="Using the Google&#x27;s Campaing URL Builder"><figcaption><p>Using the Google's Campaing URL Builder</p></figcaption></figure>

## B. Tracking Mobile Push and In-App Campaigns <a href="#b-tracking-mobile-push-and-in-app-campaigns" id="b-tracking-mobile-push-and-in-app-campaigns"></a>

**Note :**

* This section assumes you are already using the V3 of Google Analytics' SDK in your app. Also, you must have a deeplink architecture integrated into your application.
* The [Google Analytics SDK has been sunsetted](https://support.google.com/firebase/answer/9167112) since October 2019 for non-Google Analytics 360 customers, meaning if you still use it on a free Google Analytics account, no data will be available and you must migrate to Firebase.

{% stepper %}
{% step %}

### Installing the Google Analytics Dispatcher in Your Application <a href="#id-1-installing-the-google-analytics-dispatcher-in-your-application" id="id-1-installing-the-google-analytics-dispatcher-in-your-application"></a>

The Google Analytics dispatcher uses the [UTM tags](https://ga-dev-tools.appspot.com/campaign-url-builder/) (like on lots of Google services) from your campaign to dispatch a new set of data on Google Analytics.

If you haven't already installed the Google Analytics event dispatcher, please read our technical documentation for [Android](https://doc.batch.com/developer/sdk/android/event-dispatchers) and [iOS](https://doc.batch.com/developer/sdk/ios/event-dispatchers).

Once the dispatcher is installed, you will be able to track [different types of events](https://doc.batch.com/developer/sdk/ios/event-dispatchers#access-data-from-the-event) related to your push or In-App messaging campaigns on Google Analytics.

**Note:** If you use an SDK version that is older than 1.15 or has already released your apps without installing the Google Analytics event dispatcher, you can still track push opens by adding UTM tags to your deeplinks as described in section A of this article.
{% endstep %}

{% step %}

### Tracking your campaigns with UTM tags

### a. Tracking a push campaign with a UTM tag <a href="#id-2a-tracking-a-push-campaign-with-a-utm-tag" id="id-2a-tracking-a-push-campaign-with-a-utm-tag"></a>

The dispatcher gathers the values of utm\_campaign, utm\_source and utm\_medium from the deeplink URL and from the custom payload of your campaign.

The tags utm\_source and utm\_medium are optional because they have a default value of batch and push accordingly.

You can add utm\_content only in the deeplink URL in case your push notification has several different buttons.

<figure><img src="/files/3tSKZ3eQJFbwiYocWatw" alt="Adding UTM Tags in a push notification"><figcaption><p>Adding UTM Tags in a push notification</p></figcaption></figure>

### b. Tracking an In-App Campaign or Mobile Landing <a href="#id-2b-tracking-an-in-app-campaign-or-mobile-landing" id="id-2b-tracking-an-in-app-campaign-or-mobile-landing"></a>

{% hint style="info" %}
This feature is specific to Batch's Mobile Engagement Platform (More on the [difference between Batch's CEP and MEP](/getting-started/other/faq/what-are-the-differences-between-batch-customer-engagement-platform-and-mobile-engagement-platform.md)).
{% endhint %}

The dispatcher gathers the value of utm\_campaign from the field Tracking ID of your campaign.

You can't customize the utm\_source and utm\_medium tags, they have a default value of batch and in-app accordingly.

You can add utm\_content only in the deeplink URL in case your in-app message has two different buttons.

<figure><img src="/files/53LCsdgH7nsnBMyr08Vc" alt="Adding UTM Tags in an InApp"><figcaption><p>Adding UTM Tags in an InApp</p></figcaption></figure>
{% endstep %}
{% endstepper %}

## C. Filtering Your Audience Based on UTM Tags <a href="#c-filtering-your-audience-based-on-utm-tags" id="c-filtering-your-audience-based-on-utm-tags"></a>

Once the steps described in either sections A or B are completed. You will be able to track users coming from specific sources, mediums or campaigns by going to **Acquisition > Sources > all** on Google Analytics.

<figure><img src="/files/CMCOuN18CH6VM5jDI8L9" alt="Finding the source of the acquisition"><figcaption><p>Finding the source of the acquisition</p></figcaption></figure>

Then you will be able to see your whole campaign from push notifications by clicking on the campaign tab.

<figure><img src="/files/PowWWW6VGh1ReztUGms8" alt="Tracking by campaign source"><figcaption><p>Tracking by campaign source</p></figcaption></figure>

## D. Testing Your Campaign Tracking <a href="#d-testing-your-campaign-tracking" id="d-testing-your-campaign-tracking"></a>

In order to test whether your Batch campaign data is correctly being tracked, you can go to the "Real Time" tab in Google Analytics and check the event count for the event that you want to track.

<figure><img src="/files/c735XZBUndQu2dyMPpnG" alt="Track your events in real time"><figcaption><p>Track your events in real time</p></figcaption></figure>

You can then try to send yourself a test push ([iOS](https://doc.batch.com/guides-and-best-practices/message/push-notifications/how-to-send-a-test-push-notification-to-your-mobile) / [Android](https://doc.batch.com/guides-and-best-practices/message/push-notifications/how-to-send-a-test-push-notification-to-your-mobile)) or [In-App message](https://doc.batch.com/guides-and-best-practices/message/in-app-messaging/how-to-send-yourself-a-test-for-in-app-messages). If integrated correctly, you should see the event count increase a few moments after the event is performed (Push open, Push notification dismiss, In-App dismiss, In-App display, etc).


---

# 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://doc.batch.com/integrations/analytics/how-to-connect-batch-to-google-analytics.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.
