Do you want to gain marketing intelligence and information on how users interact with your PhoneGap app? You need this plugin!
Introducing the Google Analytics for PhoneGap plugin.
Over the last couple weeks, Joe aka @infil00p and I have been working on some exciting new plugins. We wanted to provide a simple way for PhoneGap developers to get analytics data on the usage of their apps.
Instead of doing something stupid [edit: removed prickish link], like trying to write our own analytics engine, we integrated with Google’s best in class offering.
Google already provides code for Android and iOS, so we really just needed to make a mapping from the JS side to the native side. Plugins made this simple, as this is exactly what they were intended for. We simply reviewed the Google SDK functionality and mirrored this in JS.
Google’s GANTracker class provides the bulk of the functionality and exposes the following methods:
- given a web-entity-id, start tracking engine.
- the engine will periodically send analytics data to the server.
- the engine will cache data if there is no network connection, and update the server when it can.
- parameters for category,action,label,value
- when something happens in your app, and you want to keep track of it, you can call trackEvent
- pageViews mean something different in an application, they may reflect actual pages, or perhaps different views within your app.
- The choice of what you send for pageUri is up to you. It can be any string value, for example /application/launch or app/settings.
Installation and Use
From finder, place the plugin js file in your www folder, and include it in the page.
After receiving the deviceready event in your app, start the tracker.
Note that I create a local alias, so I don’t need to type window.plugins.googleAnalyticsPlugin everywhere, and code can be more readable.
Track the fact that your app was launched.
Google has lots more info on how to use events so that you can track meaningful information on usage.
Where to get it.
What’s to come
We hope to make