Now that we've created a Query, this example will show you how to run that query and get an object back with the results.
The returned object will allow you to display the results in any way you wish, from a simple table to graphs.
Request:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
$t->runInteraction("Analytics.class.php");
$t->runInteraction("Config.class.php");
//use your collector access key
$collection = Config::$ANALYTICS_COLLECTOR["ACCESS"];
//select the Query ID number you want to use
$queryId = "56de2fr0219b38e071aac27e";
$queryString = array(
"event" => "Login",
"gte" => "date:2016-02-01",
"lte" => "date:2016-03-31",
"group" => "Inspector"
);
$analytics = new Report(Config::$ANALYTICS_ANALYST);
$response = $analytics->runQuery($queryId, $collection, $queryString); |
$queryId (string value)
The $queryId is the ID string that you received when you first created the query. You can also find the queries you need by using the List Saved Queries function.
$queryString (array)
The $queryString array allows you to pass dynamic values to the query, to return the results you want. When we created the query, we set variables, or placeholders, for "event", "gte" (greater than or equals), "lte" (less than or equals), and a "group".
In this example we're looking for an event with the name "Login", between 1 Feb 2016, and 31 Mar 2016 (inclusive), for all users in the group "Inspector".