List (Read) Saved Queries

Once you have created a query, you can run a report to return the query result.

These results then be listed or manipulated as necessary for your application.

Reading a query:

 

Code Block Example
//Include the analytics class and the configuration class
$t->runInteraction("Analytics.class.php");
$t->runInteraction("Config.class.php");
 
//Create our query object
$query = new Query(Config::$ANALYTICS_ANALYST);

//check if the query exists
$res = $query->get();


Explanation:

The first two "runInteraction" lines will simply "include" the class files you already uploaded. Make sure your have used the correct interaction names. You will need to put both of these lines on any page, or interaction, that you will be calling the class.

  

//Create our query object
$query = new Query(Config::$ANALYTICS_ANALYST);

This line will simply create the $query object, using the analyst credentials from the the Config.class.php file.

 

//Read all saved queries
$res = $query->get();

This line will will read all saved queries (there are no search options available).


Return:

This report will return an array containing the events that have been logged against the query. If you have been following the examples in this documentation your response would look similar to this:

Return
Array
(
    [0] => Array
        (
            [_id] => 56de2fr0219b38e071aac27e
            [name] => Login
            [tags] => Array
                (
                    [username] => johnsmith
                    [group] => Inspector
                )
            [date] => 2016-03-21T01:17:17.328Z
        )
)

 

 

Next Steps: