Fork us on GitHub

Using Analytics

Gain deeper understanding of your users

Analytics allow you to gain insight into the structure of your application, Codename One supports seamless integration with Google Analytics across all device families.

Analytics is seamless for a GUI builder application since navigation occurs via the Codename One API and can be logged without developer interaction. However, to begin the instrumentation one needs to add the line:

AnalyticsService.init(agent, domain);

To get the value for the agent argument just create a Google Analytics account and add a domain, then copy and paste the string that looks something like UA-99999999-8 from the console to the agent string. Once this is in place you should start receiving statistic events for the application.

If your application is not a GUI builder application or you would like to send more detailed data you can use the Analytics.visit() method to indicate that you are entering a specific page.