Notice: Undefined index: order_next_posts in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 194

Notice: Undefined index: post_link_target in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 195

Notice: Undefined index: posts_featured_size in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 196

A guide to Google Analytics – part 1

Keep track of your content, improve performance and get more hits with the help of Google Analytics.

How do you measure a website? A designer might say that it’s all about pixels, negative space, accessibility, colour – whereas a casual browser might feel compelled by the amount of video or level of Facebook integration. But if we’re not talking about the physical size or perceived entertainment value, then the more obvious characterisation is surely how the site is used.

Way back when the internet opened its metaphorical doors and invited us to add primitive homepages to its blossoming network, there was little thought to how it would perform. You hoped people would firstly find it, scan the limited content and feel vaguely amused enough to come back and maybe pass on a link. It was only when the first embeddable traffic counters emerged that the volume of visitors, or ‘hits’, piqued our interest, as well as the potential value this data may have.

Fast-forward to the present day and the whole concept of web metrics has become far more sophisticated than a crudely animated speedometer. This is really down to two things, with the first being the monetisation of content and how site behaviour can be leveraged for advertising purposes. If we don’t know why our website does well, how it does it, when and where, then we actually bypass a huge driver in the commercial appeal of online business.

Combine this with the rise of Google, a company that understood the first point so well, and you then have an infrastructure, or ecosystem, where web metrics can be harvested at no cost. Google Analytics (GA) delivers a free toolset that any URL can utilise to track key statistics, but crucially have them fed back visually across a series of reports. In this feature we’ll present a thorough overview of GA’s capabilities, from setting it up, explaining the tools on offer and the results they produce, but also what it can imply for ramping up the effectiveness of your site(s). Once you get the hang of measuring web success this way, you’ll find it a pretty addictive method for driving traffic in and, equally vital, keeping it there.

Starting with Google Analytics

There’s not much you need to get started with Google Analytics, apart from a website and an HTML editor. It’s a free service (unless you’re running a very large and very busy site), and all you need to sign up is a Google Account. While a Google Account is essential it doesn’t need to be your primary account, so you can keep things separate from your personal Gmail address.

Signing up is relatively simple. Start by logging on to Google Analytics and giving your account a name. Accounts can be connected to multiple sites on multiple domains, so while most organisations will want a separate account for each site, you can just use one account to track all the sites and domains used by a single service. You’ll need to configure an initial URL – either http or https. There’s also support for applications that aren’t websites, when you want to use Google Analytics with an app or a service on iOS or Android devices. Google will use this information to configure a tracking ID that you’ll add to your page content.

Google gives you the option of sharing your analytics data with other Google products you use, so you are able to fine-tune advertising with AdSense and AdWords. There’s also the possibility of sharing data with the rest of Google, as part of an anonymous benchmarking project. While benchmarking is useful, and lets you compare your site with others in the same industry or market, you may not want to share data at this stage. Choose where you’re based to accept the appropriate terms of service – and read them carefully. You’ll see that the service is free for up to 10 million page views a month, though Google does reserve the right to add supplementary fees for additional services.

You’re now ready to hit the Create Account button. Google Analytics drops you straight in to the settings page for your site, where you’ll see the tracking ID it uses. While Google provides JavaScript code for your pages, some CMSes and blogs have Google Analytics modules that configure your pages for you. All you need to do in that case is copy the code and then drop it into the appropriate control panel on your site or host. If you’re adding code to your site directly there are three options: Standard, Advanced and Custom. The Standard option is the one you’re most likely to use, as it gives you a simple section of JavaScript code that you can copy into the head sections of the pages (or into your HTML template). You’ll need to insert the code into every page you’re tracking, so taking advantage of the templating tools in Dreamweaver or another HTML design package can simplify the process considerably.

You’ll need to define just what you’re tracking before you can add the code to your site. Are you looking at a single domain, or one domain with multiple subdomains, or a site that maps multiple top-level domains? You’ll also need to choose whether you’re using the code alongside any AdWords campaigns. Once you’ve picked the options you want, cut and copy the Google Analytics JavaScript provided. The code goes at the end of the block of each page, just before the closing tag.

Advanced configuration

The Advanced view adds tools for measuring mobile sites, with support for various server-side programming languages (including PHP, Perl, JSP and ASP.NET). Mobile sites are tracked from the server using a dynamic image rather than the browser as some mobile browsers don’t support JavaScript. Most modern mobile browsers should support the client-side code used by desktop browsers, but Google doesn’t recommend using both versions of the tracking code on the same page – so you may wish to use browser-sniffing techniques to dynamically deploy the appropriate tracking code for your users’ browsers. Getting analytics right for mobile can be complex, and it’s well worth spending time to understand which mobile browsers are visiting your site before implementing any analytics code in your pages. Use your server logs to extract a list of the user agent strings from all the browsers visiting your site.

You can also use the various tracking options to manage different types of advertising campaigns, not just Google’s own tools. There’s an option to add the appropriate tags for the various terms used by different advertising sites, so Google Analytics can translate them to give you consistent reports. If you’ve been using Urchin (the software Google Analytics is based on) you can also utilise this feature to migrate from local analytics to Google’s cloud-hosted service.
If you’re working with dynamic content, use the Advanced view to generate the appropriate code to drop into your page templates. Tracking dynamic sites is an important feature of Google Analytics, as it lets you see just how users move through a site, helping you optimise eCommerce paths. PHP-generated dynamic content needs a slightly different approach; instead of using JavaScript in your page templates, you’ll need to save the tracking code as a separate PHP page, which you can then use with a PHP include statement to drop into your pages – though here it goes at the start of the tag rather than the end of the tag.

If you choose the Custom option then you can use the sample code in the editing window to create your own tracking script. If you need to start from scratch at any time just click the Clear changes text at the bottom of the window. All three options also let you cut and paste a pre-formatted email that can be sent to any third parties you may have working on your site.

A single Google account can manage many different site accounts, giving you one place to explore reports from all your different sites. You can also assign several users to an account, so while one might administer all your Google Analytics sites, reports can be accessed by users with specific responsibilities. Agencies will find this approach particularly useful, setting up a master account for the company and then giving users access to the reports they need for the clients they work with, without seeing the reports used for other sites.

The Metric System

It’s no good having analytics tools attached to a site if you don’t know what you’re looking for! You can measure everything, and anything, but without understanding what each metric is, and what it means for your site, it might just as well be random noise.
Once you’ve set up a site for tracking, you can go to the Home tab for the account. You’ll see a basic dashboard, with the initial metrics for your site – though there won’t be much on a first visit, as Google Analytics only tracks data from the time you’ve added the tracking code to a page/site. The basic dashboard gives you a quick overview of the last month’s traffic, showing daily visits, the average time spent on your site by a visitor, the key sources of traffic, and where visitors are coming from (as well as how long each country spends on your site). You also get to see what proportion of visits come from mobile devices.

Each widget on the dashboard graphs a different metric and you can click in to get a fuller report. It’s a good idea to build your own custom dashboard, pulling in the metrics you want to use. We’d recommend starting with the Google Analytics Standard Reporting view. Click through to see the key audience metrics for your site: visits, unique visitors, pageviews, pages/visit, average time on site, bounce rate and new visits. Sparklines give you an immediate overview of the trend for each of these metrics. Google defines them as:

• Visits: The total number of visits to your page. If a user is inactive for half an hour or more, any future activity is treated as a new session (visit)
• Pageviews: How many times the pages on your site have been viewed
• Pages/visit: This shows how many pages users view when they come to your website
• Bounce Rate: This shows the percentage of users that left after viewing only one page on your site
• Average Time on Site: This indicates how long each user spent on your site
• New Visits: This shows the percentage of your users that have not visited the site before.

You can change the date range for the various graphs and also opt to compare different date ranges – helping you see the effects of a new site design or your latest advertising campaign. Indeed, that’s one of the most important features of Google Analytics – the ability to compare sections of data.

Not all sites are HTML, of course, and Google has tools for tracking more than just standard page content. You can use scripts to track events or virtual pageviews for downloads (so you can track content in PDF form), while other tools also handle outbound links from your site (so you can track the users you’re handing over to partners, for example, as part of a revenue sharing deal). You’re also able to use scripts and libraries to track inside Flash movies or eCommerce shopping carts.

The Tracker Snippet
We take a closer look at the code you need to attach the Google Analytics tracking capabilities to your website

The tracking snippet required when attaching Google Analytics to your website really centres around ten key lines of code. Previously this was inserted into theof the page, however it must now be placed just before the closingtag. This new method facilitates asynchronous tracking of a page and therefore leverages asynchronous syntax via the _gaq object. This is essentially a command queue that accepts API calls for when Google Analytics (specifically ga.js) is ready to perform them. The _gaq.push() method, which often appears in the first part of the snippet, is therefore used to invoke various methods. These are not essential, but are most useful when telling GA to handle certain search keywords or other search engines when compiling reports. Below we break down the basic listing and some optional statements, but first we underline a few key tips for adding it to your pages:

• The tracker snippet should go just before
the closing tag
• Other scripts should be placed before the tracker snippet within the for optimum performance
• Google Analytics only tracks pages that contain the tracker snippet. Copy and paste into each section or use includes
• Place the tracker snippet within header.php for WordPress-based websites
• You must add your assigned Google Analytics web property ID, obtained during the initial registration phase.

 003 script type=”text/javascript"
 004 var _gaq = _gaq || [];
 005 //Below, where X requires your Google Analytics web property ID
 006 _gaq.push([‘_setAccount’, ‘UA- XXXXXXX-X’]); 007
 008 //Optional statements (see below) would go here 009
 010 //Main logic for GATC (Google Analytic Tracker Code)
 011 _gaq.push([‘_trackPageview’]);
 013 (function() {
 014 var ga = document.createElement(‘script’); ga.type = ‘text/ javascript’; ga.async = true;
 015 ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘ ga.js’; var s = document. getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
 016 })();
 017 /script

Optional Statements

Alongside the basic snippet, there’s a series of asynchronous methods used to pass certain parameters that dictate how GA interprets certain data. These are largely concerned with how associated search keywords, engines and sister sites are fed into the reports.
Often you’ll want to include discernible search attempts to access your pages as direct traffic as opposed to generic keywords, while access via an associated sister website (perhaps within the same organisation) is again classified as direct rather than referred.

Add methods

001 //Example asynchronous method for _ addIgnoredOrganic() for defining terms as direct traffic but excluded from Keywords reports
 002 _gaq.push([‘_addIgnoredOrganic’, ‘web designer magazine’]);
 03 _gaq.push([‘_addIgnoredOrganic’, ‘web designer’]);
 004 _gaq.push([‘_addIgnoredOrganic’, ‘’]); 005
 006 //Used to exclude a source as a referring site, treated instead as direct traffic
 007 _gaq.push([‘_addIgnoredRef’, ‘’]);
 008 //Adds search engine to be included as new organic source where newOrganicSource is the engine, newOrganicKeyword the Keyword name, opt_prepend a boolean value for adding engine to the engine to the beginning of the organic list if true, or the end if false (default)
 009 _gaq.push([‘_addOrganic’, ‘newOrganicEngine’, ‘newOrganicKeyword’, ‘opt_prepend’]);

Clear methods

001 //Clears strings previously set for exclusion from Keyword reports
 002 _gaq.push([‘_clearIgnoredOrganic’]);
 003 //Clears items previously set for exclusion from Referring Sites report
 004 _gaq.push([‘_clearIgnoredRef’]);
 005 //Clears all search engines as organic sources
 006 _gaq.push([‘_clearOrganic’]);