Question

Good evening, I am currently developing an application for android using phonegap and sencha touch 1.1. I am having trouble with the GoogleAnalyticsTracker plugin for Android. I followed all the instructions on github on how to import the necessery code for the plugin to work but I am having trouble with initialization.

In my plugins.xml I have added the following line: < plugin name="Analytics" value="com.phonegap.plugins.analytics.GoogleAnalyticsTracker" />

As indicated in the readme.md file in github. I also added the GoogleAnalyticsTracker.java file inside com/phonegap/plugins/analytics and referenced the js file in my html... every thing seems to work fine except the part where I call the start method with my account id... The method returns the failure callback with error 'Class not found'. any ideas why phonegap cannot find the class specified in the xml?

if you need more info on this please do not hesitate to ask.

Thank you in advance!

PS. i am using phonegap 1.4.1

-L_Sonic

Was it helpful?

Solution

I took a look at the src and I see that the PhoneGap.exec calls in analytics.js does not match the plugin name. You have two ways to fix this.

  1. In plugins.xml make the plugin line:

    <plugin name="GoogleAnalyticsTracker" value="com.phonegap.plugins.analytics.GoogleAnalyticsTracker"/>

  2. Or in analytics.js replace all instances of 'GoogleAnalyticsTracker' with 'Analytics'

This is a bug in the way the code is setup in github. You should message the author to get them to fix it.

OTHER TIPS

Rather than using the PhoneGap plugin, I would recommend using the Google Analytics SDK for tracking usage of application developed using PhoneGap or any web based mobile app.

Ensure that you respect your users privacy and dont send any other data to Google Analytics. Besides you should also adhere to Google Analytics privacy policy. Heres how to do it.

http://www.the4thdimension.net/2011/11/using-google-analytics-with-html5-or.html

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