Question

I had been using PhoneGap 1.9 for a while and was successfully using the Google Analytics Plugin.

I recently upgraded to PG 2.0 (so that I could use the new Urban Airship plugin) and now my Google Analytics seems to have stopped functioning.

Unfortunately, I think it has something to do with the initialization of the plugin via JavaScript. After some frustration I got my app to finally compile. But, my app pretty much just stops responding after the Google Analytics plugin is initialized in my JavaScript.

I wish I could give you guys some error messages or something, but I am getting no compiler errors and I am getting no JavaScript errors. The app just does not respond when I use the following two lines:

g_objGoogleAnalytics = window.plugins.googleAnalyticsPlugin;
g_objGoogleAnalytics.startTrackerWithAccountID("UA-XXXXXXXX-X");

If I comment these two lines out, everything else in the app works like a charm.

Has anyone got the Google Analytics plugin working under PG 2.0? If so, any advice or steps would be greatly appreciated.

UPDATE: I added some error checking with try/catch and the console log now states "undefined is not an object" whenever I execute the above two lines of code.

Was it helpful?

Solution

I found the answer myself. kieranshaw on github changed the keyword "PhoneGap" to "codova" in the JS file and that seemed to mix the issue. You can see the changes here: https://github.com/kieranshaw/phonegap-plugins/commit/cc4424410869912ff278de0228a6c328b1296fbe

OTHER TIPS

Here's a way to implement GA on PG without plug-ins, though there are limitations as indicated in the solution: How to use Google Analytics with Phonegap without a plugin?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top