google_analytics_et.api.php in Google Analytics Event Tracking 6
Same filename and directory in other branches
Hooks provided by Google Analytics Event Tracking API
File
google_analytics_et.api.phpView source
<?php
/**
* @file
* Hooks provided by Google Analytics Event Tracking API
*/
/**
* Defines selectors and events to track through google analytics.
*
* Returns an array with all nessesary information to track an event with
* google analytics.
* http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
* Each member of the array should be an associative array with the following,
* keys:
* event :
* - (String) - A javascript event. ie: mousedown | mousemove | mouseover
* Note: to track clicks it is best to use the [mousedown] event and not
* the [click] event
* selector :
* - (String) - A CSS selector for the DOM element that will be tracked.
* category :
* - (String) - For internal use. Does not effect functionallity. Used
* for catigorization in google analytics.
* Available tokens: !text, !href, !currentPage
* - !text : inserts text from DOM element into parameter.
* - !href : inserts text from the href attriute from the DOM element
* - !currentPage : inserts the url of the current page
* Note : if a token is used then only one token can be used. For
* example: `!url !text` will not work nor will `home !text`.
* action :
* - (String) - For internal use. Does not effect functionallity.
* label :
* - (String) - For internal use. Does not effect functionallity.
* value :
* - (Number) - For internal use. Does not effect functionallity. Does
* effect statistics.
* noninteraction :
* - (Bool) - For internal use. Does not effect functionallity. Does
* effect statistics.
*
* @return array
* A multidimentional array in the format:
* array(
* array(
* 'event' => string('mousedown | mousemove | mouseover | etc'),
* 'selector' => String('#main-menu li a, or other valid css selector'),
* 'category' => String(!text, !href, !currentPage, or custom string),
* 'action' => String!text, !href, !currentPage, or custom string(),
* 'label' => String(!text, !href, !currentPage, or custom string),
* 'value' => Number(Weight of event),
* 'noninteraction' => Bool(TRUE | FALSE),
* ),
* );
*/
function hook_google_analytics_et_api() {
$selectors = array(
array(
'event' => 'mousedown',
'selector' => '#main-menu li a',
'category' => 'main navigation',
'action' => 'click',
'label' => '!text',
'value' => 0,
'noninteraction' => TRUE,
),
array(
'event' => 'mousedown',
'selector' => 'a#logo',
'category' => 'Home Link',
'action' => 'click',
'label' => 'Logo',
'value' => 0,
'noninteraction' => TRUE,
),
array(
'event' => 'mousedown',
'selector' => 'div#site-name a[rel="home"]',
'category' => 'Home Link',
'action' => 'click',
'label' => 'Site Name',
'value' => 0,
'noninteraction' => TRUE,
),
array(
'event' => 'mouseover',
'selector' => 'div',
'category' => 'test',
'action' => 'click',
'label' => '!test',
'value' => 0,
'noninteraction' => TRUE,
),
);
return $selectors;
}
Functions
Name | Description |
---|---|
hook_google_analytics_et_api | Defines selectors and events to track through google analytics. |