Google Analytics Bridge is a java library for android ( Soon to be Open Source licensed ) that will help developers understand what the user interaction with their own application.
Google Analytics Bridge is really easy to setup and it runs on a separate thread. This is do to the problem with the internet request sometime freezing the UI and setting off the hated message:
"The Application xyz is not responing"
With the two choises :
- Force Close
- Wait
Since The Google Analytics Bridge runs on a different thread to avoid this error.
First Setup
Download and import the jar file to the application you want use the Google Analytics Bridge on. The setup is a fast one-line command but you need the following information:
- Google Analytics Tracking Code ( EX: "UA-123123123-1" )
- The Domain Name
Set up a brand new Google Analytics Profile
you will need to set up a new Google Analytics Profile or use an existing one. You will need to open a new website profile on google analytics.
The procedure is fast and simple but it does require The domain name.
In that field you can specify whatever you want, but i suggest something like:
track.your-application-name.com
After creating the new profile, copy the UA-XXXXXX-Y code for a further usage.
The Constructor
Once you've done all of step one it's time to create our constructor.
In the onCreate routine place the following code:
-
new AnalyticsBridge(this.getApplicationContext(),"UA-XXXXXX-Y","track.your-application-name.com");
You don't need to create an AnalyticsBridge object , after this line you will call the methods in a static way.
NOTE: You should call the constructor once per application lifetime.
Public Methods
_trackPageview(String pageTitle)
If you've some experience integrating google analytics on your own website you'll also remember what this method will do.
_trackPageview method on the web it's used for logging a new page View by the user. Similarly calling this static method on android will generate a google analytics request that will log a new Activity View.
Lets say you've a lot of activity, and some of theese will show the same content but in a different way, then i would put the following code on each onCreate Subroutine:
-
/** Called when the activity is first created. */
-
@Override
-
public void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.main);
-
-
AnalyticsBridge._trackPageview(this.getClass().getName());
-
-
}
This code will log each opened activity to google analytics.. Isn't it easy?
_trackEvent(String category, String action)
_trackEvent method is the same used on the web google analytics apis. I made this bridge because you should want to track some event made by the user.
Let suppouse you want to track a button click event on your user interface - this could help you understand how the user interact with your user interface - then you simply write the following statement on your View.OnClickListener implementation:
That code will track the event of category "Click" and action "login Button".
Download:
Right now the library is quite stable . You can download it here
Thanks
Thanks to barakinflorida who corrected my bad english
Tracciare le applicazioni nei telefonini Android · Google Analytics in 30 secondi
settembre 14, 2009 at 9:37 am
[...] Andrea Baccega ha invece realizzato un “ponte” tra le applicazioni Android e Google Analytics, che consentirà agli sviluppatori Android di avere una libreria pronta da includere nelle loro applicazioni per tracciare cosa e quanto fanno gli utenti mentre le utilizzano. La libreria ha due metodi _trackPageview e _trackEvent che possono essere usati ad esempio per tracciare pannelli e pulsanti delle applicazioni, per sapere quante persone usano un certo pulsante su una certa “pagina”, oppure per recuperare informazioni sulle opzioni scelte dentro all’applicazione. Le istruzioni per l’utilizzo e il download si trovano sul blog di Andrea, e non le riporto qui. Il mio consiglio, qualora voleste cimentarvi nell’integrazione, è di specificare a chiare lettere prima e durante l’utilizzo (magari con una finestra di dialogo obbligatoria al primo utilizzo, ove premere OK e RIFIUTO) che la vostra applicazione traccerà in modo anonimo i dati di utilizzo. [...]
Statistiche delle vostre applicazioni - Forum Android Italiano
febbraio 2, 2010 at 10:14 pm
[...] questo post diventi lunghissimo lascio il link alla mia documentazione in inglese sul mio blog. Google Analytics Bridge for Android developers | Baccega Andrea seo blog | android, google, google a… __________________ I [...]
luglio 23, 2010 at 8:39 am
this is great, I’ll try to implement it in a webview of an application for my site, thanks for sharing.
luglio 23, 2010 at 8:43 am
hi mobile news reader, this library is good but google has developed his own google analytics library, maybe you would like to implement that instead of this
Btw, in the webview you could use the standard js library
luglio 23, 2010 at 9:05 am
Hi andrea and thanks for the info, I’ll look around and try to find it, and probably go with it.