This article will describe for developers how to integrate and use the Analytics monitor in an application on any platform. After completing the steps, your application will be submitting statistics data to your Analytics dashboard.
If you have not already created an application, please do so first. You can read more about that here:
Statistics for your application are handled by a platform-specific monitor. The monitor will collect, store, and submit the statistics data for your application both automatically and according to your needs.
On all platforms, the monitor-library is a real component that an application must add explicitly. Your application must also programmatically create a monitor instance and invoke its API-methods for it to do its job. There is no magic "Enable Analytics for my entire app"-switch.
Your application will cause analytics data to be sent by explicitly creating a monitor object and invoking its API. The life-cycle of the monitor is overall the same on all platforms:
- Add the monitor library to your application
- Create the monitor instance with product key and optional settings
- Start the monitor when your application starts
- Track what is happening while your application is running
- Stop the monitor when your application stops
The runtime flow is illustrated below:
The details of adding the monitor are very platform-specific and are therefore described individually for All Platforms. Still, the monitor behaves in the same overall manner on all platforms, which will be elaborated below.
A created monitor object is your ticket to reporting data to the analytics server.
Your application will typically create one monitor object, but it is perfectly fine to create multiple instances if you have that need. The monitor will automatically gather information about the platform it is running on (operating system, screen resolution, language, etc) so you don't need to worry about that.
Once created you should ideally call
Start when your application starts and and
Stop when it is about to stop.
Stop the analytics server will register that your application has now been used this one time (also called a session) and receive all the gathered statistics from the monitor.
It is perfectly fine to call
Stop repeatedly on the monitor object. Each such
Stop will be recognized as one run (session) of your application. Stopping and starting the monitor repeatedly is a common practice when dealing with apps that can be suspended and resumed.