Suhaimi's
Design | Code | Deliver

Behind the Scene of Google Analytics

Website Design

This is a quick overview about Google Analytic specifically for developers.

It might be too technical for some to even digest. Anyway here’s what you need to do. You can put either one of the scripts.

In a nutshell: Google Analytics is a free service offered by Google that generates detailed statistics about the visitors to a website. Its main highlight is that the product is aimed at marketers as opposed to webmasters and technologists from which the industry of web analytics originally grew. It is the most widely used website statistics service, currently in use at around 57% of the 10,000 most popular websites. (source from Wikipedia)

The Traditional Way

<script type=”text/javascript”>
  1. var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  2. document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  3. </script>
  4. <script type="text/javascript">
  5. try {
  6. var pageTracker = _gat._getTracker("UA-XXXXX-X");
  7. pageTracker._trackPageview();
  8. } catch(err) {}</script>

Replacing UA-XXXXX-X with your web property ID.

The Asynchronous Tracking Method (more info)

<script type=”text/javascript”>
  1.  
  2.  var _gaq = _gaq || [];
  3.  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  4.  _gaq.push(['_trackPageview']);
  5.  
  6.  (function() {
  7.  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  8.  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  9.  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  10.  })();
  11.  
  12. </script>

Replacing UA-XXXXX-X with your web property ID.


Related posts:

  1. What's with Stinge SiteBuilder

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>