cmackay / google-analytics-plugin

Cordova Google Analytics Plugin for Android & iOS
Apache License 2.0
89 stars 43 forks source link

iOS: no data tracked #29

Closed dariospadoni closed 9 years ago

dariospadoni commented 9 years ago

Hello I can't see any data shown on my GA account. I enabled verbose log, put some breakpoint in the code and apparently everything is working...This is some output from my app:

Startup:

VERBOSE: GoogleAnalytics 3.10 -GAIBatchingDispatcher persist:: Saved hit: { parameters = { "&_crc" = 0; "&_u" = ".tenL"; "&_v" = "mi3.1.0"; "&a" = 281070345; "&aid" = "it.witbit.pushTest"; "&an" = witGym; "&av" = "0.0.2"; "&cd" = home; "&cid" = "dbcb6be5-8bb8-406f-a2a8-b1319340a37c"; "&ds" = app; "&sr" = 320x568; "&t" = appview; "&tid" = "UA-57581752-4"; "&ul" = it; "&v" = 1; "&z" = 9008754903745920601; gaiVersion = "3.10"; }; timestamp = "2014-12-13 16:42:30 +0000"; }

and later:

VERBOSE: GoogleAnalytics 3.10 -GAIRequestBuilder requestPostUrl:payload:compression:: building URLRequest for https://ssl.google-analytics.com/batch

VERBOSE: GoogleAnalytics 3.10 -GAIBatchingDispatcher dispatchWithCompletionHandler:: Sending hit(s) POST: https://ssl.google-analytics.com/batch

INFO: GoogleAnalytics 3.10 -GAIBatchingDispatcher didSendHits:response:data:error:: Hit(s) dispatched: HTTP status 200

INFO: GoogleAnalytics 3.10 -GAIBatchingDispatcher deleteHits:: hit(s) Successfully deleted

INFO: GoogleAnalytics 3.10 -GAIBatchingDispatcher didSendHits:: 2 hit(s) sent

No data is shown in realtime and (after 5-6 hrs) still no data in the GA statistics...any hint?

cmackay commented 9 years ago

I have seen some stackoveflow issues relating to ios analytics not showing up due to the analytics acct not being set as a mobile profile. Let me know if this is the issue you are having.

http://stackoverflow.com/questions/18829584/google-analytics-in-ios-not-working

Thanks,

-Craig

dariospadoni commented 9 years ago

I have accounts and properties well configured on Google but no real time data shown. I can see yesterday statistics now but no real time data...

jensljungblad commented 9 years ago

Might be the same issue: https://github.com/cmackay/google-analytics-plugin/issues/26

Not seeing any real time data, though other data show up after a while, 10 minutes or so.

dariospadoni commented 9 years ago

Same issue for me...I just ran the simple example code of issue #26 no errors but no real time data. I also tried with different GA accounts but nothing to do...

cmackay commented 9 years ago

Is it only iOS? does it work in the Android emulator?

dariospadoni commented 9 years ago

I tested on an iPhone with iOS 7.1. Don't know about Android.

I just checked on GA, data are collected and shown in the statistics; the problem is only for real time events.

cmackay commented 9 years ago

Hmm. I have not been able to reproduce this using the iOS emulator or on the Android emulator. I don't have an iOS device to test it with. Some possible ideas for troubleshooting this are to determine when exactly the problem occurs. Does it occur only on the actual device or does it ever happen when using the emulator also? Just iOS or when on Android also? Also what versions of cordova/iOS/etc are being used. If you create a new cordova app that does that work on all of the above? I would recommend checking the native sdk support forums if others are also having the same issue. Mobile apps are inherently difficult to troubleshoot obviously because of all the variations of devices, platforms and libraries. I know you mentioned you haven't tried on Android but that would be useful in helping to determine this issue. If anyone has multiple devices and is willing to try and reproduce this it would be greatly appreciate. This library provides a pretty thin wrapper around the native sdks so I would think since this issue is not easily reproducible it must be something within the native SDK or possibly specific platform versions.

The following forum may provide some help on this issue: https://groups.google.com/forum/?fromgroups#!forum/ga-mobile-app-analytics

If there is anything I can do to help in troubleshooting, please let me know. Since I have not been able to reproduce this it is difficult for me to determine what the issue is. Let me know if I can do anything to help or if you find any additional information.

Thanks,

-Craig

cmackay commented 9 years ago

Also, I have seen some stack overflow posts and google groups posts that mention that a trackViewName param must be set. I have not verified this but that may be worth looking into. Let me know if that helps.

https://groups.google.com/forum/?fromgroups#!searchin/ga-mobile-app-analytics/ios$20real$20time/ga-mobile-app-analytics/eRxDARcCkLA/UMvPRWR74IkJ

jensljungblad commented 9 years ago

Have tested now with Cordova 4 and the 0.1.10 version of this plugin, on the iOS emulator running Yosemite and the latest XCode, and an Android device (Sony Xperia Z1 Compact) with the same result. Normal data show up, but no real time data.

How can I set the trackViewName?

cmackay commented 9 years ago

I would try calling the following first to see if that show up under realtime.

analytics.sendAppView('home', successCallback, errorCallback);

cmackay commented 9 years ago

Also if you are primarily sending events, there is a send event with params and you may be able to pass the following in the params to avoid the additional call. I don't know that this will solve the issue but may be worth a try.

{ analytics.Fields.SCREEN_NAME: 'home'}

I would recommend probably calling sendAppView first though just to see if that resolves the problem,

jensljungblad commented 9 years ago

Yes, that's what your script does right? I'm still running the code you posted in #26

document.addEventListener('deviceready', function () {

  var analytics = navigator.analytics;

  if (!analytics) {
    throw new Error('analytics object not defined');
  }

  analytics.setTrackingId('UA-XXXXXX-X');

  analytics.sendAppView('home', function () {
    alert('app view sent!');
  }, function (err) {
    alert('app view sending failed' + err);
  });

}, false);

It still says 'app view sent', but nothing shows up under real time.

cmackay commented 9 years ago

yep thats what that script does. When I run it I see the real time hits show up usually within 30 seconds

cmackay commented 9 years ago

Not sure if this will make a difference but I just set the dispatch interval from 10 seconds to 1 second for iOS in master. If you want to give that a try add the plugin using to get the latest master:

cordova plugin add https://github.com/cmackay/google-analytics-plugin.git

cmackay commented 9 years ago

Also I see a lot of related topics in the analytics google group. Not sure if you have been through those already.

https://productforums.google.com/forum/#!searchin/analytics/Real$20time

dariospadoni commented 9 years ago

@cmackay changing the interval from 10 seconds to 1 did the work and I can see real time data (tested with iPhone iOS 7.1)

Thanks!

cmackay commented 9 years ago

Great! Let me know if you have any additional comments or questions.

Thanks,

-Craig

jensljungblad commented 9 years ago

@cmackay I saw no difference with the changed interval. However, I created a new property with the reporting time zone set to the US and now I see real time data. :+1: but weird.

I was wondering about the interval though, is it a good idea to keep it at 1? I doubt it has anything to do with whether real time reporting works or not. I noticed the default value is 120 seconds. Sending a request to Google every 1 second seems a bit excessive?

cmackay commented 9 years ago

Yeah, I think I will set the default higher and maybe expose a setDispatchInterval in the js api.

Thanks,

-Craig

jensljungblad commented 9 years ago

Sounds like a good idea

cmackay commented 9 years ago

@dariospadoni @jensljungblad

Just wanted to let you know I published a new release that supports a setDispatchInterval function. By default it will no longer set the dispatch interval on startup and instead use the analytics default dispatch interval.

jensljungblad commented 9 years ago

Nice, thanks!