Google analytics

Analytics is key for any successful application; it helps understand which screens are most visited and which products users took interest in the most. We can track many different events that a user does while using the application:

   $ ionic cordova:plugin add cordova-plugin-google-      analytics$ npm install @ionic-native/google-analytics --save

Let's start by initializing the plugin in app.component.ts, here we will set the GoogleAnalytics tracking ID and this will get us started:

// src/app/app.component.tsimport { GoogleAnalytics } from '@ionic-native/google-analytics'; constructor(private ga: GoogleAnalytics) { } platformReady() { // Call any initial plugins when ready this.platform.ready().then(() => { Splashscreen.hide(); ...

Get Hybrid Mobile Development with Ionic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.