You are here

public function Analytic::setEventName in Analytics 6

Public setter for event name.

Parameters

$event_name string Name of the event to set.:

2 calls to Analytic::setEventName()
Analytic::track in includes/analytic.inc
Primary function to record a data point.
Analytic::__construct in includes/analytic.inc
Constructor to set event name and event ID.

File

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

Class

Analytic
@file Class definition for analytics.

Code

public function setEventName($event_name) {
  $this->event_name = $event_name;

  // Fetch event IDs
  $event = db_select('analytics_events', 'a')
    ->fields('a', array(
    'id',
  ))
    ->condition('event_name', $this->event_name)
    ->range(0, 1)
    ->execute()
    ->fetch();
  if ($event->id) {
    $this->event_id = $event->id;
  }
  else {
    $this->event_id = db_insert('analytics_events')
      ->fields(array(
      'event_name' => $this->event_name,
    ))
      ->execute();
  }
}