---
title: "Track App Events with Firebase Analytics in Capacitor"
description: Measure user behavior in a Capacitor app with Firebase Analytics, covering setup, event and screen tracking, consent, and DebugView verification.
date:
  created: 2026-08-01
  updated: 2026-08-01
authors:
  - djabif
categories:
  - Capacitor
  - Firebase
  - Guides
  - SDKs
links:
  - Capacitor Firebase Analytics: sdks/capacitor/firebase/analytics.md
faq: true
---

# Track App Events with Firebase Analytics in Capacitor

Knowing what users actually do in your app, not just how many installed it, is the difference between guessing and deciding. The [Capacitor Firebase Analytics plugin](../../sdks/capacitor/firebase/analytics.md) gives you Google's free, unlimited-volume analytics service behind one API for Android, iOS, and web.

This guide walks the whole thing end to end — installing and configuring the plugin, logging events and screen views, and verifying them in real time — plus the platform quirks that catch teams off guard and the parts of Firebase Analytics that are easy to get wrong in production.

<!-- more -->

<div class="capawesome-z29o10a">
  <a href="/" target="_blank">
    <img alt="Build and deploy your Capacitor app with Capawesome Cloud" src="https://capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.png?t=1" />
  </a>
</div>

## How to Add Firebase Analytics to a Capacitor App

Adding Firebase Analytics to a Capacitor app takes four steps:

1. **Install** `@capacitor-firebase/analytics` and the `firebase` package.
2. **Add the native config files** (`google-services.json` on Android, `GoogleService-Info.plist` on iOS) — Analytics starts collecting automatically once they're in place.
3. **Log events and screen views** with `logEvent()` and `setCurrentScreen()`.
4. **Verify in real time** with DebugView, since standard reports lag about an hour.

The rest of this guide covers each step in detail, plus consent, the platform quirks, and troubleshooting.

## What Is Firebase Analytics?

[Firebase Analytics](https://firebase.google.com/docs/analytics){:target="_blank"} is Google's free app measurement service: event logging, audience segmentation, and conversion tracking, all reported in the Firebase console. The [Capacitor Firebase Analytics plugin](../../sdks/capacitor/firebase/analytics.md) exposes the native Android and iOS Analytics SDKs, plus the Firebase JS SDK on web, behind one shared TypeScript API.

A working example can be found here: [capawesome-team/capacitor-firebase-plugin-demo](https://github.com/capawesome-team/capacitor-firebase-plugin-demo){:target="_blank"}.

### Why Not Just Use the Firebase JS SDK?

A few Analytics features have no equivalent in the web-only JS SDK running inside a WebView at all. On-device conversion measurement, matching an ad click to an app install using a hashed email or phone number, is iOS-native only and requires the native SDK. The same goes for the advertising ID (IDFA) handling covered below, which depends on Apple's native App Tracking Transparency framework, not something a WebView can intercept. For everything else, the native SDKs also just give you deeper platform integration (automatic screen tracking hooks, native session management) that the JS SDK can't replicate inside an embedded WebView.

!!! tip "Advanced Operations"

    This guide covers the operations most apps need. For every method with code samples, see the [Usage section of the plugin docs](https://capawesome.io/docs/sdks/capacitor/firebase/analytics/#usage){:target="_blank"}.

## Why Use Firebase Analytics in a Capacitor App?

The plugin's own use cases map to five real scenarios:

**Event tracking.** Log app events with custom parameters using [`logEvent(...)`](../../sdks/capacitor/firebase/analytics.md#logevent), like a sign-up or a purchase:

```typescript
import { FirebaseAnalytics } from '@capacitor-firebase/analytics';

const logEvent = async () => {
  await FirebaseAnalytics.logEvent({
    name: 'sign_up',
    params: { method: 'password' },
  });
};
```

**Screen tracking.** Record which screens users visit with [`setCurrentScreen(...)`](../../sdks/capacitor/firebase/analytics.md#setcurrentscreen):

```typescript
import { FirebaseAnalytics } from '@capacitor-firebase/analytics';

const setCurrentScreen = async () => {
  await FirebaseAnalytics.setCurrentScreen({
    screenName: 'Login',
    screenClassOverride: 'LoginPage',
  });
};
```

**Audience segmentation.** Assign a user ID with [`setUserId(...)`](../../sdks/capacitor/firebase/analytics.md#setuserid) and custom properties with [`setUserProperty(...)`](../../sdks/capacitor/firebase/analytics.md#setuserproperty) to segment users in reports:

```typescript
import { FirebaseAnalytics } from '@capacitor-firebase/analytics';

const setUserId = async () => {
  await FirebaseAnalytics.setUserId({ userId: '123' });
};

const setUserProperty = async () => {
  await FirebaseAnalytics.setUserProperty({ key: 'language', value: 'en' });
};
```

**Consent management.** Set the user's consent mode with [`setConsent(...)`](../../sdks/capacitor/firebase/analytics.md#setconsent) to comply with privacy requirements like GDPR:

```typescript
import { ConsentStatus, ConsentType, FirebaseAnalytics } from '@capacitor-firebase/analytics';

const setConsent = async () => {
  await FirebaseAnalytics.setConsent({
    type: ConsentType.AnalyticsStorage,
    status: ConsentStatus.Denied,
  });
};
```

**Conversion measurement.** Initiate on-device conversion measurement with [`initiateOnDeviceConversionMeasurementWithEmailAddress(...)`](../../sdks/capacitor/firebase/analytics.md#initiateondeviceconversionmeasurementwithemailaddress) or a phone number, iOS only:

```typescript
import { FirebaseAnalytics } from '@capacitor-firebase/analytics';

const initiateOnDeviceConversionMeasurement = async () => {
  await FirebaseAnalytics.initiateOnDeviceConversionMeasurementWithEmailAddress({
    emailAddress: 'mail@example.com',
  });
};
```

## Before You Start

This guide assumes you already have a Capacitor app with the `android` and/or `ios` platforms added, and a Firebase project (create one in the [Firebase console](https://console.firebase.google.com/){:target="_blank"} if you haven't). Analytics needs no separate console setup — it starts collecting as soon as the SDK is wired up.

## Step 1: Install the Plugin

Analytics uses the `firebase` package on the web layer, so install both, then sync:

```bash
npm install @capacitor-firebase/analytics firebase
npx cap sync
```

## Step 2: Add Firebase to Your Native Apps

The plugin collects analytics through the native config files Firebase generates ([full reference](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md){:target="_blank"}):

- **Android** — register an Android app, download `google-services.json`, and place it in `android/app/google-services.json`.
- **iOS** — register an iOS app, download `GoogleService-Info.plist`, move it to `ios/App/App/GoogleService-Info.plist`, and drag it into the Xcode project (add it to all targets).
- **Web** — register a Web app and initialize the Firebase JS SDK with the config the console gives you.

On **iOS with Swift Package Manager**, add the SPM `symlink` package option to `capacitor.config.ts` to avoid a package identity collision (Capacitor CLI 8.4.0+); if you use **CocoaPods**, add the `CapacitorFirebaseAnalytics/Analytics` pod to your `Podfile`. This is also where you decide whether to collect Apple's advertising identifier (IDFA), because it's chosen at install time, not at runtime — see [Get IDFA/Advertising ID Handling Right on iOS](#get-idfaadvertising-id-handling-right-on-ios).

The plugin itself needs no additional configuration; once the config file is present, Analytics starts collecting automatically.

## Track Screen Views in Angular, React, or Vue

Firebase logs a `screen_view` event when you call [`setCurrentScreen(...)`](../../sdks/capacitor/firebase/analytics.md#setcurrentscreen). In a single-page Capacitor app the cleanest place to call it is your router, so every navigation records a screen automatically:

=== "Angular"

    ```typescript
    import { inject } from '@angular/core';
    import { Router, NavigationEnd } from '@angular/router';
    import { filter } from 'rxjs';
    import { FirebaseAnalytics } from '@capacitor-firebase/analytics';

    // Call this once from your root component or an app initializer
    export const trackScreens = () => {
      const router = inject(Router);
      router.events
        .pipe(filter((event): event is NavigationEnd => event instanceof NavigationEnd))
        .subscribe(event => {
          FirebaseAnalytics.setCurrentScreen({ screenName: event.urlAfterRedirects });
        });
    };
    ```

=== "React"

    ```tsx
    import { useEffect } from 'react';
    import { useLocation } from 'react-router-dom';
    import { FirebaseAnalytics } from '@capacitor-firebase/analytics';

    export const useScreenTracking = () => {
      const location = useLocation();
      useEffect(() => {
        FirebaseAnalytics.setCurrentScreen({ screenName: location.pathname });
      }, [location]);
    };
    ```

=== "Vue"

    ```typescript
    import { FirebaseAnalytics } from '@capacitor-firebase/analytics';
    import router from './router';

    router.afterEach(to => {
      FirebaseAnalytics.setCurrentScreen({ screenName: to.path });
    });
    ```

## Run on a Device and Verify

Analytics starts collecting automatically once the config file is in place — there's no console toggle to flip. Because standard reports batch for about an hour, verify with **DebugView** instead of waiting:

1. Enable debug mode on your device:
    - **Android:** `adb shell setprop debug.firebase.analytics.app <your.package.name>`
    - **iOS:** add `-FIRDebugEnabled` as a launch argument in your Xcode scheme.
2. Build and run: `npx cap run android` (or `npx cap run ios`).
3. Trigger some events in the app, then open **Analytics → DebugView** in the Firebase console — your events should appear within seconds.

If nothing shows up, it's almost always debug mode not enabled on the device, or the config file missing (Step 2).

## Firebase Analytics Best Practices

### Set Consent Before You Log Anything

If you need consent management (GDPR, CCPA, or similar), call [`setConsent(...)`](../../sdks/capacitor/firebase/analytics.md#setconsent) as early as possible in your app's startup, before any [`logEvent(...)`](../../sdks/capacitor/firebase/analytics.md#logevent) calls. Consent state governs what gets collected going forward, so events logged before consent is set may capture more than you intended.

### Know Which Methods Are Platform-Specific

A few methods only work on some platforms, and the split isn't symmetric in the direction you'd expect: [`isEnabled()`](../../sdks/capacitor/firebase/analytics.md#isenabled) only works on **Web**, while [`resetAnalyticsData()`](../../sdks/capacitor/firebase/analytics.md#resetanalyticsdata) only works on **Android and iOS**. [`setSessionTimeoutDuration(...)`](../../sdks/capacitor/firebase/analytics.md#setsessiontimeoutduration) is Android/iOS only, and `screenClassOverride` on `setCurrentScreen(...)` is also Android/iOS only. Don't assume a method that works on your dev machine (often web) will behave the same on device, or vice versa.

### Verify Events with DebugView Before You Ship

Don't wait for the standard Firebase console reports to confirm your events are logging correctly. Standard reports batch events for about an hour before uploading, so you won't see immediate feedback. [DebugView](https://firebase.google.com/docs/analytics/debugview){:target="_blank"} uploads events with minimal delay instead, so you can validate an implementation in minutes instead of guessing for an hour.

### Get IDFA/Advertising ID Handling Right on iOS

Disabling the Advertising ID on iOS isn't just a runtime call. You need the `CapacitorFirebaseAnalytics/AnalyticsWithoutAdIdSupport` pod (CocoaPods) or the `AnalyticsWithoutAdIdSupport` package trait (Swift Package Manager) instead of the default `Analytics` variant, chosen at install time, not at runtime. Get this wrong and you'll ship IDFA collection code you can't easily disable later without reinstalling the plugin dependency.

Keep in mind this plugin doesn't manage Apple's App Tracking Transparency (ATT) prompt itself. Even with the full IDFA-enabled variant installed, actually collecting the IDFA still requires the user to grant permission through that separate, app-level Apple requirement.

### Respect Firebase's Event Limits

Firebase Analytics allows up to 500 distinct event *types* per app, with no limit on the total volume of events logged. Event names are also case-sensitive: `sign_up` and `Sign_Up` are two different event types as far as Firebase is concerned, which silently fragments your data if you're not consistent about casing across your codebase.

## Limitations

- [`isEnabled()`](../../sdks/capacitor/firebase/analytics.md#isenabled) is only available on Web.
- [`resetAnalyticsData()`](../../sdks/capacitor/firebase/analytics.md#resetanalyticsdata), [`setSessionTimeoutDuration(...)`](../../sdks/capacitor/firebase/analytics.md#setsessiontimeoutduration), and the `screenClassOverride` option are only available on Android and iOS.
- [`logTransaction(...)`](../../sdks/capacitor/firebase/analytics.md#logtransaction), for logging StoreKit 2 purchase transactions, and on-device conversion measurement are only available on iOS.
- [`getAppInstanceId()`](../../sdks/capacitor/firebase/analytics.md#getappinstanceid) is only available on Android and iOS.

## Common Errors and Troubleshooting

- **No events in the Firebase console.** Standard reports lag about an hour by design. Use [DebugView](https://firebase.google.com/docs/analytics/debugview){:target="_blank"} with debug mode enabled (above) for near-real-time confirmation.
- **No events even in DebugView.** Debug mode isn't enabled on the device, or the `google-services.json` / `GoogleService-Info.plist` is missing or misplaced (Step 2).
- **`isEnabled()` throws or does nothing on device.** It's **web-only**. Several methods are platform-restricted in the opposite direction too — check the [platform table](#know-which-methods-are-platform-specific) before assuming a method is broken.
- **Event counts look fragmented.** Event names are case-sensitive — `sign_up` and `Sign_Up` are different event types. Keep casing consistent across the codebase.
- **iOS builds pull in IDFA/ad tracking you didn't want.** The IDFA variant is chosen at install time via the pod/package trait, not at runtime — see [Get IDFA/Advertising ID Handling Right on iOS](#get-idfaadvertising-id-handling-right-on-ios).
- **Collection doesn't stop after a user opts out.** `setConsent(...)` only governs collection *going forward* — call it before your first `logEvent(...)`, as early as possible on startup.

## FAQ

### How do I track screen views with Firebase Analytics in a Capacitor app?

Call [`setCurrentScreen(...)`](../../sdks/capacitor/firebase/analytics.md#setcurrentscreen) whenever the route changes. The cleanest place is your router, so every navigation logs a `screen_view` automatically — see [Track Screen Views in Angular, React, or Vue](#track-screen-views-in-angular-react-or-vue) for a per-framework example.

### Is Firebase Analytics free to use?

Yes, unlike Firestore or Cloud Functions, Firebase Analytics has no usage-based billing at all. It's free with unlimited event volume, capped only by the 500-distinct-event-type limit mentioned above. That makes it one of the few Firebase products with no cost consideration when deciding whether to adopt it.

### Why don't my events show up immediately in the Firebase console?

Because standard Analytics reports batch events over roughly an hour before uploading them, by design, not because something is broken. If you need to confirm an event fired correctly right now, use [DebugView](https://firebase.google.com/docs/analytics/debugview){:target="_blank"} instead of waiting on the standard dashboard.

### What's the difference between `logEvent` and `logTransaction`?

[`logEvent(...)`](../../sdks/capacitor/firebase/analytics.md#logevent) is the general-purpose method for any custom event. [`logTransaction(...)`](../../sdks/capacitor/firebase/analytics.md#logtransaction) is a specialized iOS-only method (15.0+) for logging a StoreKit 2 purchase transaction directly, which matters if you're using [in-app purchases](./tips-for-setting-up-in-app-purchases-with-capacitor.md) and want Firebase to attribute revenue events correctly without you manually re-implementing StoreKit's transaction data as a custom event.

## Ship Tracking Changes Without a Full Release

Your event and screen tracking lives in your app's web layer, so refining what you measure — a renamed event, a new screen, a fixed parameter — doesn't have to wait on an app store review. [Capawesome Cloud](https://capawesome.io/){:target="_blank"} builds your iOS and Android apps in the cloud and pushes those web-layer changes straight to users with live updates, so your analytics can keep pace with the product instead of your release schedule — and it automates App Store and Play Store submission when you do ship natively.

[Book a Capawesome Cloud Demo](https://cal.com/team/capawesome/cloud-demo){ .md-button .md-button--primary }

## Conclusion

Firebase Analytics' real value for a Capacitor app is that it's free, unlimited, and already wired into the rest of the Firebase ecosystem, at the cost of a few platform-specific quirks: `isEnabled()` is web-only, most of the interesting native features (session timeout, IDFA handling, StoreKit 2 transactions, on-device conversion) are Android/iOS-only, and the standard console reports lag behind real usage by about an hour.

If you want to go deeper from here:

- [Firebase Authentication in Capacitor: Setup & Best Practices](./capacitor-firebase-authentication-guide.md) — pair user IDs from Analytics with real signed-in users.
- [Capacitor Firestore: Real-Time Data & Offline Sync](./capacitor-firebase-cloud-firestore-guide.md) — the sibling Firebase plugin for storing and syncing your app's data.
- [Upload & Manage Files with Firebase Storage in Capacitor](./capacitor-firebase-cloud-storage-guide.md) — the sibling Firebase plugin for user-generated files.
- [How to Prepare Your App Store Listing](./how-to-prepare-your-app-store-listing.md) — covers declaring Analytics' data collection in Apple's Privacy Nutrition Labels and Google Play's Data Safety section, a commonly missed step.

Questions or something you ran into that isn't covered here? Drop into the [Capawesome Discord server](https://discord.gg/VCXxSVjefW){:target="_blank"} — and subscribe to the [Capawesome newsletter](https://capawesome.io/newsletter/){:target="_blank"} if you want the next deep-dive in your inbox.
