Analytics Firebase
Google Analytics Firebase plugin for Ionic Native apps.
https://github.com/appfeel/analytics-google
Stuck on a Cordova issue?
If you're building a serious project, you can't afford to spend hours troubleshooting. Ionicβs experts offer premium advisory services for both community plugins and premier plugins.
Installation
- Capacitor
- Cordova
- Enterprise
$ npm install cordova-plugin-analytics
$ npm install @awesome-cordova-plugins/analytics-firebase
$ ionic cap sync
$ ionic cordova plugin add cordova-plugin-analytics
$ npm install @awesome-cordova-plugins/analytics-firebase
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Β Learn More or if you're interested in an enterprise version of this plugin Contact Us
Supported Platforms
- Android
- iOS
Usage
React
Learn more about using Ionic Native components in React
Angular
import { AnalyticsFirebase } from '@awesome-cordova-plugins/analytics-firebase';
constructor(private analyticsFirebase: AnalyticsFirebase) { }
// Track an event with default events and params
const eventParams = {};
eventParams[this.analyticsFirebase.DEFAULT_PARAMS.LEVEL] = 29;
this.analyticsFirebase.logEvent(this.analyticsFirebase.DEFAULT_EVENTS.LEVEL_UP, eventParams)
.then(() => console.log('Event successfully tracked'))
.catch(err => console.log('Error tracking event:', err));
// Track an event with custom events and params
const eventParams = {};
eventParams['my-prop'] = 29;
this.analyticsFirebase.logEvent('my-event', eventParams)
.then(() => console.log('Event successfully tracked'))
.catch(err => console.log('Error tracking event:', err));
// Reset analytics data
this.analyticsFirebase.resetAnalyticsData()
.then(() => console.log('Analytics data have been reset'))
.catch(err => console.log('Error resetting analytics data:', err));
// Track a screen view
this.analyticsFirebase.setCurrentScreen('Home')
.then(() => console.log('View successfully tracked'))
.catch(err => console.log('Error tracking view:', err));
// Set user id
this.analyticsFirebase.setUserId('USER-ID')
.then(() => console.log('User id successfully set'))
.catch(err => console.log('Error setting user id:', err));
// Set user property from default properties
this.analyticsFirebase.setUserProperty('KEY', 'VALUE')
.then(() => console.log('User property successfully set'))
.catch(err => console.log('Error setting user property:', err));