gaAddonsgaAddons - Google Analytics Addons by Stéphane Hamel

Documentation: Getting Started

gaAddons brings several enhancements and seemlesly integrates with your existing Google Analytics async tracking code snippet. Each gaAddons call comes with pre-configured default options which can be overwritten using the same flexible tracking syntax found in Google Analytics async calls..

Get started with the snippet integration instructions shown bellow and refer to the calls reference to make the best use of gaAddons.

The snippet

1. Standard Google Analytics async snippet

Refer to the Getting Started with the Asynchronous Snippet for your regular Google Analytics implementation guidelines.

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(
      ['_setAccount', 'UA-XXXXX-X'],
	  ['_trackPageview']
	  );
(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);
   })();
</script>

2. Get gaAddons

Save a copy of gaAddons-2.1.2.min.js to your own website.

Note: in theory you could link directly to the file on this site but this would create an unnecessary cross-site dependency and potential vulnerability.

3. Link to jQuery

gaAddons is dependent on the jQuery 1.4.4 library. If your site already use it or use an older version gaAddons will work fine.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>

4. Add gaAddons calls!

Integrate the gaAddons calls directly into your standard _gaq code snippet. The resulting JavaScript block looks like this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="/path-to-your-scripts/gaAddons-2.1.1.min.js"></script>
<script type="text/javascript">
   var _gaq = _gaq || [];
   _gaq.push(
      ['_setAccount', 'UA-XXXXX-X'],
      ['_trackDownload'], // This is where gaAddons calls go
      ['_trackOutbound'], // Showing three basic calls
      ['_trackMailTo', {  // Sample call overwritting some defaults
         onBounce:false,  // - Do not track if the page is a bounce
         category:'email' // - Change the event label
         }],
      ['_trackPageview']
      );
(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);
   })();
</script>

4. Customize gaAddons calls

Refer to the calls reference to learn how to properly add gaAddons calls, customize them if needed and see examples.

Tips

  • Calls can be stacked multiple times - for example you could use two _trackDownload calls to track two types of files differently.
  • As of v2.1.2, calls are compatible with the multiple-tracker syntax - you can use _trackDownload and t2._trackDownload.

Need to modify gaAddons?

Badge_logo_smallYou should never alter the gaAddons-2.1.1.min.js file itself. If you think there is a bug or a feature is missing, please submit your idea, question, problem or send in your praise about gaAddons through Get Satisfaction!