You are here

public function Analytic::track in Analytics 6

Primary function to record a data point.

Parameters

$event_name:

$properties:

File

includes/analytic.inc, line 35
Class definition for analytics.

Class

Analytic
@file Class definition for analytics.

Code

public function track($event_name, array $data = array()) {

  // Set default properties
  $this->event_name = $event_name;

  // Peel off IP address and user_id
  $ip_address = $data['ip_address'];
  $unique_id = $data['unique_id'];
  unset($data['ip_address'], $data['unique_id']);
  if (empty($ip_address)) {
    $ip_address = $_SERVER['REMOTE_ADDR'];
  }
  foreach ($data as $key => $value) {
    if (is_numeric($key)) {
      unset($data[$key]);
    }
  }
  $this->data = $data;
  $this
    ->setEventName($event_name);
  $this
    ->writeEventRecord($ip_address, $unique_id);
}