Method: projects.addGoogleAnalytics
Stay organized with collections
Save and categorize content based on your preferences.
Links the specified FirebaseProject
with an existing Google Analytics account.
Using this call, you can either:
- Specify an
analyticsAccountId
to provision a new Google Analytics property within the specified account and associate the new property with the FirebaseProject
. - Specify an existing
analyticsPropertyId
to associate the property with the FirebaseProject
.
Note that when you call projects.addGoogleAnalytics
:
- The first check determines if any existing data streams in the Google Analytics property correspond to any existing Firebase Apps in the
FirebaseProject
(based on the packageName
or bundleId
associated with the data stream). Then, as applicable, the data streams and apps are linked. Note that this auto-linking only applies to AndroidApps
and IosApps
. - If no corresponding data streams are found for the Firebase Apps, new data streams are provisioned in the Google Analytics property for each of the Firebase Apps. Note that a new data stream is always provisioned for a Web App even if it was previously associated with a data stream in the Analytics property.
Learn more about the hierarchy and structure of Google Analytics accounts in the Analytics documentation.
The result of this call is an Operation
. Poll the Operation
to track the provisioning process by calling operations.get
until done
is true
. When done
is true
, the Operation
has either succeeded or failed. If the Operation
succeeded, its response
is set to an AnalyticsDetails
; if the Operation
failed, its error
is set to a google.rpc.Status
.
To call projects.addGoogleAnalytics
, a project member must be an Owner for the existing FirebaseProject
and have the Edit
permission for the Google Analytics account.
If the FirebaseProject
already has Google Analytics enabled, and you call projects.addGoogleAnalytics
using an analyticsPropertyId
that's different from the currently associated property, then the call will fail. Analytics may have already been enabled in the Firebase console or by specifying timeZone
and regionCode
in the call to projects.addFirebase
.
HTTP request
POST https://firebase.googleapis.com/v1beta1/{parent=projects/*}:addGoogleAnalytics
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters |
parent |
string
The resource name of the FirebaseProject to link to an existing Google Analytics account, in the format:
projects/PROJECT_IDENTIFIER
Refer to the FirebaseProject name field for details about PROJECT_IDENTIFIER values.
|
Request body
The request body contains data with the following structure:
JSON representation |
{
// Union field analytics_resource can be only one of the following:
"analyticsAccountId": string,
"analyticsPropertyId": string
// End of list of possible types for union field analytics_resource .
} |
Fields |
Union field analytics_resource .
Only one Google Analytics resource can be specified in the request body. - To provision a new Google Analytics property and associate it with the
FirebaseProject , provide analyticsAccountId . - To associate an existing Google Analytics property with the
FirebaseProject , provide analyticsPropertyId .
analytics_resource can be only one of the following: |
analyticsAccountId |
string
The ID for the existing Google Analytics account that you want to link with the FirebaseProject . Specifying this field will provision a new Google Analytics property in your Google Analytics account and associate the new property with the FirebaseProject .
|
analyticsPropertyId |
string
The ID for the existing Google Analytics property that you want to associate with the FirebaseProject .
|
Response body
If successful, the response body contains an instance of Operation
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/firebase
For more information, see the Authentication Overview.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-24 UTC.
[null,null,["Last updated 2024-10-24 UTC."],[],[],null,["Links the specified [FirebaseProject](/docs/reference/firebase-management/rest/v1beta1/projects#FirebaseProject) with an existing [Google Analytics account](http://www.google.com/analytics/).\n\nUsing this call, you can either:\n\n- Specify an `analyticsAccountId` to provision a new Google Analytics property within the specified account and associate the new property with the `FirebaseProject`.\n- Specify an existing `analyticsPropertyId` to associate the property with the `FirebaseProject`.\n\n\u003cbr /\u003e\n\nNote that when you call `projects.addGoogleAnalytics`:\n\n1. The first check determines if any existing data streams in the Google Analytics property correspond to any existing Firebase Apps in the `FirebaseProject` (based on the `packageName` or `bundleId` associated with the data stream). Then, as applicable, the data streams and apps are linked. Note that this auto-linking only applies to `AndroidApps` and `IosApps`.\n2. If no corresponding data streams are found for the Firebase Apps, new data streams are provisioned in the Google Analytics property for each of the Firebase Apps. Note that a new data stream is always provisioned for a Web App even if it was previously associated with a data stream in the Analytics property.\n\n\u003cbr /\u003e\n\nLearn more about the hierarchy and structure of Google Analytics accounts in the [Analytics documentation](https://support.google.com/analytics/answer/9303323).\n\nThe result of this call is an [`Operation`](../../v1beta1/operations). Poll the `Operation` to track the provisioning process by calling `operations.get` until [`done`](../../v1beta1/operations#Operation.FIELDS.done) is `true`. When `done` is `true`, the `Operation` has either succeeded or failed. If the `Operation` succeeded, its [`response`](../../v1beta1/operations#Operation.FIELDS.response) is set to an [AnalyticsDetails](/docs/reference/firebase-management/rest/v1beta1/projects/getAnalyticsDetails#body.AnalyticsDetails); if the `Operation` failed, its [`error`](../../v1beta1/operations#Operation.FIELDS.error) is set to a [google.rpc.Status](/docs/reference/firebase-management/rest/v1beta1/operations#Status).\n\nTo call `projects.addGoogleAnalytics`, a project member must be an Owner for the existing `FirebaseProject` and have the [`Edit` permission](https://support.google.com/analytics/answer/2884495) for the Google Analytics account.\n\nIf the `FirebaseProject` already has Google Analytics enabled, and you call `projects.addGoogleAnalytics` using an `analyticsPropertyId` that's different from the currently associated property, then the call will fail. Analytics may have already been enabled in the Firebase console or by specifying `timeZone` and `regionCode` in the call to [`projects.addFirebase`](../../v1beta1/projects/addFirebase).\n\nHTTP request\n\n`POST https://firebase.googleapis.com/v1beta1/{parent=projects/*}:addGoogleAnalytics`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\nPath parameters\n\nRequest body\n\nThe request body contains data with the following structure:\n\nResponse body\n\nIf successful, the response body contains an instance of [Operation](/docs/reference/firebase-management/rest/v1beta1/operations#Operation).\n\nAuthorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/cloud-platform`\n- `\n https://www.googleapis.com/auth/firebase`\n\nFor more information, see the [Authentication Overview](https://cloud.google.com/docs/authentication/)."]]