cmackay / google-analytics-plugin

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

No data in analytics although request are sent #23

Closed kentpachi closed 9 years ago

kentpachi commented 9 years ago

Hello,

I'm using you're plugin.

I followed your example and it works good.

Analytics is present and i send data via sendAppView and send.

The success callback says as response parameter "OK".

Everything looks good but there's no data in analytics. I've double checked this, and also checked Real time view which contains no data as well...

Any clue on this ?

I've created mobile application tracker in GA

Here's my code .

I have one for the first app run, and one is triggered on each location change ( angularJS )


               var successCallback = function (r)
                {
                 applicationService.notify('sucess ' + r);
                };

                var errorCallback = function (r)
                {
                    applicationService.notify('error ' + r);
                };

               var analytics = navigator.analytics;
                if (analytics !== undefined)
                {

                    alert('analytics ready');
                    // set the tracking id ( i checked this one, its the good one )
                    analytics.setTrackingId('UA-xxxx-xxx');

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

                    // or the same could be done using the send function

                    var Fields = analytics.Fields,
                            HitTypes = analytics.HitTypes,
                            LogLevel = analytics.LogLevel,
                            params = {};

                    params[Fields.HIT_TYPE] = HitTypes.APP_VIEW;
                    params[Fields.SCREEN_NAME] = $location.path();

                    analytics.setLogLevel(LogLevel.INFO);

                    analytics.send(params, successCallback, errorCallback);

                    $rootScope.$on('$routeChangeSuccess', function () {

                        // or the same could be done using the send function
                         analytics.sendAppView($location.path(), successCallback, errorCallback);

                        var Fields = analytics.Fields,
                                HitTypes = analytics.HitTypes,
                                LogLevel = analytics.LogLevel,
                                params = {};

                        params[Fields.HIT_TYPE] = HitTypes.APP_VIEW;
                        params[Fields.SCREEN_NAME] = $location.path();

                        analytics.setLogLevel(LogLevel.INFO);

                        analytics.send(params, successCallback, errorCallback);

                    });
                }
cmackay commented 9 years ago

Hi @kentpachi,

First I would recommend verifying you have the latest plugin.

cordova plugin remove com.cmackay.plugins.googleanalytics cordova plugin add com.cmackay.plugins.googleanalytics

Then, I would recommend adding the simplest snippet of analytics tracking code to your app and see if that works to try and isolate the problem.

Try adding the following block to your app:

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

  var analytics = navigator.analytics;

  analytics.setTrackingId('UA-XXXX-XX', function () {
    alert('tracking id set successfully');

    analytics.sendAppView('home', function () {
      alert('app view sent successfully');

    }, function (err) {
      alert('error sending app view: ' + err);

    });
  }, function (err) {
    alert('error setting tracking id: ' + err);

  });

}, false);

Then wait maybe a minute and see if any real time activity shows up in the analytics dashboard. Some things that may help in troubleshooting is to set the plugin log level to VERBOSE and the monitor the android log using 'adb logcat' while connected to the device.

Let me know what you find. Thanks!

-Craig

karli2000 commented 9 years ago

I had a similar problem and i fixed it by setting the time zone on google analytics (when you go to admin->view settings) to a US timezone (i am in europe). Afterwards the real time stuff was working (but be aware, it can be delayed for a few minutes). The normal stats are only showing up a few hours later. Maybe this helps.

Max

cmackay commented 9 years ago

Also please check that the account is setup as a mobile account. This seems to be an issue in some cases.

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