# Google Play Subscriptions

{% hint style="danger" %}
This functionality is available only for projects with integrated devtodev SDK version 2.1.0 or higher for native applications and not lower than 3.1.0 for Unity!
{% endhint %}

{% hint style="info" %}
*Please note that the current section describes how to integrate **only one source** of subscription data - from the Google Play. You’ll also need to integrate the* [***Subscription event via SDK***](/integration/integration-of-sdk-v2/setting-up-events/basic-methods.md#subscriptions) *to get the subscription data in the devtodev reports (the documentation link is at the bottom of the page).*\
\&#xNAN;*When you integrate both data sources (Google Play and SDK), you’ll be able to see the* [*Subscriptions report*](/reports-and-functionality/project-related-reports-and-fuctionality/smart-view/monetization-reports.md#subscriptions) *and devtodev will connect that data with the users successfully. If one of the integrations is missing, the Subscriptions report won’t be working correctly.*
{% endhint %}

## Settings in Google Cloud Platform Console

{% hint style="info" %}
If you have already activated the Google Play Android Developer API and set up a service account to work with devtodev, you can skip this section.
{% endhint %}

### Google Play Android Developer API <a href="#google-play-android-developer-api" id="google-play-android-developer-api"></a>

1. Go to [Google Cloud Console](<https://console.cloud.google.com/ >) under your Google account.\
   Select the project for which you want to configure **Google Play Developer API**. Then go to the **APIs and services** section.

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

2. Go to the **Library** section.

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

3. Find the **Google Play Developer API** section.

<figure><img src="/files/2NcZxJsjz4MrzD9S2b4P" alt=""><figcaption></figcaption></figure>

4. Press the ENABLE button.

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

### **Service account** <a href="#service-account" id="service-account"></a>

To create a service account, click the link <https://console.cloud.google.com/apis/credentials/serviceaccountkey>

If you already have selected an active project, then skip the project selection block below.

1. Select the **project** that you will link to the service account and for which you will collect subscription data later. If the project is not listed, create it.

   &#x20;

   <figure><img src="/files/uFq3w7adMIa1z5OALtNV" alt=""><figcaption></figcaption></figure>
2. In the list of available service keys, click on the **Create service account** link.

   &#x20;

   <figure><img src="/files/V2qyWwXCp7AeRXzZFJEc" alt=""><figcaption></figcaption></figure>
3. In the provided free form, fill in the **Service account name** field, the **Service Account ID** field will be filled in automatically (use the screenshot below as an example) and click **CREATE AND CONTINUE** button.

   &#x20;

   <figure><img src="/files/z8Gy0m68VIu0zq8iXQNK" alt=""><figcaption></figcaption></figure>
4. Steps 2 and 3 are not needed, just click the **Done** button at the end of the form.

   &#x20;

   <figure><img src="/files/ftFBvffIooTkWkooAOK4" alt=""><figcaption></figcaption></figure>
5. After creating a service account, you will be returned to the list of available accounts. Select the created account and open the **KEYS** tab, click the **ADD KEY** button, and then select the **JSON** option in the pop-up window. Confirm your choice by clicking the Create button. The generated **private key file** will be automatically downloaded. You will need to upload this key into the analysis connection forms. This will be explained in the following sections.

   &#x20;

   <figure><img src="/files/Brs2xwOeOeigB04cnkPd" alt=""><figcaption></figcaption></figure>
6. Go to the **IAM** section in the **Permissions** tab and click **GRANT ACCESS** to add roles to the service account in **New principals** section. In the appeared form, enter the service account address and give it the **Pub/Sub Subscriber** role. If you don’t have this role, you need to activate the **Pub/Sub service** in the Cloud Platform. Save the changes.

   <figure><img src="/files/1goFKAfnoWhwZjAhw1p6" alt=""><figcaption></figcaption></figure>

### **Pub/Sub service** <a href="#pub-sub-service" id="pub-sub-service"></a>

Go to the list of topics in the **Pub/Sub** service <https://console.cloud.google.com/cloudpubsub/topic/list>

1. Select the project on which you want to collect subscription data if it is not selected yet, then click the **CREATE TOPIC** link and create a topic.

   &#x20;

   <figure><img src="/files/FODj0It3t1GjvarkvPPQ" alt=""><figcaption></figcaption></figure>
2. To do this, fill in the **Topic ID** (use the screenshot below as an example), disable **Add a default subscription** option and confirm the topic creation.

   &#x20;

   <figure><img src="/files/OBXkQ0agqBz5bnIBwcjx" alt=""><figcaption></figcaption></figure>
3. As shown in the example below, select from the pop-up menu **View permissions**.

   &#x20;

   <figure><img src="/files/pHLPRSITaMYt0GRfzpb8" alt=""><figcaption></figcaption></figure>
4. Click on the button **ADD PRINCIPAL**.

   &#x20;

   <figure><img src="/files/caUJRvMOjW0RvWua0XnM" alt=""><figcaption></figcaption></figure>
5. Add the service account `google-play-developer-notifications@system.gserviceaccount.com`, and grant it the role of **Pub/Sub Publisher**. Save the changes.

   &#x20;

   <figure><img src="/files/71F92bF58scV5UCUVZkk" alt=""><figcaption></figcaption></figure>
6. After that, open the list of subscriptions and click **CREATE SUBSCRIPTION**.

   &#x20;

   <figure><img src="/files/D0IzviX6WueS5tGijy3S" alt=""><figcaption></figcaption></figure>
7. In the appeared form, specify the **Subscription ID** in the field below **Select a Cloud Pub/Sub topic** specify the topic you’ve just created, in the **Delivery type** choose **Push** and in the **Endpoint URL** field insert the link obtained from the devtodev subscription integration window that described on the next session (**Settings on devtodev side**). All other parameters remain unchanged. Save the changes.

   &#x20;

   <figure><img src="/files/7HHhXoHka6yadXVJl5v5" alt=""><figcaption></figcaption></figure>
8. To get **Endpoint URL** go to [devtodev](https://analytics.devtodev.com/), select the same app and open the app settings (**Settings -> Payments integration -> Subscriptions**). Click on the button **Integrate**.

   <figure><img src="/files/VAHbHcOCXpaAoO4PPpnZ" alt=""><figcaption></figcaption></figure>
9. In the next form copy the **Endpoint URL**.

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

## **Settings on devtodev side** <a href="#step-3.-settings-on-devtodev-side" id="step-3.-settings-on-devtodev-side"></a>

1. In the devtodev app subscription settings, specify **the app package**, and upload the **private key file**.
2. Add all existing subscriptions, specifying the bundle, subscription period, and name for each subscription.

   <figure><img src="/files/ZmoJz2o3hcS5zIIHY47r" alt=""><figcaption></figcaption></figure>
3. Save changes
4. Don't forget to integrate the [subscription-specific SDK methods](/integration/integration-of-sdk-v2/setting-up-events/basic-methods.md#subscriptions).

## **Settings in Google paly console**. <a href="#step-3.-google-paly-console" id="step-3.-google-paly-console"></a>

#### Service account and User permissions <a href="#service-account-and-user-permissions" id="service-account-and-user-permissions"></a>

To set up user permission, you need to log into your Google Play Console account and invite your previously created service account.

1. Sign into the [Google Play Developer Console](https://play.google.com/apps/publish/signup/).

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

   &#x20;
2. In the **Users and permissions** section, you can add users and manage their permissions.
   * Click **Users and permissions.**
   * Click the **Invite new users** button.

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

     &#x20;
3. Add Service Account
   * Put an email address for your service account in the **email address** field and grant the necessary rights to perform actions. How to create service account see **Step 1. Service account.**
   * In the **Permissions section** select **the apps** this service account has access to. Click **Apply.** Grant permissions to individual apps, or use account permissions to grant access to all apps in your developer account.

     <figure><img src="/files/Kpw8vpjoOt9rNkGwQDgJ" alt=""><figcaption></figcaption></figure>
4. You have to grant the following permissions:
   * *View app information*
   * *View app quality information*
   * *View financial data*
   * Click **Apply** button.\
     \&#xNAN;***Please note that the specified settings may not work immediately.***

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

     &#x20;
5. After creating a subscription in the **Pub/Sub** service, you need register the created topic as a target for RTDN (**Real-time developer notifications**). To do this, go to the app’s **Monetise with Play** → **Monetisation setup** section and enter the full name of the topic in the **Topic name field**. After that, send a **test notification** using the link below. If everything is configured correctly, then the test notification will change the integration status of the **Subscriptions** in devtodev to Active.

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


---

# 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://docs.devtodev.com/3rd-party-sources/app-marketplace-data/google-play-subscriptions.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.
