cmackay / google-analytics-plugin

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

Hits not registering for iOS app emulation #6

Closed avicks closed 10 years ago

avicks commented 10 years ago

Hello again,

Code compiles with the GA Plugin and app executes just fine via XCode 5.1.1. However, hits do not register.

After some research other people have run into similar issues, but the solutions all seem to be based around altering code in .m files as these other programmers are not using Cordova. When trying to replicate any fixes other coders have come into my situation is not similar enough to make the same changes.

Below are two relevant output messages regarding the issue.

INFO: GoogleAnalytics 3.07 -GAIReachabilityChecker reachabilityFlagsChanged:: Reachability flags update: 0X000002

INFO: GoogleAnalytics 3.07 -GAIBatchingDispatcher hitsForDispatch: No pending hits.

This occurs when attempting both methods of registering a hit in the readme.

cmackay commented 10 years ago

How about you test in a clean project to confirm that something else isn't causing an issue.

cordova create analytics-test cd analytics-test cordova platform add ios cordova plugin add https://github.com/cmackay/google-analytics-plugin.git

In the default cordova code after the device ready event occurs, add your tracking id and submit some analytics events. Give that a try and let me know if that works?

avicks commented 10 years ago

Will do, I will get back to you with the results. Thank you for the fast response.

cmackay commented 10 years ago

Also when I test out the plugin, I run the above steps of creating a clean cordova project and then I edit the default index.js so it has the below:

        ...
        if (id === 'deviceready') {
            var analytics = navigator.analytics;

            function onSuccess() {
                alert('success');
            }

            function onError(err) {
                alert('error' + err);
                console.log(err);
            }
            analytics.setTrackingId('UA-XXXXXX-X');

            analytics.sendAppView('home', onSuccess, onError);

        }
        ...

Replace the default if (id === 'deviceready') statement with the above and you should see events logged in google analytics. Let me know how it works out.