title: How to extend google analytics to track AJAX etc (as per H5BP docs)
body: <p>I am trying to install the <code>google analytics augments</code> identified in the <code>extend.md</code> file of H5BP (<a href="https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/extend.md" rel="noreferrer">https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/extend.md</a>)</p>
  
  <p>It states that the "optimised" google analytics JS snippet includes the following code:</p>
  
  <pre><code>var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']];
  </code></pre>
  
  <p>and that additional augments such as <code>track jquery AJAX requests</code>, <code>track javascript errors</code> and <code>track page scroll</code> should be added after  <code>_gaq</code> is defined.</p>
  
  <p>In fact, the snippet included with the current version of H5BP does not make reference to <code>_gaq</code> as a variable:</p>
  
  <pre><code>        (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
          function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
          e=o.createElement(i);r=o.getElementsByTagName(i)[0];
          e.src='//www.google-analytics.com/analytics.js';
          r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
          ga('create','UA-XXXXX-X');ga('send','pageview');
  </code></pre>
  
  <p>This creates an undefined error when trying to use any of the H5BP extensions. E.g. </p>
  
  <pre><code>if (typeof _gaq !== "undefined" &amp;&amp; _gaq !== null) {
      $(document).ajaxSend(function(event, xhr, settings){
          _gaq.push(['_trackPageview', settings.url]);
      });
  }
  </code></pre>
  
  <p>Will not work as _gaq is not defined.</p>
  
  <p>How are these augments intended to be implemented? Can someone provide a working example showing a full implementation of all the extensions?</p>
  
  <p>Thanks</p>