danwilson / google-analytics-plugin

Cordova (PhoneGap) Plugin to connect to the native Google's Universal Analytics SDK 3.0
MIT License
695 stars 500 forks source link

Not seeing analytics on Google Analytics #422

Open magickaito opened 7 years ago

magickaito commented 7 years ago

I am debugging an issue on an iOS Cordova app. This plugin (verison 1.8.2) is being used. There is no traffic reported on the Google Analytics dashboard.

This is the code:

window.analytics.startTrackerWithId('UA-XXXX');
window.analytics.trackView('Main');

So apparently, this is the old coding syntax? I tried to change to the new way:

window.ga.startTrackerWithId('UA-XXXX',30);
window.ga.trackView('Debugging Screen Title');

I need to see this working before submitting this fix. I keep looking at the Real Time dashboard on the Google Analytics dashboard. However, I am not seeing my testing screen title "Debugging Screen Title".

So it appears that the plugin is still not sending in analytics to Google? How should I debug this?

magickaito commented 7 years ago

Not sure is it relevant, but I see this warning in console log: THREAD WARNING: ['UniversalAnalytics'] took '21.554932' ms. Plugin should use a background thread.

magickaito commented 7 years ago

FYI, if I downgrade the plugin to 0.8.1 it will work again.

ghost commented 7 years ago

I am seeing the same issue. Works fine on iOS but not on Android. Any advice?

victorsosa commented 7 years ago

window.analytics.startTrackerWithId('UA-XXXX'); please check the code example, because this code should be run alone in the platform ready method, before anything else to init the plugin.

andreyliventsev commented 7 years ago

Same issue

syc-pad commented 7 years ago

Same here...

mhinman87 commented 7 years ago

I am having the same exact issue. If I launch my iOS cordova app, my real time google analytics will show me as an active user, so the plugin is working to some extent, but I have waited several days and my history shows 0 users and 0 page views.

Something is being sent but it is not quite working.

syc-pad commented 7 years ago

I'm wondering if the "in permanent progress" Google world, with Firebase replacing/integrating same features as GA, etc etc... wouldn't be the cause of the problem...

andreyliventsev commented 7 years ago

I think I know what has been wrong. This plugin works with Mobile App tracker type (see prerequisites of this plugin). So if you are using Web Application tracker/resource type then you can't track activities.

For using Web Application tracker for cordova apps use local storage to store trackingId

          window.ga('create', {
            storage: 'none'
            trackingId: GOOGLE_ANALYTICS_ID
            clientId: localStorage.getItem('ga:clientId')
          })

see https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id?hl=en

mhinman87 commented 7 years ago

@andreyliventsev I think you are right. I can get trackEvent() to work but I am still not having luck with trackView() and I think it has something to do with trying to track views vs pages (i.e. mobile vs web).

If I try to set up the mobile app tracker in firebase then the project does not have the UA-XXXX formatted project ID needed for this plugin.

mhinman87 commented 7 years ago

I cannot figure this out. I am using Ionic, I am using the latest everything,

    @ionic/cli-plugin-cordova       : 1.6.2
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

and I am using the latest version of the plugin

<plugin name="cordova-plugin-google-analytics" spec="^1.8.3" />

I am following directions exactly as it says on

https://ionicframework.com/docs/native/google-analytics/

and I still cannot get this to work properly. I suspect it has something to do with mobile vs web but I am not sure what to change.

If I run the app, look at real time data on the google analytics site, I can see myself as an active user, I can track events, but no data ever remains after it falls off of the real time tracking dashboard. I also cannot use trackView() at all. I am running my app on iOS using the ionic CLI.

Any thoughts or help would be greatly appreciated.

oudinia commented 7 years ago

Same issues as @mhinman87, on Android, trackEvent works but not trackView

Please help us understand or solve the issue.

Thanks.

oudinia commented 7 years ago

Finally found a temporary, effective solution

Getting back to this issue.

I used the javascript file directly in debug_mode and removed the plugin.

when sending a pageview (trackView equivalent), I got the following error:

"unallowed document protocol"

this led me to this link: https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks at the end of the document, it explains to set the checkprotocol task to null, which disables the checking. ga('set', 'checkProtocolTask', null); // Disables file protocol checking

I wonder how the plugin allows such control.

For now, I go through the JS directly, by encapsulating logic through an angular service.

timmyrosen commented 7 years ago

I have the same problem, I can track events but not pages/views. I have enabled debugmode and the output looks successful to me. Even the promise from the trackView method returns successfully, but no view appears in Google Analytics. I even tried downgrading to v1.7.11 but the issue remains.

Is this a problem with the plugin, the Ionic wrapper or with Google Analytics?

Ionic info:


cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.9.1
    ionic (Ionic CLI) : 3.9.1

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 25.2.5
    ios-deploy        : 1.9.1 
    ios-sim           : 5.0.8 
    Node              : v8.1.2
    npm               : 5.3.0 
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b
mhinman87 commented 7 years ago

I am still having trouble. Did anyone find a solution??

timmyrosen commented 7 years ago

@mhinman87 Yes, here is the solution: #466

pushpendra-jaypore commented 6 years ago

Hello Guys, google analytics not working in ionic 3 getting error TypeError: Cannot read property 'apply' of undefined please help if anybody have any idea on same

vromaniv commented 6 years ago

@pushpendra-jaypore +1. I have the same issue.