Getting multiple metrics in one Keen query

I played with Keen and could not find a way to get multiple metrics in one query. Although I do not mind asking again and combining the results in my application.

I also understand that api metrics are just designed to facilitate visualization when analyzing a single property makes sense.

Just want to know if this is possible in the near future?

+5
source share
1 answer

In some situations, you can get multiple metrics in a single query.

You can use the Multi-Analysis query type to run several types of analyzes on the same collection. The multi-analysis is described in detail here: https://keen.io/docs/data-analysis/multi-analysis/

Getting multiple metrics from individual collections is slightly different. keen-js allows you to pass an array of requests to the .run() function, which are then executed simultaneously in the background. While it is true that keen-js still runs multiple requests behind the scenes, passing an array of request objects mimics a single request operation.

keen-js Example:

 var count = new Keen.Query("count", { eventCollection: "pageviews", groupBy: "visitor.geo.country", interval: "daily", timeframe: "this_21_days" }); var sum = new Keen.Query("sum", { eventCollection: "purchases", targetProperty: "total", interval: "daily", timeframe: "this_21_days" }); client.run([count, sum], function(response) { count = this.data[0]; sum = this.data[1]; var pageviews = new Keen.Visualization(count, document.getElementById("pageviews"), { chartType: "metric", title: "Pageviews" }); var total = new Keen.Visualization(sum, document.getElementById("total"), { chartType: "metric", title: "Total" }); }); 

There is also an example in keen-js that shows how to combine the results of several queries into one graph: https://github.com/keen/keen-js/blob/master/docs/visualization.md#combine-results-of- two-queries p>

+5
source

Source: https://habr.com/ru/post/1207384/


All Articles