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:

 

Code Block
languagephp
themeRDark
titleLog an Event
//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);
 
$name = "Login";
$tags = array("username" => "johnsmith", "group" => "Inspector");

//register login event with username, returns saved event with unique id
$response = $analytics->log($name, $tags);

 

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"));

...