You are here

README.txt in Google Analytics Event Tracking 6

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

@todo - Update this for Drupal 6 if needed

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(
    'selector' => '#main-menu li a',
    'category' => 'main navigation',
    'action' => 'click',
    'label' => '!text',
    'value' => 0,
    'noninteraction' => true,
  ),
  
  Once you have created this array you can save it with a call to
  google_analytics_event_tracking_set_selectors($selectors)
  this function will serialize and save the array in the drupal
  variable table.

File

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