phonegap-build / GAPlugin

Google Analytics Plugin
MIT License
170 stars 141 forks source link

Add following Gotchas to the Readme.md #53

Open tomwoods opened 10 years ago

tomwoods commented 10 years ago

I installed the plugin from git, and I was not able to set up the plugin successfully without the following steps that are missing from the Readme.md file:

  1. Include the following in your index.html:
<script src="GAPlugin.js"></script>

Explanation: Without this step, you get a fatal error because the plugin javascript variables haven't been defined.

  1. Make sure you have the following permissions in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Explanation: Without ACCESS_NETWORK_STATE, the plugin assumes you are offline and never sends the requests to Google Analytics and eventually shuts down.

mchev2 commented 10 years ago

Thanks for the info. I added these permissions to plugin.xml of this plugin to make them persistent.

This is what I modified in plugin.xml

<platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
  <feature name="GAPlugin" >
    <param name="android-package" value="com.adobe.plugins.GAPlugin"/>
  </feature>
    </config-file>

    <config-file target="AndroidManifest.xml" parent="/manifest">
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    </config-file>

    <source-file src="src/android/GAPlugin.java"
            target-dir="src/com/adobe/plugins" />
    <source-file src="src/android/libGoogleAnalyticsV2.jar"
            target-dir="libs" />
</platform>
jtomaszewski commented 10 years ago

@mchev2 , with this, do you get Google Analytics data onlive on Android? I still cant manage to receive any data from Android (iOS works though) :/

mchev2 commented 10 years ago

As tomwoods mentioned, for Android extra permissions are needed. It worked after I added the extra permissions. Without it I did not see any data going between GA and our app. I noticed that someone already sent a pull request for the same. https://github.com/phonegap-build/GAPlugin/pull/42