Skip to main content
Back to plugins
@capgo/capacitor-firebase-analytics
Tutorial
by github.com/Cap-go

Firebase Analytics

Capacitor plugin for Firebase Analytics

Guide

Tutorial on Firebase Analytics

Using @capgo/capacitor-firebase-analytics

Capacitor plugin for Firebase Analytics.

Install

bun add @capgo/capacitor-firebase-analytics
bunx cap sync

What This Plugin Exposes

  • getAppInstanceId - Retrieves the app instance id.
  • getSessionId - Retrieves the current session id (ga_session_id).
  • setConsent - Sets the user's consent mode.
  • setUserId - Sets the user ID property.

Example Usage

getAppInstanceId

Retrieves the app instance id.

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

await FirebaseAnalytics.getAppInstanceId();

getSessionId

Retrieves the current session id (ga_session_id).

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

await FirebaseAnalytics.getSessionId();

setConsent

Sets the user's consent mode.

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

await FirebaseAnalytics.setConsent({} as SetConsentOptions);

setUserId

Sets the user ID property.

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

await FirebaseAnalytics.setUserId({} as SetUserIdOptions);

Full Reference

Keep going from Using @capgo/capacitor-firebase-analytics

If you are using Using @capgo/capacitor-firebase-analytics to plan native plugin work, connect it with Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives, and Capgo Native Builds for the product workflow in Capgo Native Builds.