title: Google Analytics: Uncaught ReferenceError: _gat is not defined
body: <h2>"_gat is not defined" error on page load</h2>
  
  <p>Tried suggestions from: <a href="https://stackoverflow.com/questions/10401894/uncaught-referenceerror-gaq-is-not-defined-google-analytics">Uncaught ReferenceError: _gaq is not defined (Google Analytics)</a> but didn't help.</p>
  
  <p>Here is my initial code snippet:</p>
  
  <pre><code>(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);
  })(); 
  
  var pageTracker pageTracker = _gat._createTracker('UA-xxxxxxxx-1'); 
  
  &lt;button onclick="pageTracker._setCustomVar(1,'customvar1', 'value', 3); 
  pageTracker._trackPageview();"&gt;Fire&lt;/button&gt;            
  </code></pre>