Firebase Analyticsβ
This plugin is still in beta stage and may not work as expected. Please submit any issues to the plugin repo.
Cordova plugin for Firebase Analytics
Go to firebase console and export google-services.json and GoogleService-Info.plist. Put those files into the root of your cordova app folder.
NOTE: on iOS in order to collect demographic, age, gender data etc. you should additionally include AdSupport.framework into your project.
Repo: https://github.com/chemerisuk/cordova-plugin-firebase-analytics
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-firebase-analytics $ npm install --save @ionic-native/firebase-analytics@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
Usage
import { FirebaseAnalytics } from '@ionic-native/firebase-analytics';
constructor(private firebaseAnalytics: FirebaseAnalytics) { }
...
this.firebaseAnalytics.logEvent('page_view', {page: "dashboard"})
.then((res: any) => console.log(res))
.catch((error: any) => console.error(error));
Instance Members
logEvent(name, params)
Logs an app event. Be aware of automatically collected events.
Param | Type | Details |
---|---|---|
name |
string
|
The name of the event |
params |
any
|
Some param to configure something |
Returns: Promise<any>
Returns a promise
setUserId(id)
Sets the user ID property. This feature must be used in accordance with Google’s Privacy Policy.
Param | Type | Details |
---|---|---|
id |
string
|
The user ID |
Returns: Promise<any>
Returns a promise
setUserProperty(name, value)
This feature must be used in accordance with Google’s Privacy Policy. Be aware of automatically collected user properties.
Param | Type | Details |
---|---|---|
name |
string
|
The property name |
value |
string
|
The property value |
Returns: Promise<any>
Returns a promise
setEnabled(enabled)
Sets whether analytics collection is enabled for this app on this device.
Param | Type | Details |
---|---|---|
enabled |
boolean
|
Returns: Promise<any>
Returns a promise
setCurrentScreen(name)
Sets the current screen name, which specifies the current visual context in your app. This helps identify the areas in your app where users spend their time and how they interact with your app.
Param | Type | Details |
---|---|---|
name |
string
|
The name of the screen |
Returns: Promise<any>
Returns a promise