You are here

google_analytics_et_example.module in Google Analytics Event Tracking 7

Same filename and directory in other branches
  1. 6 google_analytics_et_example/google_analytics_et_example.module

Google Analytics Event Tracking Module API Example.

Shows a quick and dirty example of how to integrate the Google Analytics Event Tracking Module into an user's module.

File

google_analytics_et_example/google_analytics_et_example.module
View source
<?php

/**
 * @file
 * Google Analytics Event Tracking Module API Example.
 *
 * Shows a quick and dirty example of how to integrate the Google Analytics
 * Event Tracking Module into an user's module.
 */

/**
 * Implements hook_google_analytics_et_settings_info().
 */
function google_analytics_et_example_google_analytics_et_settings_info() {
  $settings = array();
  $settings['debug'] = TRUE;
  return $settings;
}

/**
 * Implements hook_google_analytics_et_api().
 */
function google_analytics_et_example_google_analytics_et_api() {
  return _google_analytics_et_example_set_selectors_array();
}

/**
 * Internal function returns the example selectors array.
 */
function _google_analytics_et_example_set_selectors_array() {
  $selectors = array();
  $selectors = array(
    array(
      'event' => 'mousedown',
      'selector' => 'a',
      'category' => 'main navigation',
      'action' => 'click',
      'label' => '!test',
      'value' => 0,
      'noninteraction' => TRUE,
    ),
    array(
      'event' => 'mousedown',
      'selector' => '#page-title',
      'category' => 'main navigation',
      'action' => 'click',
      'label' => '!test',
      'value' => 0,
      'noninteraction' => TRUE,
      'options' => array(
        'trackOnce' => TRUE,
      ),
    ),
    array(
      'event' => 'mousedown',
      'selector' => 'a#logo',
      'category' => 'Home Link',
      'action' => 'click',
      'label' => 'Logo',
      'value' => 0,
      'noninteraction' => TRUE,
    ),
    array(
      'event' => 'mousedown',
      'selector' => 'div',
      'category' => 'Home Link',
      'action' => '[site:name]',
      'label' => 'test',
      'value' => 0,
      'noninteraction' => TRUE,
    ),
    array(
      'event' => 'blur',
      'selector' => '#edit-name',
      'category' => '[TEST] blurred from the user login username/email input field.',
      'action' => 'BLUR',
      'label' => '!test',
      // !test token causes the the output to be alerted to the screen.
      'value' => 0,
      'noninteraction' => TRUE,
    ),
  );
  return $selectors;
}

Functions