You are here

README.txt in Google Analytics Event Tracking 7

Same filename and directory in other branches
  1. 6 README.txt
Google analytics event tracking module README:

Purpose
  To provide a user configurable and reusable module for the tracking of
  events with google analytics.
  Per this method
   http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
  
Google method
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-YY']);
  
  (function() {
    var ga = document.createElement('script'); 
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src =
    ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
    '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
  })();
  
  _gaq.push(['_trackEvent', category, action, optional label, optional_value,
    optional noninteraction]);
  _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
  
  • category (required)
      The name you supply for the group of objects you want to track.
  • action (required)
      A string that is uniquely paired with each category, and commonly used
      to define the type of user interaction for the web object.
  • label (optional)
      An optional string to provide additional dimensions to the event data.
  • value (optional)
      An integer that you can use to provide numerical data about the user
      event.
  • non-interaction (optional)
      A boolean that when set to true, indicates that the event hit will not
      be used in bounce-rate calculation.

Usage
  Create an array of arrays with the format 
    $selectors = array(
      array(
        'event' => 'String',
        'selector' => 'String',
        'category' => 'String',
        'action' => 'String',
        'label' => 'String',
        'value' => integer,
        'noninteraction' => boolean,
      ),
    );
  Each of the elements in the inner array are values that will go into the
  corresponding parameter of the google analytics push call. On the category,
  action, and label keys the value could be set to !text in order to utilize
  the .text() method for the value: for instance, if one where to use !text
  as the value for the label on a call that used '#main-menu li a' for the
  selector --the corresponding label for the value sent to google would be
  the .text() within the a tag; most likely this would be the title of the
  destination that the link was sending the user to: 'Home' or 'Blog'
  Below is an example of exactly that:

  array(
    'event' => 'mousedown',
    'selector' => '#main-menu li a',
    'category' => 'main navigation',
    'action' => 'click',
    'label' => '!text',
    'value' => 0,
    'noninteraction' => true,
  ),

  This array should be returned via an implementation of
  hook_google_analytics_et_api()

  An example module is supplied in the module Google Analytics ET Example.

File

README.txt
View source
  1. Google analytics event tracking module README:
  2. Purpose
  3. To provide a user configurable and reusable module for the tracking of
  4. events with google analytics.
  5. Per this method
  6. http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
  7. Google method
  8. var _gaq = _gaq || [];
  9. _gaq.push(['_setAccount', 'UA-XXXXXX-YY']);
  10. (function() {
  11. var ga = document.createElement('script');
  12. ga.type = 'text/javascript';
  13. ga.async = true;
  14. ga.src =
  15. ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
  16. '.google-analytics.com/ga.js';
  17. var s = document.getElementsByTagName('script')[0];
  18. s.parentNode.insertBefore(ga, s);
  19. })();
  20. _gaq.push(['_trackEvent', category, action, optional label, optional_value,
  21. optional noninteraction]);
  22. _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
  23. • category (required)
  24. The name you supply for the group of objects you want to track.
  25. • action (required)
  26. A string that is uniquely paired with each category, and commonly used
  27. to define the type of user interaction for the web object.
  28. • label (optional)
  29. An optional string to provide additional dimensions to the event data.
  30. • value (optional)
  31. An integer that you can use to provide numerical data about the user
  32. event.
  33. • non-interaction (optional)
  34. A boolean that when set to true, indicates that the event hit will not
  35. be used in bounce-rate calculation.
  36. Usage
  37. Create an array of arrays with the format
  38. $selectors = array(
  39. array(
  40. 'event' => 'String',
  41. 'selector' => 'String',
  42. 'category' => 'String',
  43. 'action' => 'String',
  44. 'label' => 'String',
  45. 'value' => integer,
  46. 'noninteraction' => boolean,
  47. ),
  48. );
  49. Each of the elements in the inner array are values that will go into the
  50. corresponding parameter of the google analytics push call. On the category,
  51. action, and label keys the value could be set to !text in order to utilize
  52. the .text() method for the value: for instance, if one where to use !text
  53. as the value for the label on a call that used '#main-menu li a' for the
  54. selector --the corresponding label for the value sent to google would be
  55. the .text() within the a tag; most likely this would be the title of the
  56. destination that the link was sending the user to: 'Home' or 'Blog'
  57. Below is an example of exactly that:
  58. array(
  59. 'event' => 'mousedown',
  60. 'selector' => '#main-menu li a',
  61. 'category' => 'main navigation',
  62. 'action' => 'click',
  63. 'label' => '!text',
  64. 'value' => 0,
  65. 'noninteraction' => true,
  66. ),
  67. This array should be returned via an implementation of
  68. hook_google_analytics_et_api()
  69. An example module is supplied in the module Google Analytics ET Example.