You are here

function drush_google_analytics_et_admin_gaet_add_et in Google Analytics Event Tracking 6

Same name and namespace in other branches
  1. 7 drush_commands/google_analytics_et_admin.drush.inc \drush_google_analytics_et_admin_gaet_add_et()

Drush command callback for gaet-add-et.

Adds an event to be tracked by a click event on the given CSS selector.

Parameters

string $event: The Javascript event that Google Analytics is going to track.

string $selector: The CSS string that defines the CSS selector of the elements that will respond to the click event.

string $category: The name you supply for the group of objects you want to track.

string $action: A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.

string $label: (optional) An optional string to provide additional dimensions to the event data.

int $value: (optional) An integer that you can use to provide numerical data about the user event.

string|bool $nonineration: (optional) A boolean that when set to true, indicates that the event hit will not be used in bounce-rate calculation

File

drush_commands/google_analytics_et_admin.drush.inc, line 104
Google Analytics Event Tracking Module Drush Admin.

Code

function drush_google_analytics_et_admin_gaet_add_et($event, $selector, $category, $action, $label = '', $value = 0, $nonineration = TRUE) {
  $selector_array = array(
    '$event' => $event,
    'selector' => $selector,
    'category' => $category,
    'action' => $action,
    'label' => $label,
    'value' => $value,
    'noninteraction' => $nonineration,
  );
  if (_drush_google_analytics_et_admin_gaet_add_et_input_validation($selector_array)) {
    google_analytics_et_add_event_tracker($selector_array);
    foreach ($selector_array as $key => $value) {
      drush_print('   | ' . str_pad($key . ' ', 16, "-", STR_PAD_RIGHT) . ' | ' . $value);
    }
    drush_print(dt("Done!"));
  }
  else {
    drush_print(dt("An Error Occured! \nOne or more data types was incorect."));
  }
}