As you may or may not be aware google analytics is one of the free service provided by Google for website owners. It would allow website owners to track the usage data and perform usage & trend analysis on websites. Whether you have a personal blog, social networking portal, corporate website or just a family website, you will be able to track the information about the visitors and what part of the website they use more etc. So, it would help the webmasters to find their target audience and identify the areas for improvements.
Conventionally, google analytics is used only for tracking websites and web portals. As a open-source contributor I often wonder, is there a way to track the usage on non web-based applications. I was curious to know about my users, what part of the tool they use more or even less. Hence, the genesis of JGoogleAnalytics. It’s a light-weight, unobtrusive utility used for tracking usage data on Java applications thro Google analytics. If you are a plugin(IntelliJ, Eclipse, Netbeans) developer or own a full blown Java web portal, you will be able to track the usage data.
As a proof of concept, I have used this tool in Library Finder – IntelliJ plugin. I am capturing events like plugin load and some of the user actions. Following is the sample code to track the usage data. FocusPoint is a logical point of focus in the application. It can be events like application/module load, user actions, error events etc.
//Google analytics tracking code for Library Finder JGoogleAnalyticsTracker tracker = new JGoogleAnalyticsTracker("Library Finder","1.3.2","UA-2184000-1"); FocusPoint focusPoint = new FocusPoint("PluginLoad"); tracker.trackAsynchronously(focusPoint);
There are two ways you can capture the usage data. You can track them either Synchronously or Asynchronously. Please note that you may always want to use the Async approach unless otherwise it’s required or if you are ready to sacrifice some performance hit on the actual application. Tracking asynchronously is the ideal way as it will be running on a low-priority thread.
Here is the google analytics screenshot showing the usage on Library Finder.
Please let me know if you have any suggestions, comments or critiques.