Google Analytics Quick Start Guide : Part 1 – Setup

Overview

Google Analytics is a easy to install analytics package useful for tracking activity on both small and large websites. This 3 part guide outlines how to setup and install google analytics on your website as well as explaining the basic information you can get out of the system e.g. Site Visits, Page Views, Bounce Rates, traffic sources, and etc.  I recommend installing analytics on every site you develop as it takes a matter of minutes, and can give you valuable insight into what information on your site visitors are looking for.

Setting Up Your First Account

Setting up your first account is as simple as filling out a few forms.

  1. Go to the google analytics site at http://www.google.com/analytics
  2. If you don’t have a google account, create one by selecting the  “sign up now” link and following the instructions. If you do have an account proceed to step 3.
  3. Sign in to your account – this should take you to the Account Overview page listing all of your analytic accounts.
  4. Create a new analytics account by selecting “+ add new account”
  5. On the getting started page select the “Sign Up” button.
  6. Next you will be prompted to enter the site information including url, name, country, and time zone.  Once entered press “continue”
  7. On the following screen enter the primary contact for the analytics account, unless this account will be handled by a client enter your information. Press “continue” once completed.
  8. After you enter the contact information you will be prompted to accept google’s privacy policy, you will need to select “yes” to continue. In addition you can also modify the account’s data sharing with google and non-google applications. I personally select Share “with other Google products only”
  9. Click “Create New Account”
  10. Copy the code displayed under the “New tracking Code (ga.js)” and paste it into a document.
  11. Click “Finish”, you should now be back on the overview page displaying your new account.

Installing the code into your site

It is recommended that you place the tracking code copied from step 11 above into your web page right before the closing </body> tag. This way the page is loaded before the tracking code runs. You will need to do this for every page of your website, if you are using a language such as php to output your web pages it would be a good idea to place the code in a separate file that is included in all your pages. Doing so will keep your from modifying your entire site if you need to modify settings in the future. You do not need to make any modifications for if your site is using ssl as the script checks the protocol being utilized.

Once you place your files live on your server tracking will now be functioning.  Please note that you will not see information in real time and will see information up to the previous day.

<html>
<head>
  ...
</head>
<body>
  ...
  <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
    try {
      var pageTracker = _gat._getTracker("UA-6713355-1");
      pageTracker._trackPageview();
    } catch(err) {}
  </script>
</body>
</html>

Understanding the Basic Reports

To view the statistics of your site you will need to log back into google analytics. Once logged in select the analytics account for the site you want to view data on by clicking on the name.  You will now be presented with the profiles set-up for this account select “view report” to go to the report dashboard.  On this page you can get the basic stats of your site.

  • Site Usage
    • Visits – How many visits have there been to your site
    • Pageviews – How many pages have been viewed on your site in total
    • Pages/Visit – On average how many pages does a visitor view
    • Bounce Rate – What percentage of people come to this page then immediately go somewhere else
    • Avg Time on Site – How long does a visitor stay on the site
    • New Visits – Percentage of new visitors to the site
  • Visitors – Displays the number of visitors to your site, note that the number of visitors may be less then the number of visits as a visitor my visit your site multiple time
  • Map Overlay – This feature gives you a global view of where visitors of your site are from and you are able to click in to a state view as well.
  • Traffic Sources Overview – This area displays how users are getting to your site, from direct traffic(typing in the url) search, referral from other sites, etc.
  • Content Overview – The Content Overview lists out the top viewed pages in your site. This area can be used to determine what pages users find helpfull and ones that they don’t.

Conclusion & Next Steps

That concludes Part 1 of the Google Analytics Quick Start Guide, you should now know how to configure google analytics into your websites and what some of the basic stats are that you can retrieve from the system to enhance your visitors experience.  The introduction is continued in Part 2 – Link tracking and Site Search

// Analytics //

Session Fixation

Session Fixation is a security vulnerability where a user sets the Session Identifier (SID) of a user to a known value, allowing them to access your session. This would allow the malicious user to access the user’s private information. For Example: Jason has determined that his neighbor Joe’s bank site http://mybank.com is susceptible to a

Javascript String Reverse

Simple Javascript reverse function prototyped onto the String Object.

String.prototype.reverse = function(){
    return this.split("").reverse().join("");
}

Usage Example:

var test_string = "reverse this string";
var reversed_string = test_string.reverse();
// Javascript //