How can I use the Localytics Query API to generate specific reports?

The Localytics Query API is a tool that can be used to generate custom reports from analytics data that is passed to Localytics. The API returns aggregated metrics - e.g. counts of Users, Sessions, or Events. If you are looking for individual records - e.g. the events for a specific user - you should consider accessing Localytics' raw data logs.

To understand the power of the Localytics Query API, consider that virtually all reports with the Localytics Dashboard are created using this API. For example, when you load a Retention report, under the hood Localytics is making a request to have our API return certain structured results that can then be visualized in a friendly way. What this means is that any report that can be created within the Localytics UI can also be recreated programmatically by querying the API directly.

Localytics provides documentation explaining how to use our API. This should be your first line of defense. Of course, we are also continually evolving and growing the capabilities of our API so here are a few helpful "hacks" for setting up API queries.

(1) Consider using Query Builder in the Dashboard.(Click image to see animation)

Note that while Query Builder requires you to specify the Apps, Metrics, and Dimensions that you want to report on you can also adapt the Time Range and apply Filters as well just like you can in all Localytics reports.

(3) Try creating your report within the dashboard, then inspect what is happening behind the scenes in your browser to "reverse-engineer" the underlying queryTo do this, use a browser like Chrome, and right-click to select "Inspect Element". This should bring up a pane that provides development tools that looks like this:

If you navigate to the "Network" option at the top, it will report all the GET and POST requests that are made while the developers console is open. The Localytics API call will be one of these, usually under the name "query". Try refreshing the page and looking for the record with the name "query". You will then be able to view the particulars of the query that was used to generate this report of interest.