Saturday, January 26, 2013

3 Google Analytics "Hacks" that will improve your tracking ablities

3 Google Analytics "Hacks" 
that will improve your tracking ablities

There is some useful information that Google excludes from analytics. The downside of any free application is that you can only customize the information that is provided to you. So, since the genesis of Google Analytics, coders have been coming up with ways to gather additional information. The following are three hacks that will provide a more thorough experience with Google's analytics suite.

#1 Tracking Outbound Links

When a user leaves your website by clicking on an outbound link, Google does not track how many users click on them. This leaves you wondering how successful your outbound links are. The following hack will allow you to track how many clicks are happening on each link:

1) Set up Event Tracking in your Analytics Tracking code.
You're going to add the following line to the tracking code for your pages after the page tracking object is set up:

    var pageTracker = _gat._getTracker('UA-XXXXX-X');

2) Add JavaScript in the <head> of your document to delay the outbound click.
Not to worry...this delay is only a fraction of a second and will hardly be noticeable by the user. But the delay does provide the browser more time load the tracking code. Without this delay, the user may click on the outgoing link before the tracking code loads, in which case the event isn't going to get recorded. Here's the JavaScript code you'll add in the <head> section (NOTE: this script assumes you will use your own tracking code ID):

    <script type="text/javascript">
    function recordOutboundLink(link, category, action) {
      try {
        var pageTracker=_gat._getTracker("UA-XXXXX-X");
        pageTracker._trackEvent(category, action);
        setTimeout('document.location = "' + link.href + '"', 100)

3) Update the outbound links you want to track to call the new function without following the link first.
For example, to log every click on a particular link to, you would use the _trackEvent() method in the link's <a> tag, like so:
    <a href="" onClick="recordOutboundLink(this, 'Outbound Links', '');return false;">

#2 Tracking Lost Users

The bigger your website gets, the more likely it is that your user will land on a 404. This creates a bad user experience, and the more it happens the more upset users you'll have. This hack will help you track how often users land on pages that don't exist, so you can find and fix the issues. 

Setup: Placing The GATC In Your Error 404'S, 500'S, Etc.

To track error pages you will need to have the Google Analytics Tracking Code (GATC) added to your error page template(s) (contact your webmaster to complete this task). Without the tracking code on the error pages you will not be able report on these pages or find their associated broken links.
As a reference, here is the code:
<script type="text/javascript">
Var gaJsHost = (("https:" == document.location.protocal) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
<script tupe="text/javascript">
Var pageTracker = _gat.getTracker("UA-xxxxx-x");
Note: Be sure to use your own number under gat.getTracker()
With the GATC on your error pages they will now be tracked as page views. Since these error pages will be considered page views you will want to create a filter that will allow you to view them in isolation from each other.
One important aspect to setting up your error report properly is the naming convention that you use for your error pages' in the HTML "title" tag. All of the title tags need to be created in a consistent manner so that a single filter will be able to identify them. An example title tag would be: Error 404 Page.
For other errors you would just replace the '404' with the appropriate error number. An example of a custom filter that will track the above format would be:
Filter Type: Advanced
Field A -> Extract A | Page Title | (Error [0-9][0-9][0-9].+)
Field B -> Extract B | Request URI | (.*)
Output To -> Constructor | Request URI | $A1$B1
Field A Required: Yes
Field B Required: Yes
Override Output Field: Yes
Case Sensitive: No
An alternative version of the Field A regular expression is: (Error [0-9]{3}.+) Once you have the GATC on your error pages and set up your filter to help differentiate the different type of error pages from each other it is time to figure out where your error pages are and which links (broken links) sent your visitors to these nonexistent pages.

Creating The Report In Top Content

To create your error pages report you will go to the top content report and then filter by the term "error" (assuming you had this word in your error page title tags as we did above). This will bring up all of your error pages and let you see the associated Content Performance metrics associated with them (pageviews, unique pageviews, bounce rate...)
Now that you have identified the error pages we need to track down the broken links that created the error. To do this you will click on an error page in the report to view the content details of that page. From the content details page you will then click on the "Navigation Summary" link on the right side. Once on the Navigation Summary page you will be able to see the page your visitor was on prior to visiting your error page. A quick visit to these pages and you should be able to figure out where your broken links are. Sometimes the pages with the broken links will not be within your site and you will need to contact someone else and ask them to correct the link, or set up a 301 redirect on your site to redirect the inbound visitor to the correct URL.
This is a great report for your webmaster or IT team to review regularly so that you can fix broken links as quickly as possible and reduce the number of error pages that your visitors will see.

#3  Tracking SEO variables in Google Analytics

This hack will be extremely useful for anyone who is running a site that is very content rich or has allows users to leave reviews. It would be optimal to segment your data by pages that have lots of content and pages that don't.
          1,                   // This custom var is set to slot #1. Required.
          'Num_Reviews',       // The name of the custom variable. Required.
          0,                   // Sets the value of "Num_Reviews" to 0. Required.
          3                    // Sets the scope to page-level.  Optional.

You don't have to limit yourself to just using this for number of reviews, you could look at other factors that you think might be affecting your pages ability to rank and pass those into GA. For example, you could pass the length of the description of a page. Or the number of tweets it has or anything you can think of really!

These are just three hacks of probably hundreds. Just being aware that they exist will allow any savvy analytics user to improve their ability to track vital data. The following are some additional references that may help you in your efforts to become an ultimate user: