---
description: Unofficial Capacitor plugin for Firebase Analytics SDK to track user interactions and events in your app.
title: Capacitor Firebase Analytics Plugin - Capawesome
image: https://capawesome.io/docs/assets/images/social/sdks/capacitor/firebase/analytics.png
---

<!doctype html> 

[Skip to content ](#capacitor-firebaseanalytics) 

[🔐 Introducing the **Capacitor Vault** plugin — store secrets behind biometrics or a device passcode. ](/blog/announcing-the-capacitor-vault-plugin/) 

* [ SDKs ](/docs/sdks/)
* [ iOS ](#ios)
* [ Configuration ](#configuration)
* [ Demo ](#demo)
* [ Usage ](#usage)
* [ API ](#api)
* [ Enums ](#enums)
* [ Test your implementation ](#test-your-implementation)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Newsletter ](#newsletter)
* [ Changelog ](#changelog)
* [ License ](#license)
* [ App ](/docs/sdks/capacitor/firebase/app/)
* [ App Check ](/docs/sdks/capacitor/firebase/app-check/)
* [ Authentication ](/docs/sdks/capacitor/firebase/authentication/)
* [ Crashlytics ](/docs/sdks/capacitor/firebase/crashlytics/)
* [ Cloud Firestore ](/docs/sdks/capacitor/firebase/cloud-firestore/)
* [ Cloud Functions ](/docs/sdks/capacitor/firebase/cloud-functions/)
* [ Cloud Messaging ](/docs/sdks/capacitor/firebase/cloud-messaging/)
* [ Cloud Storage ](/docs/sdks/capacitor/firebase/cloud-storage/)
* [ Performance Monitoring ](/docs/sdks/capacitor/firebase/performance-monitoring/)
* [ Remote Config ](/docs/sdks/capacitor/firebase/remote-config/)
* [ Formbricks ](/docs/sdks/capacitor/formbricks/)
* [ Geocoder ](/docs/sdks/capacitor/geocoder/)
* [ Google Sign-In ](/docs/sdks/capacitor/google-sign-in/)
* [ Grafana Faro ](/docs/sdks/capacitor/grafana-faro/)
* [ Gyroscope ](/docs/sdks/capacitor/gyroscope/)
* [ Haptics ](/docs/sdks/capacitor/haptics/)
* [ Home Indicator ](/docs/sdks/capacitor/home-indicator/)
* [ In-App Browser ](/docs/sdks/capacitor/in-app-browser/)
* [ Install Referrer ](/docs/sdks/capacitor/install-referrer/)
* [ Keep Awake ](/docs/sdks/capacitor/keep-awake/)
* [ libSQL ](/docs/sdks/capacitor/libsql/)
* [ Light Sensor ](/docs/sdks/capacitor/light-sensor/)
* [ Live Update ](/docs/sdks/capacitor/live-update/)
* [ Localization ](/docs/sdks/capacitor/localization/)
* [ Mail Composer ](/docs/sdks/capacitor/mail-composer/)
* [ Managed Configurations ](/docs/sdks/capacitor/managed-configurations/)
* [ Maps Launcher ](/docs/sdks/capacitor/maps-launcher/)
* [ Media Session ](/docs/sdks/capacitor/media-session/)
* [ ML Kit ](/docs/sdks/capacitor/mlkit/)
* [ Navigation Bar ](/docs/sdks/capacitor/navigation-bar/)
* [ Network ](/docs/sdks/capacitor/network/)
* [ NFC ](/docs/sdks/capacitor/nfc/)
* [ Node.js ](/docs/sdks/capacitor/nodejs/)
* [ OAuth ](/docs/sdks/capacitor/oauth/)
* [ Passkeys ](/docs/sdks/capacitor/passkeys/)
* [ Password Autofill ](/docs/sdks/capacitor/password-autofill/)
* [ PDF Generator ](/docs/sdks/capacitor/pdf-generator/)
* [ PDF Viewer ](/docs/sdks/capacitor/pdf-viewer/)
* [ Pedometer ](/docs/sdks/capacitor/pedometer/)
* [ Permissions ](/docs/sdks/capacitor/permissions/)
* [ Phone Dialer ](/docs/sdks/capacitor/phone-dialer/)
* [ Photo Editor ](/docs/sdks/capacitor/photo-editor/)
* [ Photo Manipulator ](/docs/sdks/capacitor/photo-manipulator/)
* [ PixLive ](/docs/sdks/capacitor/pixlive/)
* [ PostHog ](/docs/sdks/capacitor/posthog/)
* [ Printer ](/docs/sdks/capacitor/printer/)
* [ Privacy Screen ](/docs/sdks/capacitor/privacy-screen/)
* [ Proximity Sensor ](/docs/sdks/capacitor/proximity-sensor/)
* [ Purchases ](/docs/sdks/capacitor/purchases/)
* [ RealtimeKit ](/docs/sdks/capacitor/realtimekit/)
* [ Root Detection ](/docs/sdks/capacitor/root-detection/)
* [ Screen Brightness ](/docs/sdks/capacitor/screen-brightness/)
* [ Screen Orientation ](/docs/sdks/capacitor/screen-orientation/)
* [ Screen Reader ](/docs/sdks/capacitor/screen-reader/)
* [ Screenshot ](/docs/sdks/capacitor/screenshot/)
* [ Secure Preferences ](/docs/sdks/capacitor/secure-preferences/)
* [ Settings Launcher ](/docs/sdks/capacitor/settings-launcher/)
* [ Shake ](/docs/sdks/capacitor/shake/)
* [ Silent Mode ](/docs/sdks/capacitor/silent-mode/)
* [ SIM ](/docs/sdks/capacitor/sim/)
* [ SMS Composer ](/docs/sdks/capacitor/sms-composer/)
* [ Speech Recognition ](/docs/sdks/capacitor/speech-recognition/)
* [ Speech Synthesis ](/docs/sdks/capacitor/speech-synthesis/)
* [ Share Target ](/docs/sdks/capacitor/share-target/)
* [ Square Mobile Payments ](/docs/sdks/capacitor/square-mobile-payments/)
* [ SQLite ](/docs/sdks/capacitor/sqlite/)
* [ Superwall ](/docs/sdks/capacitor/superwall/)
* [ System WebView ](/docs/sdks/capacitor/system-webview/)
* [ Text Interaction ](/docs/sdks/capacitor/text-interaction/)
* [ Text Zoom ](/docs/sdks/capacitor/text-zoom/)
* [ Thermal State ](/docs/sdks/capacitor/thermal-state/)
* [ Toast ](/docs/sdks/capacitor/toast/)
* [ Torch ](/docs/sdks/capacitor/torch/)
* [ Vault ](/docs/sdks/capacitor/vault/)
* [ Volume ](/docs/sdks/capacitor/volume/)
* [ Wallet ](/docs/sdks/capacitor/wallet/)
* [ Wifi ](/docs/sdks/capacitor/wifi/)
* [ Zip ](/docs/sdks/capacitor/zip/)
* [ Cordova ](/docs/sdks/cordova/)
* [ Cloud ](/docs/cloud/)
* [ Integrations ](/docs/cloud/live-updates/integrations/)
* Concepts
* Reference
* [ Troubleshooting ](/docs/cloud/live-updates/troubleshooting/)
* [ FAQ ](/docs/cloud/live-updates/faq/)
* [ Native Builds ](/docs/cloud/native-builds/)
* [ Set Up Environments ](/docs/cloud/native-builds/environments/)
* [ Overwrite Native Configurations ](/docs/cloud/native-builds/native-configurations/)
* [ Auto-Increment Build Numbers ](/docs/cloud/native-builds/auto-incrementing-build-numbers/)
* [ Configure the Web Build Script ](/docs/cloud/native-builds/web-build-script/)
* [ Build from a Monorepo ](/docs/cloud/native-builds/monorepo/)
* [ Use pnpm, Yarn, or bun ](/docs/cloud/native-builds/package-managers/)
* [ Install Private npm Packages ](/docs/cloud/native-builds/npm-private-registry/)
* [ Override the Java Version ](/docs/cloud/native-builds/override-java-version/)
* [ Custom iOS Provisioning Profiles ](/docs/cloud/native-builds/custom-ios-provisioning-profiles/)
* [ Build without Git ](/docs/cloud/native-builds/build-without-git/)
* [ Access Git Behind a Firewall ](/docs/cloud/native-builds/firewall-access/)
* [ Integrations ](/docs/cloud/native-builds/integrations/)
* Reference
* [ Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [ FAQ ](/docs/cloud/native-builds/faq/)
* [ App Store Publishing ](/docs/cloud/app-store-publishing/)
* [ Submit a Build ](/docs/cloud/app-store-publishing/submit-a-build/)
* [ Submit Automatically After a Build ](/docs/cloud/app-store-publishing/submit-automatically/)
* [ Troubleshooting ](/docs/cloud/app-store-publishing/troubleshooting/)
* [ FAQ ](/docs/cloud/app-store-publishing/faq/)
* [ Automations ](/docs/cloud/automations/)
* [ Reference ](/docs/cloud/automations/reference/)
* [ Troubleshooting ](/docs/cloud/automations/troubleshooting/)
* [ FAQ ](/docs/cloud/automations/faq/)
* [ Assist ](/docs/cloud/assist/)
* [ CLI ](/docs/cloud/cli/)
* APIs and SDKs
* [ Webhooks ](/docs/cloud/webhooks/)
* [ Integrations ](/docs/cloud/integrations/)
* Account
* [ Organization ](/docs/cloud/organizations/)
* [ Two-Factor Enforcement ](/docs/cloud/organizations/two-factor-authentication/)
* [ Audit Logs ](/docs/cloud/organizations/audit-logs/)
* [ Billing ](/docs/cloud/organizations/billing/)
* [ License Keys ](/docs/cloud/license-keys/)
* [ AI ](/docs/ai/)
* [ Insiders ](/docs/insiders/)
* [ Billing & Plans ](/docs/insiders/billing-and-plans/)
* [ FAQ ](/docs/insiders/faq/)
* [ License ](https://capawesome.io/legal/eula/)
* [ Support ](/docs/support/)
* [ Contributing ](/docs/contributing/)
* Contributing code
* [ Code of Conduct ](/docs/contributing/code-of-conduct/)
* [ Questions ](https://docs.github.com/en/discussions/collaborating-with-your-community-using-discussions/participating-in-a-discussion#creating-a-discussion)
* [ Blog ](/blog/)
* Categories

* [ iOS ](#ios)
* [ Configuration ](#configuration)
* [ Demo ](#demo)
* [ Usage ](#usage)
* [ API ](#api)
* [ Enums ](#enums)
* [ Test your implementation ](#test-your-implementation)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Newsletter ](#newsletter)
* [ Changelog ](#changelog)
* [ License ](#license)

# @capacitor-firebase/analytics[¶](#capacitor-firebaseanalytics "Permanent link")

Unofficial Capacitor plugin for [Firebase Analytics](https://firebase.google.com/docs/analytics).[1](#fn:1)

[ ![Deliver Live Updates to your Capacitor app with Capawesome Cloud](../../../../assets/external/cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.69628c3f.png) ](https://cloud.capawesome.io/) 

## Use Cases[¶](#use-cases "Permanent link")

The Firebase Analytics plugin is typically used to understand how users interact with your app, for example:

* **Event tracking**: Log app events such as sign-ups with custom parameters using `logEvent(...)`.
* **Screen tracking**: Record which screens users visit using `setCurrentScreen(...)`.
* **Audience segmentation**: Assign user IDs and custom user properties to segment your users.
* **Consent management**: Set the user's consent mode and enable or disable data collection to comply with privacy requirements.
* **Conversion measurement**: Initiate on-device conversion measurement with an email address or phone number on iOS.

## Compatibility[¶](#compatibility "Permanent link")

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 8.x.x          | \>=8.x.x          | Active support |
| 7.x.x          | 7.x.x             | Deprecated     |
| 6.x.x          | 6.x.x             | Deprecated     |
| 5.x.x          | 5.x.x             | Deprecated     |
| 1.x.x          | 4.x.x             | Deprecated     |

## Installation[¶](#installation "Permanent link")

You can use our **AI-Assisted Setup** to install the plugin. Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

`[](#%5F%5Fcodelineno-0-1)npx skills add capawesome-team/skills --skill capacitor-plugins
`

Then use the following prompt:

`` [](#%5F%5Fcodelineno-1-1)Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capacitor-firebase/analytics` plugin in my project.
 ``

If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:

`[](#%5F%5Fcodelineno-2-1)npm install @capacitor-firebase/analytics firebase
[](#%5F%5Fcodelineno-2-2)npx cap sync
`

Add Firebase to your project if you haven't already ([Android](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#android) / [iOS](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#ios) / [Web](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#web)).

### Android[¶](#android "Permanent link")

#### Disable Analytics data collection[¶](#disable-analytics-data-collection "Permanent link")

See [Disable Analytics data collection](https://firebase.google.com/docs/analytics/configure-data-collection?platform=android#disable%5Fdata%5Fcollection) if you want to disable Analytics data collection.

#### Disable Advertising ID collection[¶](#disable-advertising-id-collection "Permanent link")

See [Disable Advertising ID collection](https://firebase.google.com/docs/analytics/configure-data-collection?platform=android#disable%5Fadvertising%5Fid%5Fcollection) if you want to disable Advertising ID collection.

#### Variables[¶](#variables "Permanent link")

If needed, you can define the following project variable in your app’s `variables.gradle` file to change the default version of the dependency:

* `$firebaseAnalyticsVersion` version of `com.google.firebase:firebase-analytics` (default: `23.0.0`)

This can be useful if you encounter dependency conflicts with other plugins in your project.

### iOS[¶](#ios "Permanent link")

#### Swift Package Manager[¶](#swift-package-manager "Permanent link")

Add the following to your `capacitor.config.json` (or `capacitor.config.ts`) to avoid a [SwiftPM package identity collision](https://github.com/capawesome-team/capacitor-firebase/issues/959):

`[](#%5F%5Fcodelineno-3-1){
[](#%5F%5Fcodelineno-3-2)  "experimental": {
[](#%5F%5Fcodelineno-3-3)    "ios": {
[](#%5F%5Fcodelineno-3-4)      "spm": {
[](#%5F%5Fcodelineno-3-5)        "packageOptions": {
[](#%5F%5Fcodelineno-3-6)          "@capacitor-firebase/analytics": {
[](#%5F%5Fcodelineno-3-7)            "symlink": true
[](#%5F%5Fcodelineno-3-8)          }
[](#%5F%5Fcodelineno-3-9)        }
[](#%5F%5Fcodelineno-3-10)      }
[](#%5F%5Fcodelineno-3-11)    }
[](#%5F%5Fcodelineno-3-12)  }
[](#%5F%5Fcodelineno-3-13)}
`

**Attention**: SPM `packageOptions` support requires Capacitor CLI **8.4.0+**.

If you are using **CocoaPods** for your iOS project, you need to add the `CapacitorFirebaseAnalytics/Analytics` pod to your `Podfile` (usually `ios/App/Podfile`):

`[](#%5F%5Fcodelineno-4-1)target 'App' do
[](#%5F%5Fcodelineno-4-2)capacitor_pods
[](#%5F%5Fcodelineno-4-3)# Add your Pods here
[](#%5F%5Fcodelineno-4-4)+  pod 'CapacitorFirebaseAnalytics/Analytics', :path => '../../node_modules/@capacitor-firebase/analytics'
[](#%5F%5Fcodelineno-4-5)end
`

**Attention**: Do not add the pod in the section `def capacitor_pods`, but under the comment `# Add your Pods here` ([example](https://github.com/robingenz/capacitor-firebase-plugin-demo/blob/e1684a0af6871442ed0a87dceeeba6fd9ce0185d/ios/App/Podfile#L30)).

#### Disable Analytics data collection[¶](#disable-analytics-data-collection%5F1 "Permanent link")

See [Disable Analytics data collection](https://firebase.google.com/docs/analytics/configure-data-collection?platform=ios#disable%5Fdata%5Fcollection) if you want to disable Analytics data collection.

#### Disable IDFA collection[¶](#disable-idfa-collection "Permanent link")

If you are using **CocoaPods** for your iOS project and you want to disable IDFA collection, you can use the `CapacitorFirebaseAnalytics/AnalyticsWithoutAdIdSupport` pod instead of the `CapacitorFirebaseAnalytics/Analytics` pod:

`[](#%5F%5Fcodelineno-5-1)target 'App' do
[](#%5F%5Fcodelineno-5-2)capacitor_pods
[](#%5F%5Fcodelineno-5-3)# Add your Pods here
[](#%5F%5Fcodelineno-5-4)-  pod 'CapacitorFirebaseAnalytics/Analytics', :path => '../../node_modules/@capacitor-firebase/analytics'
[](#%5F%5Fcodelineno-5-5)+  pod 'CapacitorFirebaseAnalytics/AnalyticsWithoutAdIdSupport', :path => '../../node_modules/@capacitor-firebase/analytics'
[](#%5F%5Fcodelineno-5-6)end
`

If you are using **Swift Package Manager** for your iOS project and you want to disable IDFA collection, you can enable the `AnalyticsWithoutAdIdSupport` trait in your `capacitor.config.json` (or `capacitor.config.ts`):

`[](#%5F%5Fcodelineno-6-1){
[](#%5F%5Fcodelineno-6-2)  "experimental": {
[](#%5F%5Fcodelineno-6-3)    "ios": {
[](#%5F%5Fcodelineno-6-4)      "spm": {
[](#%5F%5Fcodelineno-6-5)        "swiftToolsVersion": "6.1",
[](#%5F%5Fcodelineno-6-6)        "packageTraits": {
[](#%5F%5Fcodelineno-6-7)          "@capacitor-firebase/analytics": ["AnalyticsWithoutAdIdSupport"]
[](#%5F%5Fcodelineno-6-8)        }
[](#%5F%5Fcodelineno-6-9)      }
[](#%5F%5Fcodelineno-6-10)    }
[](#%5F%5Fcodelineno-6-11)  }
[](#%5F%5Fcodelineno-6-12)}
`

**Note**: SPM trait support requires Capacitor CLI **8.3.0+** and Xcode **16.3+** (Swift 6.1+).

## Configuration[¶](#configuration "Permanent link")

No configuration required for this plugin.

## Demo[¶](#demo "Permanent link")

A working example can be found here: [robingenz/capacitor-firebase-plugin-demo](https://github.com/robingenz/capacitor-firebase-plugin-demo)

## Usage[¶](#usage "Permanent link")

The following examples show how to log events, track screens, identify users, manage data collection, configure the session timeout, and initiate on-device conversion measurement.

### Log events[¶](#log-events "Permanent link")

Log an app event with a name and optional parameters:

`[](#%5F%5Fcodelineno-7-1)import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
[](#%5F%5Fcodelineno-7-2)
[](#%5F%5Fcodelineno-7-3)const logEvent = async () => {
[](#%5F%5Fcodelineno-7-4)  await FirebaseAnalytics.logEvent({
[](#%5F%5Fcodelineno-7-5)    name: 'sign_up',
[](#%5F%5Fcodelineno-7-6)    params: { method: 'password' },
[](#%5F%5Fcodelineno-7-7)  });
[](#%5F%5Fcodelineno-7-8)};
`

### Track screens[¶](#track-screens "Permanent link")

Set the current screen name to record which screens users visit. The `screenClassOverride` option is only available on Android and iOS:

`[](#%5F%5Fcodelineno-8-1)import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
[](#%5F%5Fcodelineno-8-2)
[](#%5F%5Fcodelineno-8-3)const setCurrentScreen = async () => {
[](#%5F%5Fcodelineno-8-4)  await FirebaseAnalytics.setCurrentScreen({
[](#%5F%5Fcodelineno-8-5)    screenName: 'Login',
[](#%5F%5Fcodelineno-8-6)    screenClassOverride: 'LoginPage',
[](#%5F%5Fcodelineno-8-7)  });
[](#%5F%5Fcodelineno-8-8)};
`

### Identify users[¶](#identify-users "Permanent link")

Set the user ID property and custom user properties to segment your users:

`[](#%5F%5Fcodelineno-9-1)import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
[](#%5F%5Fcodelineno-9-2)
[](#%5F%5Fcodelineno-9-3)const setUserId = async () => {
[](#%5F%5Fcodelineno-9-4)  await FirebaseAnalytics.setUserId({
[](#%5F%5Fcodelineno-9-5)    userId: '123',
[](#%5F%5Fcodelineno-9-6)  });
[](#%5F%5Fcodelineno-9-7)};
[](#%5F%5Fcodelineno-9-8)
[](#%5F%5Fcodelineno-9-9)const setUserProperty = async () => {
[](#%5F%5Fcodelineno-9-10)  await FirebaseAnalytics.setUserProperty({
[](#%5F%5Fcodelineno-9-11)    key: 'language',
[](#%5F%5Fcodelineno-9-12)    value: 'en',
[](#%5F%5Fcodelineno-9-13)  });
[](#%5F%5Fcodelineno-9-14)};
`

### Manage data collection[¶](#manage-data-collection "Permanent link")

Enable or disable automatic data collection (the value does not apply until the next run of the app), check whether it is enabled (only available on Web), or clear all analytics data from the device (only available on Android and iOS):

`[](#%5F%5Fcodelineno-10-1)import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
[](#%5F%5Fcodelineno-10-2)
[](#%5F%5Fcodelineno-10-3)const setEnabled = async () => {
[](#%5F%5Fcodelineno-10-4)  await FirebaseAnalytics.setEnabled({
[](#%5F%5Fcodelineno-10-5)    enabled: true,
[](#%5F%5Fcodelineno-10-6)  });
[](#%5F%5Fcodelineno-10-7)};
[](#%5F%5Fcodelineno-10-8)
[](#%5F%5Fcodelineno-10-9)const isEnabled = async () => {
[](#%5F%5Fcodelineno-10-10)  const { enabled } = await FirebaseAnalytics.isEnabled();
[](#%5F%5Fcodelineno-10-11)  return enabled;
[](#%5F%5Fcodelineno-10-12)};
[](#%5F%5Fcodelineno-10-13)
[](#%5F%5Fcodelineno-10-14)const resetAnalyticsData = async () => {
[](#%5F%5Fcodelineno-10-15)  await FirebaseAnalytics.resetAnalyticsData();
[](#%5F%5Fcodelineno-10-16)};
`

### Configure the session timeout[¶](#configure-the-session-timeout "Permanent link")

Set the duration of inactivity that terminates the current session. Only available on Android and iOS:

`[](#%5F%5Fcodelineno-11-1)import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
[](#%5F%5Fcodelineno-11-2)
[](#%5F%5Fcodelineno-11-3)const setSessionTimeoutDuration = async () => {
[](#%5F%5Fcodelineno-11-4)  await FirebaseAnalytics.setSessionTimeoutDuration({
[](#%5F%5Fcodelineno-11-5)    duration: '120',
[](#%5F%5Fcodelineno-11-6)  });
[](#%5F%5Fcodelineno-11-7)};
`

### Initiate on-device conversion measurement[¶](#initiate-on-device-conversion-measurement "Permanent link")

Initiate on-device conversion measurement with a plain or hashed email address or phone number. Only available on iOS:

`[](#%5F%5Fcodelineno-12-1)import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
[](#%5F%5Fcodelineno-12-2)
[](#%5F%5Fcodelineno-12-3)const initiateOnDeviceConversionMeasurementWithEmailAddress = async () => {
[](#%5F%5Fcodelineno-12-4)  await FirebaseAnalytics.initiateOnDeviceConversionMeasurementWithEmailAddress({
[](#%5F%5Fcodelineno-12-5)    emailAddress: 'mail@example.com',
[](#%5F%5Fcodelineno-12-6)  });
[](#%5F%5Fcodelineno-12-7)};
[](#%5F%5Fcodelineno-12-8)
[](#%5F%5Fcodelineno-12-9)const initiateOnDeviceConversionMeasurementWithPhoneNumber = async () => {
[](#%5F%5Fcodelineno-12-10)  await FirebaseAnalytics.initiateOnDeviceConversionMeasurementWithPhoneNumber({
[](#%5F%5Fcodelineno-12-11)    phoneNumber: '+49123456789',
[](#%5F%5Fcodelineno-12-12)  });
[](#%5F%5Fcodelineno-12-13)};
[](#%5F%5Fcodelineno-12-14)
[](#%5F%5Fcodelineno-12-15)const initiateOnDeviceConversionMeasurementWithHashedEmailAddress = async () => {
[](#%5F%5Fcodelineno-12-16)  await FirebaseAnalytics.initiateOnDeviceConversionMeasurementWithHashedEmailAddress({
[](#%5F%5Fcodelineno-12-17)    emailAddressToHash: 'mail@example.com',
[](#%5F%5Fcodelineno-12-18)  });
[](#%5F%5Fcodelineno-12-19)};
[](#%5F%5Fcodelineno-12-20)
[](#%5F%5Fcodelineno-12-21)const initiateOnDeviceConversionMeasurementWithHashedPhoneNumber = async () => {
[](#%5F%5Fcodelineno-12-22)  await FirebaseAnalytics.initiateOnDeviceConversionMeasurementWithHashedPhoneNumber({
[](#%5F%5Fcodelineno-12-23)    phoneNumberToHash: '+49123456789',
[](#%5F%5Fcodelineno-12-24)  });
[](#%5F%5Fcodelineno-12-25)};
`

## API[¶](#api "Permanent link")

* [getAppInstanceId()](#getappinstanceid)
* [setConsent(...)](#setconsent)
* [setUserId(...)](#setuserid)
* [setUserProperty(...)](#setuserproperty)
* [setCurrentScreen(...)](#setcurrentscreen)
* [logEvent(...)](#logevent)
* [setSessionTimeoutDuration(...)](#setsessiontimeoutduration)
* [setEnabled(...)](#setenabled)
* [isEnabled()](#isenabled)
* [resetAnalyticsData()](#resetanalyticsdata)
* [logTransaction(...)](#logtransaction)
* [initiateOnDeviceConversionMeasurementWithEmailAddress(...)](#initiateondeviceconversionmeasurementwithemailaddress)
* [initiateOnDeviceConversionMeasurementWithPhoneNumber(...)](#initiateondeviceconversionmeasurementwithphonenumber)
* [initiateOnDeviceConversionMeasurementWithHashedEmailAddress(...)](#initiateondeviceconversionmeasurementwithhashedemailaddress)
* [initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(...)](#initiateondeviceconversionmeasurementwithhashedphonenumber)
* [Interfaces](#interfaces)
* [Enums](#enums)

### getAppInstanceId()[¶](#getappinstanceid "Permanent link")

`[](#%5F%5Fcodelineno-13-1)getAppInstanceId() => Promise<GetAppInstanceIdResult>
`

Retrieves the app instance id.

Only available for Android and iOS.

**Returns:** `Promise<[GetAppInstanceIdResult](#getappinstanceidresult)>`

**Since:** 1.4.0

---

### setConsent(...)[¶](#setconsent "Permanent link")

`[](#%5F%5Fcodelineno-14-1)setConsent(options: SetConsentOptions) => Promise<void>
`

Sets the user's consent mode.

| Param       | Type                                    |
| ----------- | --------------------------------------- |
| **options** | [SetConsentOptions](#setconsentoptions) |

**Since:** 6.0.0

---

### setUserId(...)[¶](#setuserid "Permanent link")

`[](#%5F%5Fcodelineno-15-1)setUserId(options: SetUserIdOptions) => Promise<void>
`

Sets the user ID property.

| Param       | Type                                  |
| ----------- | ------------------------------------- |
| **options** | [SetUserIdOptions](#setuseridoptions) |

**Since:** 0.1.0

---

### setUserProperty(...)[¶](#setuserproperty "Permanent link")

`[](#%5F%5Fcodelineno-16-1)setUserProperty(options: SetUserPropertyOptions) => Promise<void>
`

Sets a custom user property to a given value.

| Param       | Type                                              |
| ----------- | ------------------------------------------------- |
| **options** | [SetUserPropertyOptions](#setuserpropertyoptions) |

**Since:** 0.1.0

---

### setCurrentScreen(...)[¶](#setcurrentscreen "Permanent link")

`[](#%5F%5Fcodelineno-17-1)setCurrentScreen(options: SetCurrentScreenOptions) => Promise<void>
`

Sets the current screen name.

| Param       | Type                                                |
| ----------- | --------------------------------------------------- |
| **options** | [SetCurrentScreenOptions](#setcurrentscreenoptions) |

**Since:** 0.1.0

---

### logEvent(...)[¶](#logevent "Permanent link")

`[](#%5F%5Fcodelineno-18-1)logEvent(options: LogEventOptions) => Promise<void>
`

Logs an app event.

| Param       | Type                                |
| ----------- | ----------------------------------- |
| **options** | [LogEventOptions](#logeventoptions) |

**Since:** 0.1.0

---

### setSessionTimeoutDuration(...)[¶](#setsessiontimeoutduration "Permanent link")

`[](#%5F%5Fcodelineno-19-1)setSessionTimeoutDuration(options: SetSessionTimeoutDurationOptions) => Promise<void>
`

Sets the duration of inactivity that terminates the current session.

Only available for Android and iOS.

| Param       | Type                                                                  |
| ----------- | --------------------------------------------------------------------- |
| **options** | [SetSessionTimeoutDurationOptions](#setsessiontimeoutdurationoptions) |

**Since:** 0.1.0

---

### setEnabled(...)[¶](#setenabled "Permanent link")

`[](#%5F%5Fcodelineno-20-1)setEnabled(options: SetEnabledOptions) => Promise<void>
`

Enables/disables automatic data collection. The value does not apply until the next run of the app.

| Param       | Type                                    |
| ----------- | --------------------------------------- |
| **options** | [SetEnabledOptions](#setenabledoptions) |

**Since:** 0.1.0

---

### isEnabled()[¶](#isenabled "Permanent link")

`[](#%5F%5Fcodelineno-21-1)isEnabled() => Promise<IsEnabledResult>
`

Returns whether or not automatic data collection is enabled.

Only available for Web.

**Returns:** `Promise<[IsEnabledResult](#isenabledresult)>`

**Since:** 0.1.0

---

### resetAnalyticsData()[¶](#resetanalyticsdata "Permanent link")

`[](#%5F%5Fcodelineno-22-1)resetAnalyticsData() => Promise<void>
`

Clears all analytics data for this app from the device. Resets the app instance id.

Only available for Android and iOS.

**Since:** 0.1.0

---

### logTransaction(...)[¶](#logtransaction "Permanent link")

`[](#%5F%5Fcodelineno-23-1)logTransaction(options: LogTransactionOptions) => Promise<void>
`

Logs a StoreKit 2 transaction.

Only available for iOS (15.0+).

| Param       | Type                                            |
| ----------- | ----------------------------------------------- |
| **options** | [LogTransactionOptions](#logtransactionoptions) |

**Since:** 8.2.0

---

### initiateOnDeviceConversionMeasurementWithEmailAddress(...)[¶](#initiateondeviceconversionmeasurementwithemailaddress "Permanent link")

`[](#%5F%5Fcodelineno-24-1)initiateOnDeviceConversionMeasurementWithEmailAddress(options: InitiateOnDeviceConversionMeasurementWithEmailAddressOptions) => Promise<void>
`

Initiates on-device conversion measurement with an email address.

Only available for iOS.

| Param       | Type                                                                                                                          |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **options** | [InitiateOnDeviceConversionMeasurementWithEmailAddressOptions](#initiateondeviceconversionmeasurementwithemailaddressoptions) |

**Since:** 7.2.0

---

### initiateOnDeviceConversionMeasurementWithPhoneNumber(...)[¶](#initiateondeviceconversionmeasurementwithphonenumber "Permanent link")

`[](#%5F%5Fcodelineno-25-1)initiateOnDeviceConversionMeasurementWithPhoneNumber(options: InitiateOnDeviceConversionMeasurementWithPhoneNumberOptions) => Promise<void>
`

Initiates on-device conversion measurement with a phone number.

Only available for iOS.

| Param       | Type                                                                                                                        |
| ----------- | --------------------------------------------------------------------------------------------------------------------------- |
| **options** | [InitiateOnDeviceConversionMeasurementWithPhoneNumberOptions](#initiateondeviceconversionmeasurementwithphonenumberoptions) |

**Since:** 7.2.0

---

### initiateOnDeviceConversionMeasurementWithHashedEmailAddress(...)[¶](#initiateondeviceconversionmeasurementwithhashedemailaddress "Permanent link")

`[](#%5F%5Fcodelineno-26-1)initiateOnDeviceConversionMeasurementWithHashedEmailAddress(options: InitiateOnDeviceConversionMeasurementWithHashedEmailAddressOptions) => Promise<void>
`

Initiates on-device conversion measurement with a hashed email address.

Only available for iOS.

| Param       | Type                                                                                                                                      |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **options** | [InitiateOnDeviceConversionMeasurementWithHashedEmailAddressOptions](#initiateondeviceconversionmeasurementwithhashedemailaddressoptions) |

**Since:** 7.2.0

---

### initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(...)[¶](#initiateondeviceconversionmeasurementwithhashedphonenumber "Permanent link")

`[](#%5F%5Fcodelineno-27-1)initiateOnDeviceConversionMeasurementWithHashedPhoneNumber(options: InitiateOnDeviceConversionMeasurementWithHashedPhoneNumberOptions) => Promise<void>
`

Initiates on-device conversion measurement with a hashed phone number.

Only available for iOS.

| Param       | Type                                                                                                                                    |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| **options** | [InitiateOnDeviceConversionMeasurementWithHashedPhoneNumberOptions](#initiateondeviceconversionmeasurementwithhashedphonenumberoptions) |

**Since:** 7.2.0

---

### Interfaces[¶](#interfaces "Permanent link")

#### GetAppInstanceIdResult[¶](#getappinstanceidresult "Permanent link")

| Prop              | Type   | Description                                                                                                                                                                                          | Since |
| ----------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **appInstanceId** | string | The app instance id. Not defined if FirebaseAnalytics.<a href="#consenttype">ConsentType</a>.ANALYTICS\_STORAGE has been set to FirebaseAnalytics.<a href="#consentstatus">ConsentStatus</a>.DENIED. | 1.4.0 |

#### SetConsentOptions[¶](#setconsentoptions "Permanent link")

| Prop       | Type                            | Description         | Since |
| ---------- | ------------------------------- | ------------------- | ----- |
| **type**   | [ConsentType](#consenttype)     | The consent type.   | 6.0.0 |
| **status** | [ConsentStatus](#consentstatus) | The consent status. | 6.0.0 |

#### SetUserIdOptions[¶](#setuseridoptions "Permanent link")

| Prop       | Type           | Since |
| ---------- | -------------- | ----- |
| **userId** | string \| null | 0.1.0 |

#### SetUserPropertyOptions[¶](#setuserpropertyoptions "Permanent link")

| Prop      | Type           | Since |
| --------- | -------------- | ----- |
| **key**   | string         | 0.1.0 |
| **value** | string \| null | 0.1.0 |

#### SetCurrentScreenOptions[¶](#setcurrentscreenoptions "Permanent link")

| Prop                    | Type           | Description                         | Default | Since |
| ----------------------- | -------------- | ----------------------------------- | ------- | ----- |
| **screenName**          | string \| null |                                     |         | 0.1.0 |
| **screenClassOverride** | string \| null | Only available for Android and iOS. | null    | 0.1.0 |

#### LogEventOptions[¶](#logeventoptions "Permanent link")

| Prop       | Type                      | Description                | Since |
| ---------- | ------------------------- | -------------------------- | ----- |
| **name**   | string                    | The event name.            | 0.1.0 |
| **params** | { \[key: string\]: any; } | The optional event params. | 0.1.0 |

#### SetSessionTimeoutDurationOptions[¶](#setsessiontimeoutdurationoptions "Permanent link")

| Prop         | Type   | Description          | Default | Since |
| ------------ | ------ | -------------------- | ------- | ----- |
| **duration** | number | Duration in seconds. | 1800    | 0.1.0 |

#### SetEnabledOptions[¶](#setenabledoptions "Permanent link")

| Prop        | Type    | Since |
| ----------- | ------- | ----- |
| **enabled** | boolean | 0.1.0 |

#### IsEnabledResult[¶](#isenabledresult "Permanent link")

| Prop        | Type    | Since |
| ----------- | ------- | ----- |
| **enabled** | boolean | 0.1.0 |

#### LogTransactionOptions[¶](#logtransactionoptions "Permanent link")

| Prop              | Type   | Description                                              | Since |
| ----------------- | ------ | -------------------------------------------------------- | ----- |
| **transactionId** | string | The StoreKit 2 Transaction.id value as a numeric string. | 8.2.0 |

#### InitiateOnDeviceConversionMeasurementWithEmailAddressOptions[¶](#initiateondeviceconversionmeasurementwithemailaddressoptions "Permanent link")

| Prop             | Type   | Description                                                          | Since |
| ---------------- | ------ | -------------------------------------------------------------------- | ----- |
| **emailAddress** | string | The email address to initiate on-device conversion measurement with. | 7.2.0 |

#### InitiateOnDeviceConversionMeasurementWithPhoneNumberOptions[¶](#initiateondeviceconversionmeasurementwithphonenumberoptions "Permanent link")

| Prop            | Type   | Description                                                         | Since |
| --------------- | ------ | ------------------------------------------------------------------- | ----- |
| **phoneNumber** | string | The phone number to initiate on-device conversion measurement with. | 7.2.0 |

#### InitiateOnDeviceConversionMeasurementWithHashedEmailAddressOptions[¶](#initiateondeviceconversionmeasurementwithhashedemailaddressoptions "Permanent link")

| Prop                   | Type   | Description                                                          | Since |
| ---------------------- | ------ | -------------------------------------------------------------------- | ----- |
| **emailAddressToHash** | string | The email address to initiate on-device conversion measurement with. | 7.2.0 |

#### InitiateOnDeviceConversionMeasurementWithHashedPhoneNumberOptions[¶](#initiateondeviceconversionmeasurementwithhashedphonenumberoptions "Permanent link")

| Prop                  | Type   | Description                                                         | Since |
| --------------------- | ------ | ------------------------------------------------------------------- | ----- |
| **phoneNumberToHash** | string | The phone number to initiate on-device conversion measurement with. | 7.2.0 |

### Enums[¶](#enums "Permanent link")

#### ConsentType[¶](#consenttype "Permanent link")

| Members                    | Value                      | Since |
| -------------------------- | -------------------------- | ----- |
| **AdPersonalization**      | 'AD\_PERSONALIZATION'      | 6.0.0 |
| **AdStorage**              | 'AD\_STORAGE'              | 6.0.0 |
| **AdUserData**             | 'AD\_USER\_DATA'           | 6.0.0 |
| **AnalyticsStorage**       | 'ANALYTICS\_STORAGE'       | 6.0.0 |
| **FunctionalityStorage**   | 'FUNCTIONALITY\_STORAGE'   | 6.0.0 |
| **PersonalizationStorage** | 'PERSONALIZATION\_STORAGE' | 6.0.0 |

#### ConsentStatus[¶](#consentstatus "Permanent link")

| Members     | Value     | Since |
| ----------- | --------- | ----- |
| **Granted** | 'GRANTED' | 6.0.0 |
| **Denied**  | 'DENIED'  | 6.0.0 |

## Test your implementation[¶](#test-your-implementation "Permanent link")

[Here](https://firebase.google.com/docs/analytics/debugview) you can find more information on how to test the Firebase Analytics implementation using the **DebugView**.

## FAQ[¶](#faq "Permanent link")

### How can I verify that my events are being logged?[¶](#how-can-i-verify-that-my-events-are-being-logged "Permanent link")

Use the **DebugView** in the Firebase console to inspect events as they are logged by your app. See the [DebugView documentation](https://firebase.google.com/docs/analytics/debugview) for more information on how to test your Firebase Analytics implementation.

### How can I disable analytics data collection?[¶](#how-can-i-disable-analytics-data-collection "Permanent link")

You can enable or disable automatic data collection at runtime using the `setEnabled(...)` method; note that the value does not apply until the next run of the app. To disable data collection by default, follow the platform-specific instructions linked in the [Installation](#installation) section for Android and iOS.

### How do I set the user's consent mode?[¶](#how-do-i-set-the-users-consent-mode "Permanent link")

Call the `setConsent(...)` method with a consent type (for example analytics storage or ad storage) and a consent status (granted or denied). This allows you to manage what data is collected based on the user's consent.

### Why is the app instance ID not defined?[¶](#why-is-the-app-instance-id-not-defined "Permanent link")

The `appInstanceId` returned by `getAppInstanceId()` is not defined if the analytics storage consent type has been set to denied via `setConsent(...)`. Also note that `getAppInstanceId()` is only available on Android and iOS.

### How do I disable Advertising ID or IDFA collection?[¶](#how-do-i-disable-advertising-id-or-idfa-collection "Permanent link")

On Android, follow the [Disable Advertising ID collection](https://firebase.google.com/docs/analytics/configure-data-collection?platform=android#disable%5Fadvertising%5Fid%5Fcollection) guide. On iOS, use the `CapacitorFirebaseAnalytics/AnalyticsWithoutAdIdSupport` pod instead of the `CapacitorFirebaseAnalytics/Analytics` pod if you are using CocoaPods, or enable the `AnalyticsWithoutAdIdSupport` package trait if you are using Swift Package Manager. See the [Installation](#installation) section for details.

### Can I use this plugin with Ionic, React, Vue or Angular?[¶](#can-i-use-this-plugin-with-ionic-react-vue-or-angular "Permanent link")

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

## Related Plugins[¶](#related-plugins "Permanent link")

* [Firebase App](https://capawesome.io/docs/sdks/capacitor/firebase/app/): Access the core Firebase app configuration.
* [Firebase Crashlytics](https://capawesome.io/docs/sdks/capacitor/firebase/crashlytics/): Track and report app crashes with Firebase Crashlytics.
* [Firebase Performance Monitoring](https://capawesome.io/docs/sdks/capacitor/firebase/performance-monitoring/): Measure the performance of your app with Firebase Performance Monitoring.
* [Firebase Remote Config](https://capawesome.io/docs/sdks/capacitor/firebase/remote-config/): Change the behavior and appearance of your app without publishing an app update.

## Newsletter[¶](#newsletter "Permanent link")

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).

## Changelog[¶](#changelog "Permanent link")

See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/analytics/CHANGELOG.md).

## License[¶](#license "Permanent link")

See [LICENSE](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/analytics/LICENSE).

---

1. This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries. [↩](#fnref:1 "Jump back to footnote 1 in the text")

July 8, 2026 

Back to top

```json
{"@context": "https://schema.org", "@graph": [{"@type": "TechArticle", "@id": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/#article", "headline": "Capacitor Firebase Analytics Plugin", "name": "Capacitor Firebase Analytics Plugin", "description": "Unofficial Capacitor plugin for Firebase Analytics SDK to track user interactions and events in your app.", "inLanguage": "en", "url": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/", "mainEntityOfPage": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "about": {"@id": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/#software"}}, {"@type": "SoftwareSourceCode", "@id": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/#software", "name": "Capacitor Firebase Analytics Plugin", "description": "Unofficial Capacitor plugin for Firebase Analytics SDK to track user interactions and events in your app.", "url": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/", "programmingLanguage": "TypeScript", "runtimePlatform": "Capacitor", "codeRepository": "https://github.com/capawesome-team", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}}]}
{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "How can I verify that my events are being logged?", "acceptedAnswer": {"@type": "Answer", "text": "Use the DebugView in the Firebase console to inspect events as they are logged by your app. See the DebugView documentation for more information on how to test your Firebase Analytics implementation."}}, {"@type": "Question", "name": "How can I disable analytics data collection?", "acceptedAnswer": {"@type": "Answer", "text": "You can enable or disable automatic data collection at runtime using the setEnabled(...) method; note that the value does not apply until the next run of the app. To disable data collection by default, follow the platform-specific instructions linked in the Installation section for Android and iOS."}}, {"@type": "Question", "name": "How do I set the user's consent mode?", "acceptedAnswer": {"@type": "Answer", "text": "Call the setConsent(...) method with a consent type (for example analytics storage or ad storage) and a consent status (granted or denied). This allows you to manage what data is collected based on the user's consent."}}, {"@type": "Question", "name": "Why is the app instance ID not defined?", "acceptedAnswer": {"@type": "Answer", "text": "The appInstanceId returned by getAppInstanceId() is not defined if the analytics storage consent type has been set to denied via setConsent(...). Also note that getAppInstanceId() is only available on Android and iOS."}}, {"@type": "Question", "name": "How do I disable Advertising ID or IDFA collection?", "acceptedAnswer": {"@type": "Answer", "text": "On Android, follow the Disable Advertising ID collection guide. On iOS, use the CapacitorFirebaseAnalytics/AnalyticsWithoutAdIdSupport pod instead of the CapacitorFirebaseAnalytics/Analytics pod if you are using CocoaPods, or enable the AnalyticsWithoutAdIdSupport package trait if you are using Swift Package Manager. See the Installation section for details."}}, {"@type": "Question", "name": "Can I use this plugin with Ionic, React, Vue or Angular?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects."}}], "url": "https://capawesome.io/docs/sdks/capacitor/firebase/analytics/"}
```
