cmackay / google-analytics-plugin

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

No data reported even though success callback fires #26

Closed jensljungblad closed 9 years ago

jensljungblad commented 9 years ago

Using cordova 4.0, and the latest version of this plugin, I'm not seeing any data being reported. I've created an "app" property in Google Analytics and done the following:

navigator.analytics.setTrackingId('xxx')
navigator.analytics.sendAppView('foo', function() { 
  console.log('success');
}, function(e) {
  console.log('failure:' + e)
});

Running it in the browser I'm getting a "failure: Missing Command Error" which I assume is because there is no implementation for the browser platform. When I run it in the iOS emulator, I get the success message, which I assume means the event was sent, but no data is showing up in Google Analytics.

Is there more configuration that needs to be done somewhere?

cmackay commented 9 years ago

There is no additional configuration needed. It should be sending them. Since it has been a day since you posted this, are they events showing up yet? or still none? Some possible ways to troubleshoot this might be to enable verbose logging and look at the simulator logs to see what is going. I just did a quick test using cordova 4 and the latest plugin and I was see the hits showing in the real time view in under 30 seconds.

I have a script I run to verify hits are showing that does the following:

#!/bin/sh

rm -fr analytics-test
cordova create analytics-test
cd analytics-test
cordova platform add ios
cordova plugin add com.cmackay.plugins.googleanalytics
cat ../analytics-test.js >> www/js/index.js
cordova run ios
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);

Let me know what you find. Thanks,

-Craig

cmackay commented 9 years ago

If you can provide more information on this, please reopen the issue. Thanks!

jensljungblad commented 9 years ago

Hi, managed to test this some more. Seems data is tracked, but the real time view isn't working. The data shows up after a while in the normal views. I tested this using your example above. Do you have any idea as to why real time isn't working?

cmackay commented 9 years ago

It works for me. Maybe try setting up a different analytics account to test if it is an account setting or device/software related issue.