Firebase Dynamic Links Analytics API

You can use this REST API to get analytics data for each of your short Dynamic Links, whether created in the console or programmatically.

API Authorization

When you make requests to the Dynamic Link Analytics APIs, you must include an OAuth 2.0 access token that authorizes access to your Firebase project.

You can get access tokens using a Google API client library:

  1. Add Firebase to your app as described in the Admin SDK setup guide. That is, create a service account and generate a private key.
  2. Use a Google API client library to get an access token from your service account credentials:


    Using the Google API Client Library for Java:

    // Load the service account key JSON file
    FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json");
    // Authenticate a Google credential with the service account
    GoogleCredential googleCred = GoogleCredential.fromStream(serviceAccount);
    // Add the required scope to the Google credential
    GoogleCredential scoped = googleCred.createScoped(
    // Use the Google credential to generate an access token
    String token = scoped.getAccessToken();
    // Include the access token in the Authorization header.


    Using the Google API Client Library for Node.js:

    var { google } = require("googleapis");
    // Load the service account key JSON file.
    var serviceAccount = require("path/to/serviceAccountKey.json");
    // Specify the required scope.
    var scopes = [
    // Authenticate a JWT client with the service account.
    var jwtClient = new google.auth.JWT(
    // Use the JWT client to generate an access token.
    jwtClient.authorize(function(error, tokens) {
      if (error) {
        console.log("Error making request to generate access token:", error);
      } else if (tokens.access_token === null) {
        console.log("Provided service account does not have permission to generate access tokens");
      } else {
        var accessToken = tokens.access_token;
        // Include the access token in the Authorization header.


    Using the Google Auth library for Python:

    from google.oauth2 import service_account
    from google.auth.transport.requests import AuthorizedSession
    # Specify the required scope
    scopes = [
    # Authenticate a credential with the service account
    credentials = service_account.Credentials.from_service_account_file(
        "path/to/serviceAccountKey.json", scopes=scopes)
    # Use the credentials object to authenticate a Requests session.
    authed_session = AuthorizedSession(credentials)
    response = authed_session.get(
    # Or, use the token directly, as described below.
    request = google.auth.transport.requests.Request()
    access_token = credentials.token

Get statistics for a single Dynamic Link

Use the linkStats endpoint to get event statistics for a single Dynamic Link.

HTTP request

A linkStats request has the following format:


Authorization: Bearer ACCESS_TOKEN

For example, to retrieve statistics from the last 7 days for the short link


Authorization: Bearer ya29.Abc123...
SHORT_DYNAMIC_LINK The URL-encoded short Dynamic Link for which you want to get event data.
DURATION The number of days for which to get event data. For example, if you specify 30, the request retrieves data for the past 30 days. Note that some events logged in the last 36 hours might not be included.
ACCESS_TOKEN An unexpired access token. See API Authorization.

Response body

The response to a request is a JSON object like the following:

  "linkEventStats": [
      "platform": "ANDROID",
      "count": "123",
      "event": "CLICK"
      "platform": "IOS",
      "count": "123",
      "event": "CLICK"
      "platform": "DESKTOP",
      "count": "456",
      "event": "CLICK"
      "platform": "ANDROID",
      "count": "99",
      "event": "APP_INSTALL"
      "platform": "ANDROID",
      "count": "42",
      "event": "APP_FIRST_OPEN"



Each item in the linkEventStats list contains a platform-specific count of some Dynamic Link related event (such as the number of clicks on Android). Note that these statistics might not include events that have been logged within the last 36 hours.

Event Description Firebase console REST API
CLICK Count of any click on a Dynamic Link, irrespective to how it is handled and its destinations
REDIRECT Count of attempts to redirect users, either to the App Store or Play Store to install or update the app, or to some other destination
APP_INSTALL Count of actual installs (only supported by the Play Store)
APP_FIRST_OPEN Count of first-opens after an install
APP_RE_OPEN Number of times the Dynamic Link caused an app to be re-opened