# Google Ads conversion tracking

Google Tag Manager provides Google Ads conversion tracking tags to
support flexible, rule-based Google Ads conversion tracking for Android apps.

This guide shows you how use Google Tag Manager to track Android app install conversions with
Google Ads conversion tracking tags:

1. [Create a new conversion in Google Ads](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#create-conversion)
2. [Create a trigger to fire a Google Ads conversion
   tracking tag](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#create-trigger)
3. [Create a Google Ads conversion tracking tag](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#create-tag)
4. [Update file
   `AndroidManifest.xml`](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#update-xml-file)
5. [Push the conversion
   event to the data layer](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#push-event-to-datalayer)
6. [Record deep links](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#record-deep-links)
7. [Publish the container](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#publish-container)

## 1. Create a new conversion in Google Ads

To create a new conversion in Google Ads:

1. Sign in to your [Google Ads](https://ads.google.com) account.
2. At the menu bar, select **Tools \> Conversions**.
3. Click **+ CONVERSION**.
4. Select **App**.
5. Select **Android** and **App installs (first open)** and click **Continue**.
6. Enter the following:
   - Click **Name** to the name of the Android app and click **Done**.
   - Click **Value** to enter a value for each install of the app, or select **Don't assign a value to this install** , and click **Done**.
   - Click **Package name** to enter the package name of your Android app within Google play and click **Done**.
   - Click **Optimization** , which is turned off by default. To turn on optimization, click **OFF** to toggle it to **ON** and click **Done**.
   - (Optional). Click **Postback URL** to enter the URL from your analytics provider where you'd like conversions to be posted and click **Done**.
7. Click **Save and continue**.
8. Review your conversion settings. To change them, click **Edit settings**.
9. Under **Set up your tracking method** , select **Put tracking code into the app** . See the screenshot of setting up conversion tracking.
   ![tracking method](https://developers.google.com/static/tag-platform/tag-manager/images/android/v4/tracking-method.png)
10. Click **Save instructions and code** or **Email instructions and code** to save the conversion ID and conversion label, which are required to [create a Google Ads conversion tracking tag](https://developers.google.com/tag-platform/tag-manager/android/v4/google-ads-conversions#create-tag).
11. Click **Done**.

## 2. Create a trigger to fire a Google Ads conversion
tracking tag

To create a trigger in Google Tag Manager to fire the
Google Ads conversion tracking tag:

1. Sign in to your [Google Tag Manager](https://tagmanager.google.com) account.
2. Select a mobile container.
3. On the left navigation bar, click **Triggers**.
4. Click **New**.
5. Under **Fire On** , enter the following conditions:

   ![tracking method](https://developers.google.com/static/tag-platform/tag-manager/images/android/v4/conversion-trigger.png)
6. Click **Create Trigger**.
7. Enter a trigger name.
8. Click **Save**.

## 3. Create a Google Ads conversion tracking tag

To create a Google Ads conversion tracking tag:

1. Sign in to your [Google Tag Manager](https://tagmanager.google.com) account.
2. Select a mobile container.
3. On the left navigation bar, click **Tags**.
4. Click **New**.
5. Choose product **Google Ads**.
6. Choose tag type **Google Ads Conversion Tracking**.
7. Enter the **Conversion ID** and **Conversion Label**.
8. Select **Unrepeatable**.
9. Click **Continue**.
10. Under **Fire On** , select **Custom** event.
11. Select the trigger created in step 2.
12. Click **Save**.
13. Click **Create Tag**.
14. Enter a tag name (e.g. **Android App Install Conversion**).
15. Click **Save**.

## 4. Update file `AndroidManifest.xml`

In Android Studio, open the `AndroidManifest.xml` file to add
the following within the `<application>` tag:

```
<service android:name="com.google.android.gms.tagmanager.InstallReferrerService"/>
<receiver
   android:name="com.google.android.gms.tagmanager.InstallReferrerReceiver"
   android:exported="true">
   <intent-filter>
       <action android:name="com.android.vending.INSTALL_REFERRER" />
   </intent-filter>
</receiver>
```

## 5. Push the Google Ads conversion event
to the data layer

First initialize [Google Tag Manager (GTM)](https://developers.google.com/tag-platform/tag-manager/android/v4#init). Then add the following code you to your app
to push the Google Ads conversion event to the data layer, which will enable
GTM to evaluate the trigger and fire the matching tag:

```
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("appLaunch", DataLayer.mapOf());
```

## 6. Record deep links

If your app uses deep linking, to record a deep linking conversion,
push the link to the data layer as `"gtm.url"` in the activities
launched by your intents:

```
if (this.getIntent() != null && this.getIntent().getData() != null ) {
  TagManager.getInstance(this).getDataLayer().push("gtm.url", this.getIntent().getData().toString());
}
```

## 7. Publish the container

You can now publish your container to begin firing the Google Ads conversion tag.
For details, see **Adding, Updating and Publishing Tags** on
[Setup and Workflow (Mobile Apps)](https://support.google.com/tagmanager/answer/3127354).

<br />