Using Google Analytics With IonicFramework

Apple and Google don’t offer much in terms of analytics after an app has been downloaded.  Google will take it a step further than Apple and show how many devices have the app installed rather than just downloads, but nothing in terms of usage.  To use Google Analytics with IonicFramework, not much is required.

There is a convenient plugin created for Apache Cordova by Dan Wilson called simply Google Analytics Plugin.  With a bit of adjusting we can easily use it with AngularJS.

In your project make sure that you’ve added iOS and Android as platforms.  This can be done by running the following from a command line:

Remember that you’ll need a Mac with Xcode installed in order to build for iOS.

When your project is set up, you need to install the analytics plugin into your project.  From the command line run the following:

The Google Analytics plugin is actually very simple to use with IonicFramework.  The initialization code will go in the $ionicPlatform.ready() function as seen below:

The analytics plugin won’t exist for platforms other than iOS and Android so we must make sure the analytics object exists first otherwise we’ll get an error.  Remember to replace the tracking id in the above snippet with your own.

Now that the Google Analytics plugin is initialized, it won’t report data until we tell it to.  Above we have a controller and when called it will immediately report as a view / screen.  When something calls the initEvent method set up in the controller it will report an event.  Events can be button clicks, gestures, or whatever you want them to be.

According to Dan Wilson’s documentation, the following methods are available for use with this plugin:

The API methods were copied directly from the plugin repository documentation.

A video version of this article can be seen below.

Nic Raboy

Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.

  • Charlie

    Should I make a App Google Analytics ID or a Web Google Analaytics ID for a Ionic App/Cordova App? Are there differences?

    • Hi @Charlie,

      For IonicFramework / Cordova applications you should be using an app analytics id rather than a web analytics id. I am no Google expert, but I believe the only differences are that they report different things.

      Cheers,

      • Charlie

        Thank your Nic for the fast reply. I will look at both when I am testing.

    • Confirmed, you need and app ID

  • Thanks,
    1. i will implement it in my ionic app 🙂
    2. i think the custom parameter is very helpful for GA, so u can take a look 🙂

  • Islahul Hassan Zunjani

    Thanks man! It worked, saved many hours I guess!

  • Arun

    I tried the instructions and all I get is Google Analytics Unavailable in console. Am I doing anything wrong?

    I tried this http://stackoverflow.com/questions/26910421/ngcordova-google-analytics-cordovagoogleanalytics instructions as well..but it just goes in endless loop

    • I noticed in your StackOverflow post that you are using ngCordova. I’ve never used the ngCordova wrapper for Google Analytics, so I’m afraid I won’t be of much help on the topic.

      Thanks for noting that you are using the serve command. I encourage you to never use that command when testing plugins of any kind. That command is for testing UI, not functionality. You’ll probably get better results if you build a binary and install it to the device as you would any other mobile application.

      Regards,

      • Arun

        Thats Nic! Appreciate your quick response…I tried to run it on ios phone and xcode emulator and I was able to get the analytics working as expected. You are right….I keep forgetting that cordova plugins don’t usually work on browser emulators. I think adding if(typeof analytics !== “undefined”) will ignore analytics on browser testing. Also, on google analytics admin when registering the app…. you need to choose mobile app and not website (which is default).

        • Awesome, I’m glad you got it working!

  • SubjectiveEffect

    In the TrackView method what exactly is the “Screen title”? Is this the .state name, the url, the templateUrl or something else?

    • It is whatever you want it to be. I usually set it to the name of the controller or state.

      • SubjectiveEffect

        So if I put analytics.trackView(‘dash’) it will track once every time you go to Screen7 where in the app I have this?

        .state(‘tab.dash’, {
        url: ‘/dash’,
        views: {
        ‘tab-dash’: {
        templateUrl: ‘templates/tab-dash.html’,
        controller: ‘DashCtrl’
        }
        }
        })

        • Yea it is just a placeholder value, so that you can make better sense of the data in your Google Analytics dashboard. See which views are used more than others.

  • jome

    It defines analytics when i am open the application first time,But it throws an reference error second time,why?

    • Can you post the full error?

      I need more information go to off.

      Regards,

      • Our project is done using Ionic framework, this issue is noticed only on mobile with Android version: 4.2.1 for others mobile it works fine,

        Scenario,
        – When we open the mobile app it works fine
        – later we close app and start again, analytics obj is undefined
        – When clear the app-cache of the mobile, it works fine again

        Code is exactly is the same you have given and it works well on other 2 mobiles we tested, totally strange.

        • Yes, this is strange. I’d still like to see your logs if you want to pursue this further.

          Regards,

  • Keval

    Hi, thanks for all of your blogs, they were very much helpful to me yet. I am stuck with this plugin now.

    My problem is, the plugin works fine and analytics do happen when I am directly running my app on Android using: ionic run android

    But the moment I sign my APK and then install on my Android device, the app won’t start, all I see is a blank screen.

    From the logcat, I can find this: file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 19387 : ReferenceError: analytics is not defined

    • That is weird. What line in your app.js file is experiencing the error? The reference you provided is not the correct one. If you can’t find it, go ahead and paste your ADB logs in the chat window.

      Regards,

      • Keval

        Is this what you want? The line 224 in controllers.js is analytics.trackView(‘mypage’); in the template’s controller that should load.
        D/CordovaLog(29315): file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 19387 : ReferenceError: analytics is not defined
        D/CordovaLog(29315): at new (file:///android_asset/www/js/controllers.js:224:5)
        D/CordovaLog(29315): at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11994:17)
        D/CordovaLog(29315): at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12002:27)
        D/CordovaLog(29315): at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:16255:28
        D/CordovaLog(29315): at self.appendViewElement (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47320:24)
        D/CordovaLog(29315): at Object.switcher.render (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:45864:41)
        D/CordovaLog(29315): at Object.switcher.init (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:45784:20)
        D/CordovaLog(29315): at self.render (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47225:14)
        D/CordovaLog(29315): at self.register (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47181:10)
        D/CordovaLog(29315): at updateView (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:50834:23)

        • Did you wrap it in a condition like I did in the tutorial?:

          You might also want to wrap it in an $ionicPlatform.ready in case the controller is executing before the plugin loads.

          Regards,

          • Keval

            Sorry for replying back late, I was on a vacation.

            And yep, I have added the condition. Also, it is wrapped inside the $ionicPlatform.ready event.

          • I still find it weird that you’re getting an undefined error.

            What happens when you remove the quotes around undefined? I believe had had them there in error.

            Regards,

          • Keval

            Removed them quotes and IT WORKED! Thank you very much, everything’s working like normal after I sign the apk. And great work you’re doing here, keep it up. 🙂

          • I fixed the quotation marks in the article now. I’m glad it works for you!

            Thanks for the compliment as well 🙂

            Regards,

  • Gustavo Gervásio

    Hi, can i help me??

    I follow your tutorial, but when i run app i receiver the msg Unavailable.

    I use ionic

    • What do your full logs say?

      • Gustavo Gervásio

        How see the log at device?

          • Gustavo Gervásio

            the logcat, i can find this “Google Analytics Unavailable”, source: file:///android_asset/www/js/controllers.js (12)

          • Try wrapping it in an $ionicPlatform.ready(). Maybe the controller is trying to run the code before the plugin is ready.

          • Gustavo Gervásio

            i try put in $ionicPlatform.ready()

            but i don’t receiver sucess.

            my log

            I/ActivityManager( 1220): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=br.com.petlove.petlove/.MainActivity (has extras)} from uid 10008 on display 0

            W/AudioTrack( 1220): AUDIO_OUTPUT_FLAG_FAST denied by client

            I/art ( 3318): Not late-enabling -Xcheck:jni (already on)

            I/ActivityManager( 1220): Start proc br.com.petlove.petlove for activity br.com.petlove.petlove/.MainActivity: pid=3318 uid=10066 gids={50066, 9997, 3003} abi=x86

            I/CordovaLog( 3318): Changing log level to DEBUG(3)

            D/CordovaActivity( 3318): CordovaActivity.init()

            I/WebViewFactory( 3318): Loading com.android.webview version 37 (1630668-x86) (code 100007)

            I/LibraryLoader( 3318): Loading: webviewchromium

            I/LibraryLoader( 3318): Time to load native libraries: 6 ms (timestamps 3715-3721)

            I/LibraryLoader( 3318): Expected native library version number “”,actual native library version number “”

            V/WebViewChromiumFactoryProvider( 3318): Binding Chromium to main looper Looper (main, tid 1) {1d7fcc8}

            I/LibraryLoader( 3318): Expected native library version number “”,actual native library version number “”

            I/chromium( 3318): [INFO:library_loader_hooks.cc(106)] Chromium logging enabled: level = 0, default verbosity = 0

            I/BrowserStartupController( 3318): Initializing chromium process, renderers=0

            W/art ( 3318): Attempt to remove local handle scope entry from IRT, ignoring

            W/chromium( 3318): [WARNING:resource_bundle.cc(315)] locale_file_path.empty()

            I/chromium( 3318): [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=31 off=46092 len=2953

            I/chromium( 3318): [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.pak from, fd:32 off:228796 len:643667

            W/AudioManagerAndroid( 3318): Requires BLUETOOTH permission

            D/ ( 3318): HostConnection::get() New Host Connection established 0xa64e3480, tid 3318

            W/chromium( 3318): [WARNING:mailbox_synchronizer.cc(36)] MailboxSync not supported due to missing EGL image/fence support

            W/chromium( 3318): [WARNING:data_reduction_proxy_settings.cc(403)] SPDY proxy OFF at startup

            W/chromium( 3318): [WARNING:proxy_service.cc(901)] PAC support disabled because there is no system implementation

            W/art ( 3318): Attempt to remove local handle scope entry from IRT, ignoring

            W/AwContents( 3318): onDetachedFromWindow called when already detached. Ignoring

            D/CordovaActivity( 3318): CordovaActivity.createViews()

            D/PluginManager( 3318): init()

            D/CordovaWebView( 3318): CordovaWebView is running on device made by: unknown

            W/art ( 3318): Attempt to remove local handle scope entry from IRT, ignoring

            W/art ( 3318): Attempt to remove local handle scope entry from IRT, ignoring

            D/CordovaWebView( 3318): >>> loadUrl(file:///android_asset/www/index.html)

            D/CordovaWebView( 3318): >>> loadUrlNow()

            D/CordovaActivity( 3318): Resuming the App

            D/OpenGLRenderer( 3318): Render dirty regions requested: true

            D/Atlas ( 3318): Validating map…

            I/art ( 3318): Background partial concurrent mark sweep GC freed 1273(109KB) AllocSpace objects, 0(0B) LOS objects, 44% free, 1254KB/2MB, paused 1.418ms total 221.279ms

            D/SoftKeyboardDetect( 3318): Ignore this event

            I/OpenGLRenderer( 3318): Initialized EGL, version 1.4

            D/ ( 3318): HostConnection::get() New Host Connection established 0xa4322b10, tid 3358

            D/OpenGLRenderer( 3318): Enabling debug mode 0

            W/EGL_emulation( 3318): eglSurfaceAttrib not implemented

            W/OpenGLRenderer( 3318): Failed to set EGL_SWAP_BEHAVIOR on surface 0xa4342b00, error=EGL_SUCCESS

            D/SoftKeyboardDetect( 3318): Ignore this event

            I/ActivityManager( 1220): Displayed br.com.petlove.petlove/.MainActivity: +774ms

            D/SoftKeyboardDetect( 3318): Ignore this event

            D/CordovaWebViewClient( 3318): onPageStarted(file:///android_asset/www/index.html)

            D/CordovaActivity( 3318): onMessage(onPageStarted,file:///android_asset/www/index.html)

            E/AndroidProtocolHandler( 3318): Unable to open asset URL: file:///android_asset/www/css/style.css

            D/JsMessageQueue( 3318): Set native->JS mode to OnlineEventsBridgeMode

            D/CordovaLog( 3318): file:///android_asset/www/lib/openfb.js: Line 38 : file:///android_asset/oauthcallback.html

            I/chromium( 3318): [INFO:CONSOLE(38)] “file:///android_asset/oauthcallback.html”, source: file:///android_asset/www/lib/openfb.js (38)

            D/CordovaLog( 3318): file:///android_asset/www/lib/openfb.js: Line 39 : file:///android_asset/logoutcallback.html

            I/chromium( 3318): [INFO:CONSOLE(39)] “file:///android_asset/logoutcallback.html”, source: file:///android_asset/www/lib/openfb.js (39)

            D/CordovaWebViewClient( 3318): onPageFinished(file:///android_asset/www/index.html#/login)

            D/CordovaActivity( 3318): onMessage(onPageFinished,file:///android_asset/www/index.html#/login)

            D/CordovaActivity( 3318): onMessage(spinner,stop)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/chromium( 3318): [ERROR:buffer_manager.cc(313)] [.Parent-Compositor-0xa3292f90]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            I/App ( 3318): WARNING: Back Button Default Behavior will be overridden. The backbutton event will be fired!

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            D/CordovaLog( 3318): file:///android_asset/www/js/app.js: Line 31 : Uncaught TypeError: Cannot read property ‘Keyboard’ of undefined

            I/chromium( 3318): [INFO:CONSOLE(31)] “Uncaught TypeError: Cannot read property ‘Keyboard’ of undefined”, source: file:///android_asset/www/js/app.js (31)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            D/TaskPersister( 1220): removeObsoleteFile: deleting file=53_task.xml

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000b44

            E/eglCodecCommon( 3318): glUtilsParamSize: unknow param 0x00000bd0

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            E/eglCodecCommon( 3318): **** ERROR unknown type 0x0 (glSizeof,72)

            D/CordovaActivity( 3318): onMessage(spinner,stop)

          • There are no errors in your log that relates to Google Analytics. It looks like you might be having problems elsewhere in your code.

          • Gustavo Gervásio

            yes but when put the analytics at my controller a receiver the error if(typeof analytics !== undefined) {

            the logcat, i can find this “Google Analytics Unavailable”, source: file:///android_asset/www/js/controllers.js (12)

            if(typeof analytics !== “undefined”) {

            I/chromium( 2642): [INFO:CONSOLE(17696)] “ReferenceError: analytics is not defined

          • Please put your full project on GitHub and I’ll take a look.

            Regards,

          • Gustavo Gervásio

            link to my repo: https://github.com/gustavogervasio/myApp.git

            Thanks for your help

          • Gustavo Gervásio

            I receiver a new error

            I/chromium( 4778): [INFO:CONSOLE(24)] “starting analytics”, source: file:///android_asset/www/js/app.js (24)

            W/CordovaPlugin( 4778): Attempted to send a second callback for ID: UniversalAnalytics1669909072

            W/CordovaPlugin( 4778): Result was: “Invalid action”

          • Gustavo Gervásio

            I could make it work when I put the analytics.trackView ( ‘ Screen TITLE2 ‘ ) in app.run but when I put in controlers does not work.

          • Only thing I can think of is wrap the call in your controller in an $ionicPlatform.ready like found in your module.run.

            Regards,

  • Harris Boedijono

    Excuse me, I’ve been following the tutorial n got the same ‘Google Analytics Unavailable’. I use IonicFramework to build an android app and using my browser to check up. Here is my code :

    • This plugin uses native code so it will not work in a browser. This is why you’re getting an unavailable error because ‘analytics’ will never be defined in a browser.

      Regards,

    • Harris Boedijono

      @nicraboy:disqus At last it works, thx Nic. The plugin works after I remove the ‘if analytics undifined’ part in the controller. If I don’t remove it, my app failed to load the page which uses the ‘homeController’. I still don’t get what’s wrong, my logcat doens’t show any error about it.

      • That is weird. Careful about removing it though because you might get a bunch of exceptions somewhere in your coding adventures.

      • Harris Boedijono

        @Nic Raboy I still dont understand this in full. If i say trackview (‘update_controller’), will analytics track any activity in any screen involving ‘update_controller’ ?

        • If you have it at the root of your controller, information will be sent to Google stating you are on such and such view (controller). If you have multiple views per controller, you may want to place that call where appropriate.

        • Harris Boedijono

          @nicraboy:disqus So I only need to put it inside the controller i wish to track, and then analytics will do the tracking. Is it okay if I ask you again when I stumble into something else ?

          • Feel free to ask questions relevant to a particular article in the comments section of that article. If I’ve not made a post for your question, please ask me on Twitter.

            Regards,

      • Harris Boedijono

        @nicraboy:disqus

  • Hieu Tran AGI .

    I’m following the tutorial, when I use Android studio to rebuild the project which I am using Ionic Framework, I meet an error:
    Error:(109, 75) java: cannot access android.app.Activity
    class file for android.app.Activity not found
    Thanks in advance!

    • I could be wrong, but I don’t think you can use Android Studio when making hybrid mobile applications. If you can, I don’t have any experience with it. Sorry,

      • Hieu Tran AGI .

        Thanks Nic so much,
        I’m investigating to figure out the issue. 😀

    • Hieu Tran AGI .

      I found the root cause of the issue.
      Right click on the project -> Open Module Setting. On Project Struct window, select Libraries selection then delete all dupplicated libraries.
      Thanks!

      • Thanks for sharing. I don’t use Android Studio, so I wouldn’t know.

  • Carlos Pravia Jácamo

    Hello, I setup the plugin and had to struggle with the configuration, mainly because it didn´t initialise as expected, but finally we are receiving data on the real time report on GA. Now I have a strange situation: the app is in alpha stage at this point and is publish on the Google Play Store, we are publishing from Costa Rica and have three phones from we are downloading the app, but the audience report shows a lot more traffic from other countries including Rusia and Canada. We create a new GA Account and new Property for the app, but still getting data from other countries. ¿some ideas?

    • I really have no idea. It sounds like a Google Analytics configuration issue if it is reporting inaccurate data.

      You might consult the Google Analytics forums or Google Groups.

      Regards,

      • Carlos Pravia Jácamo

        I realice those data came from the traffic spammers. I just create a new GA Profile including only costarican traffic. That would work for now.

        Thanks !

  • technotip

    I spent 3hrs trying to figure out ..but not able to find the solution.

    AM getting the following error: (This error shown in my Chrome Console Window)

    app.js:47 Uncaught ReferenceError: analytics is not defined(anonymous function) @ app.js:47(anonymous function) @ ionic.bundle.js:44806onPlatformReady @ ionic.bundle.js:2445onWindowLoad @ ionic.bundle.js:2426

    ionic.bundle.js:20306 ReferenceError: analytics is not defined

    • I see an IP here. Can you confirm that you are NOT using Ionic View, Ionic Serve, or Ionic Live-Reload?

      Since the plugin uses native code it has to be compiled and installed to the device just as if it were a native app.

      Regards,

      • technotip

        am using ‘ionic serve’ to run the app ..

        • Hugh Hou

          window.analytics does not work…the startTrackerWithId will be undefined…

      • technotip

        Actually the error message seems so valid ..where is analytics defined?
        We haven’t injected it to the controller, then how can we use it?

        We are no passing it as a dependency, then how can we use it in app,js ?

      • Hugh Hou

        So using your code, I can not do Ionic Serve to test the app? So if I develop my app locally and need to using Ionic serve. Everything I serve the app in browser, my app will break b/c of analytics undefined? So do you mean in the finial development stage, I will add the analytics code one by one on each controler (I want to track all the controllers, that is like 50 o them)?! And each time I back to local development, I will need to delete or comment out the analystics (50+ location?) That does not sound right …

        • Here is how I see it:

          When you’re developing native Android or iOS applications there is no serve-like command. You would typically build and install every time you wanted to test. Why should it be any different with hybrid applications?
          Ionic Serve, Ionic View, and Ionic Live-Reload are all beta. I’m sure one day they will be sufficient, but as of right now they are more trouble than they are worth when it comes to plugins.

          https://www.thepolyglotdeveloper.com/2015/02/properly-testing-ionic-framework-mobile-application/

          Sure you could go with the approach of adding plugin-based code at the end of your development lifecycle, but honestly I would just take the extra 10 seconds to build and install to a device. You’ll end up making a much better application that way since it will be tested realistically.

          Regards,

          • Hugh Hou

            Thanks for the advices. You can tell I know nothing about native development. I am just a web developer. And we love live reload, see change as the code update and refresh to see error and fix it. That is just how I develop. Does native development has “console log” code and refresh and output error when I save the js file? I feel like I am missing a lot of Ionic development and testing tips.

          • Hugh Hou

            Mmm…I received the same error on the actual iOs device: Can’t find variable: analytics

            File file:///private/var/mobile/Containers/Bundle/Application/F8EFBC9F-CF44-4929-A8E2-EB3C8F81EBDE/CreatorUp.app/www/app/home/courses-ctrl.js at line 10, col 49 in CoursesCtrl@

          • Post your full project source code to GitHub and I’ll take a look.

  • jome

    while adding platform i have an error

    Installing “cordova-plugin-google-analytics” for android

    Fetching plugin “[email protected]” via plugin registry

    npm http GET https://registry.npmjs.org/com.google.playservices/19.0.0

    npm http 404 https://registry.npmjs.org/com.google.playservices/19.0.0

    Failed to install ‘cordova-plugin-google-analytics’:Error: version not found: 19.0.0 : com.google.playservices/19.0.0

    Error: version not found: 19.0.0 : com.google.playservices/19.0.0

    im tried to install

    cordova plugin add [email protected]

    but i have same error please suggest me a soloution

    • Sounds like you might not have the correct Android API versions installed. Open the Android utility as described in the official Android documentation and make sure you install API 19 and the appropriate build tools.

      If that doesn’t work, you may want to raise a ticket for the plugin developer.

      Regards,

  • Harry Webb

    Hi Nic – have you heard of any issues with tracking paid installs (adwords) using this or any other GA plugin? We’re struggling with this issue for iOS at the moment

    • What do you mean paid installs? Like if someone does an in app purchase in your application?

      Regards,

      • Harry Webb

        We are running app install campaigns on Adwords to get people to download the app. We have new users showing up in google analytics along with screen views and events, but no campaign, source, keyword data coming through. Adwords and GA are linked but there is something missing

        • I think these metrics are things you track via your Google Play and iTunes Connect dashboard. This plugin (and all I think) will only track events from within the application. Whether it be who opens it, what screens they click, whether or not they choose to buy an IAP.

          I’m not a Google Analytics power user, so I only track the basics in my personal stuff. You might want to ask in a Google Products forum board this kind of stuff.

          Regards,

  • Alex Sadri

    Hi. Thanks for your nice explanation. Actually when building my app i get several “preDex” errors. It seems a library is referenced multiple times. Removing android-support-v13.jar from my libs folder makes it work, but i wonder if anyone else stumbled upon this problem. It SEEMS that everything is working as expected (not just this plugin) but im not really sure.

    • Please bring that up with the plugin developer. Sounds like a bug in the plugin.

      Regards,

  • Mike Jouwstra

    I’m unable to add the plugin.

    I get an error — “Arguments to path.resolve must be strings at Object.exports.resolve (path.js:116:15)

    I’m using cordova 4.3.1.. and I’ve tried many other cordova versions from 3.0 to 5.2

    https://dl.dropboxusercontent.com/u/39552300/plugin-error.jpg

    Thanks!
    Mike

    • You may want to contact the plugin developer to see if support is available for the latest versions of Android and Apache Cordova. It has been over a year since I wrote this tutorial so I’m assuming the plugin may have changed or needs to change.

      Regards,

  • Hi Nic,

    As I mentioned on Twitter, I am having trouble with this plugin. I followed your article and put this code in my app.js

    angular.module(‘name’, [”])

    .run([‘$ionicPlatform’, ‘$cordovaSplashscreen’, function($ionicPlatform, $cordovaSplashscreen) {

    }])

    What I find is that none of my console logs gets printed. I tried putting in the real tracking ID, didn’t help. If I remove the condition and leave bare code, I get the feared white screen of death in Ionic. No errors, nothing.

    I think that it is only expected then that I get an undefined error in my controller:

    if(typeof analytics !== undefined) { analytics.trackView(“Awesome Controller”); } else {
    console.log(“Analytics unavailable.”);
    }

    $scope.initEvent = function() {
    if(typeof analytics !== undefined) { analytics.trackEvent(“Category”, “Action”, “Label”, 25); }
    }

    Any idea what might be wrong? I was trying also $cordovaGoogleAnalytics but no luck either. Thanks a lot!

    • I guarantee that if you have a white screen, you’re getting something in your logs. Are you using ADB to find your logs? Can you give me the command you’re using and paste anything that might appear? Maybe it is slipping past you and I can find it.

      Also note that analytics keys take a day or two before they start showing data. Are you sure you waited long enough?

      Best,

      • I managed to fix it Nic! Didn’t want to bother you with it .. however, I have been seriously struggling with Ionic title overlapping my menu icon AND my view not being shown on certain view switches. Can I ask you for help?

        • I’m glad you got it working!

          In regards to your other question. I like to keep comments on topic to the article so other readers don’t have to dig through a ton of unrelated things. I encourage you to post your question in the forums.

          Regards,

  • Tony Romanov

    Hi Thank you for the post.

    I am not able to get any activity on the analytics page.

    When I look at the android console output I see this:

    09-17 23:06:05.214 1834-1895/? W/GAv4﹕ AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.
    09-17 23:06:05.240 1834-1895/? W/PluginManager﹕ THREAD WARNING: exec() call to UniversalAnalytics.startTrackerWithId blocked the main thread for 41ms. Plugin should use CordovaInterface.getThreadPool().
    09-17 23:06:05.246 1834-1897/? W/GAv4﹕ AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.

    Any ideas?

  • EDWIN COBOS

    Hi,
    To use this plugin, I want to know what option I should choose into the Admin Google Analytics, at the moment of the account creation for track the app.
    There is two options: Website or Mobile App.

    Regards!

    • Because the plugin uses native Google Analytics libraries you want to choose Mobile App.

      Best,

  • Nurhadi

    hi Nic,,
    i try implement this article and everything works fine, the view is tracked in GA, but my device is not reported in the Real Time GA. when i see in the log, no error or warning came up.. am i doing something wrong?

    • You might post this in a Google Group. If the GA key is tracking anything it means the app is working correctly. If the Google Analytics dashboard isn’t reporting real time it sounds like a Google problem

      Sorry,

  • Sarah

    Hi Nic, great tutorial, though I am having a slight problem:

    Here is my app.js:

    var TestingApp= angular.module(‘starter’, [‘ionic’,’ngSanitize’])

    .run(function($ionicPlatform) {

    $ionicPlatform.ready(function() {

    if(window.cordova && window.cordova.plugins.Keyboard) {

    }

    if(window.StatusBar) {

    }

    if(typeof analytics !== undefined) {

    } else {

    }

    });

    })

    and this is the error i am getting:

    ReferenceError: ReferenceError: analytics is not defined
    at new (app.js:141)
    at Object.invoke (ionic.bundle.js:17762)
    at extend.instance (ionic.bundle.js:22311)
    at nodeLinkFn (ionic.bundle.js:21421)
    at compositeLinkFn (ionic.bundle.js:20853)
    at publicLinkFn (ionic.bundle.js:20728)
    at ionic.bundle.js:14947
    at Scope.$eval (ionic.bundle.js:29158)
    at Scope.$apply (ionic.bundle.js:29257)
    at bootstrapApply (ionic.bundle.js:14945)(anonymous function) @ ionic.bundle.js:25642(anonymous function) @ ionic.bundle.js:22421Scope.$apply @ ionic.bundle.js:29259bootstrapApply @ ionic.bundle.js:14945invoke @ ionic.bundle.js:17762doBootstrap @ ionic.bundle.js:14943bootstrap @ ionic.bundle.js:14963angularInit @ ionic.bundle.js:14857(anonymous function) @ ionic.bundle.js:41671trigger @ ionic.bundle.js:16308eventHandler @ ionic.bundle.js:16583
    app.js:24 Uncaught ReferenceError: analytics is not defined

    thanks =)

  • Sarah

    Hi Nic, great tutorial:

    think there is slight syntax error when you try to serve the app in a web browser:

    http://stackoverflow.com/questions/29664948/does-anybody-know-what-does-uncaught-referenceerror-analytics-is-not-defined

    solves the problem!

    Thanks =)

    • I am going to give you the best advice you’ll ever receive when it comes to mobile application development. If you listen to it, your development career will excel.

      Do not test your mobile apps in a web browser. Do not use services such as ionic serve, ionic view, or phonegap build. Compile your application locally and install it to a device or simulator. You’re developing mobile apps, not web apps. Test them as such.

      Best,

      • Áron Barócsi

        This is a good thought but cynical. There are many functional cases where firing up an emulator is a waste of time.
        I hope it will not affect my career though.

        • Wrote this the other day:

          https://www.thepolyglotdeveloper.com/2016/02/why-you-should-not-use-ionic-serve-for-hybrid-apps/

          People are telling me I’m an idiot, but you may find it valuable.

          Best,

          • Áron Barócsi

            Would never do that, your contribution to the community is totally remarkable. Just having said that until a tipping point, app logic is platform agnostic, and must be so. This is why we are x-platforming to reduce common waste. However yes, when its time to tailor things mocking is far from enough. Lately I have ran into many things that required deep inspection of device and os specific quirks that falls out of the browser range.

  • Sung Kim

    Nice tutorial! BTW, I’m getting THREAD WARNING: [‘UniversalAnalytics’] took ‘16.254150’ ms. Plugin should use a background thread from ios. Do you know how to solve? Should I put the analytics.startTrackerWithId(“UA-XXXXXXXX-XX”); in setTimeout or something?

    • Sometimes Apache Cordova plugins throw those warnings. Nothing you can do from a JavaScript side. However they are just warnings, not errors. If it truly bothers you, you should contact the plugin developer.

      • Sung Kim

        Thanks! When I put that part in the setTimer, the warning is gone. I am not sure this really addresses the issue, though.

        • You probably want to reach out to the plugin developer then. Native code will have to be altered.

  • Mod Term

    Hi Nic. Thank’s for this tutorial. I have 1 problem
    Analytics in device.ready is work’s, but when i run analytics include in controller i get error analytics is not defined.
    Help me please . . .

    • Mod Term

      Solved.
      Work’s for me this code

      function _waitForAnalytics(){

      };

      _waitForAnalytics();

      • Axel Ingadi

        Thank you Mod Term!! This fixed the problem for me too.

      • Dileep Kumar

        Wow… after breaking head for some time… Got it fixed with your snippet…Cheers….

  • oaklandj

    Hi Nic, Thank you so much for this very helpful writeup. Do you know how unique visitors (or, a bit less helpful but better than nothing: unique sessions) are tracked using this plugin? Is it done automatically when startTrackerWithId is fired?

  • Alex Fine

    I’m getting an error “Can’t find variable: analytics,” which makes sense because nowhere is analytics defined, what files (if any) in the plugin do I need to link to in the index.html?

    • How are you testing? Analytics is a global variable as part of window that becomes available when you install the plugin.

      • Alex Fine

        I tried running ionic serve and ionic build iOS, didn’t work on either. I’m pretty sure I installed the plugin correctly (I installed it the same way I’ve been installing other plugins that work fine and it’s in the same folder as them). Not sure what’s going on.

        • Try to reinstall the plugin. Somethings they get corrupted for some strange reason.

        • Matt Gaudion

          Have you ngCordova, i had trouble with the before and after including this in my Ionic App the plugins were pulled in automaticaly and the variable was available for me to use.

          Hope this works for you 🙂

  • roseliux

    i am trying to view users id with a the addDimension,

    my call is like this :
    $cordovaGoogleAnalytics.addCustomDimension(‘dimension1’, ‘user_’ + userId);
    $cordovaGoogleAnalytics.trackView(view);

    and already created the custom dimension in GA configuration panel.
    Im using ionic 1 and testing the app on an android phone, the info for views is in GA but the dimension is not.

    • I didn’t use ngCordova anywhere in my example. You probably want to post in the Ionic Framework forums or their GitHub issue tracker if you want help with ngCordova.

      If you want to use the vanilla Apache Cordova plugin like I do in my tutorial, the official documentation says you can track custom dimensions like this:

      window.analytics.addCustomDimension(‘Key’, ‘Value’, success, error)

      Best,

  • Fasil

    Hi Nic,

    Thank you for this article. I tried this and it is working for android. When I tried on ios, this is not working because (typeof analytics !== undefined) always fails. Not sure if I am missing anything here, but, I am assuming that it should work fine because on android it is good. Do you have any suggestions?

    Fasil

    • Are you using any of the following?:

      ionic serve
      ionic view
      ionic live reload
      PhoneGap build

      If yes, stop using them. Native plugins don’t work correctly with those services. If you’re not using them, what do your iOS logs say?

      • Fasil

        Hi Nic, I am not using any of those. I made iOS build by using ‘sudo ionic build ios’, opened project using xcode, and ran. There is nothing informative on xcode logs.
        Thank.

        • Try to uninstall the plugin and reinstall it. Sometimes it gets corrupted for particular platforms. Some kind of Cordova problem.

          For what you describe, you are doing everything right.

          • Fasil

            Great!! That worked. I removed and added the plugin again. Thank you so much for the help Nic.

          • Awesome!

            Yea I don’t know why that happens, but it is super annoying. I often don’t remember to think of that as being a reason why a plugin doesn’t work.

            Best,

  • Olajide Awoyinka

    i tried using it as instructed in the video but it bring up some error that analytics is undefined , i tested it on a real device and using ionic serve.. when i run on a real device it remains blank and doesnt display anything same as ionic serve

  • Dane

    Yo Nic – helpful article and examples. Thank you.
    One thing (and I think this gets at Olajide’s comment below) – the reference to [window.]analytics is deprecated per the github’s repo. It’s been replaced by [window.]ga

  • Tester Medma Tester Medma

    Hey Nic , how can i use firebase analytics in ionic framework .

  • Shouldn’t be better add the GA code into beforeEnter function? Or there is no need for that?