Analytics not working on Android Build

Hi all,

I have attempted to set up Google Analytics on my Ionic 1 app.

I had no luck with danwilson’s cordova plugin so I am doing it directly.

Analytics tracks in the browser emulation, as well as on Ionic View on Android, no problem. But when I build the apk - none of the tracking registers.

I have left it for some time as I read somewhere that there is a 4hr delay for android apps, but after running it over a weekend still no luck.

Here is the code:

I include the analytics.js file from google.


ga('create', {
    // Disables cookies.
    storage: 'none',
    trackingId: 'UA-XXXXXXXX-1',
    // Will return null if not set, and GA will then assign one.
    clientId: localStorage.getItem('ga:clientId')
ga('set', 'checkProtocolTask', null);
ga('set', 'transportUrl', '');
ga(function(tracker) {
    if (!localStorage.getItem('ga:clientId')) {
        // Save the assigned id for the next time the app boots.
        localStorage.setItem('ga:clientId', tracker.get('clientId'));
ga('set', 'appName', 'Customer App');
ga('set', 'transport', 'beacon');        
ga('send', 'event', 'System', 'start');

The above code is from

As I have said above the tracking works in the browser and when using ionic view - it doesnt work on the android apk.

There is very little on the net about analytics for google - most of it is about the plugins not working on the android build.

Any ideas on what I can do here?

Thank you all in advance!