Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Logging an event is how you start collecting data.

...

By default, a timestamp of the log will be automatically inserted, and so there is no need to include a timestamp yourself. You can, however, add as much extra information to the log as you wish. This extra information can also be queried on, as we will show later.

 

Code Snippet Example:
 

//to import the analytics classes
$t->runInteraction("Analytics.class.php");

//import config class which contains keys
$t->runInteraction("Config.class.php");

//create object
$analytics = new Event(Config::$ANALYTICS_COLLECTOR);

//register login event with username, returns saved event with unique id
$response = $analytics->log("Login", array("username" => "johnsmith",
 
                                                                          "group" => "Inspector"));


 

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 object
$analytics = new Event(Config::$ANALYTICS_COLLECTOR);

This line will simply create the $analytics object, using the details from the the Config.class.php file. You don't need to modify this line.


//register login event with username, returns saved event with unique id
$response = $analytics->log("Login", array("username" => "johnsmith",
     
                                                                      "group" => "Inspector"));

...

In the example above, we're including the username of the person logged in, and the group they are a part of. To add extra information, just add a new value to this array.

Response:

After running this method, you will receive a response object that will simply return the data you logged. You can use this to double check values if you wish, but this is optional.


Next Step:

Create a Query