PhoneGap-alytics

PhoneGap-alytics

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:

startTrackerWithAccountID

  • 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.

trackEvent

  • parameters for category,action,label,value
  • when something happens in your app, and you want to keep track of it, you can call trackEvent

trackPageview

  • 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.

    // track an event in your app
    googleAnalytics.trackEvent(“userAction”,”ftw”,”label goes here … “,callNum++);

    http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

    What’s to come

    We hope to make

  1. Jeremy
    Jeremy08-16-2011

    I don’t see any plug-in code links, is there no plug-in? Do I just need the GoogleAnalyticsPlugin.js file, and if so, where would I get that?

    This project looks awesome and I want to add it in to my app!

  2. Tim Hogg
    Tim Hogg08-30-2011

    Thank you for all the work you do to aid the progress of phonegap. I have been one of the benefactors of your work.
    I have a question about the MapKit plugin for phonegap. Where is the best place to ask questions about that?

    No Twitter Messages