1.0.34 • Published 2 years ago

google-playstore-stats-viewer v1.0.34

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

google-playstore-stats-viewer

View basic stats like installs/downloads, uninstall, active users events

Maintenance GPLv3 license Generic badge PRs Welcome npm

forthebadge forthebadge forthebadge forthebadge forthebadge forthebadge forthebadge forthebadge

SUPPORT THE WORK & DEV

GitHub stars   GitHub stars   GitHub followers

Authentication

Steps to get your service account file from Google Cloud Platform

  • Go to your GCP Project https://console.cloud.google.com/iam-admin/serviceaccounts (Create gcp project if you don't have one)
  • Create service account (In 3rd step you will get option to create the key), store that key, that will be used access your app data statistics
  • Go to https://play.google.com/apps/publish
  • Go to Users and Permissions -> Invite new user -> Add the email (Service account email)
  • Now, Grant permission to service account we created (Choose permission - "View app information and download bulk reports (read-only)") -> click Add user

It can take upto 24 hours to grant permission to service account, so don't worry if you get authentication error

Bucket Name

Steps to find bucket name

  • Go to your play console
  • Navigate to Download reports -> Statistics
  • Click "Copy cloud storage URI" , Example: gs://pubsite_prod_xxxxx/stats/installs/
  • Use only "pubsite_prod_xxxxx" as the bucket name

Install

npm install -g google-playstore-stats-viewer

or

yarn global add google-playstore-stats-viewer

Usage

Using the CLI - (Get basic stats)

playstore-stats \
    -p=com.example.app \
    -k=KEY_FILE_LOCATION \
    -g=YOUR_GCP_PROJECT_ID \
    -b=pubsite_prod_xxxx

or the JavaScript API to fetch stats (Get basic stats)

const GooglePlayStoreStatsViewer = require('google-playstore-stats-viewer');

try {
    const statsViewer = new GooglePlayStoreStatsViewer({
        keyFilePath: "PATH_TO_KEY_FILE",
        packageName: "com.example.app",
        projectID: "GCP_PROJECT_ID",
        bucketName: "pubsite_prod_xxxx"})
    const data = await statsViewer.getAppStats();
    console.log(data);
} catch (e) {
  console.log(e);
}

Output (sample)

{
  currentlyActiveDevices: 344,
  totalInstallCountByUser: 1051,
  totalUninstallCountByUser: 780,
  totalInstallEventsDetected: 117276,
  totalUninstallEventsDetected: 831
}

You can use setPackageName(STRING) -> Update packageID to query stats for different apps associated with same developer account. (and you have the permission)

statsViewer.setPackageName("com.newpackage.app")

To download csv files - Statistics (Installs)

returns a promise, which resolves to an array containing downloaded file names.

try {
    const statsViewer = new GooglePlayStoreStatsViewer({
        keyFilePath: "PATH_TO_KEY_FILE",
        packageName: "com.example.app",
        projectID: "GCP_PROJECT_ID",
        bucketName: "pubsite_prod_xxxx"})
    const data = await statsViewer.downloadAppStats({
        dimension: statsViewer.Dimensions.<DIMENSION_NAME>,
        targetLocation: targetLocation
    });
    console.log(data);
} catch (e) {
  console.log(e);
}

where dimension name can be any of the following:

DIMENSION NAMEUSE
DEVICEDevice wise installs
APP_VERSIONVersion wise installs
CARRIERCarrier wise installs
COUNTRYCountry wise installs
LANGUAGELanguage wise
ANDROID_OS_VERSIONOS version wise

Use cases

What are the possible usage of this package?

  • Create API based, stats fetch
  • When you have multiple apps hosted on playstore
  • Integration with custom dashboard

Do more

Modify the source to support more methods like reviews, crashes and more. https://support.google.com/googleplay/android-developer/?p=stats_export

This project uses: