Medium 9780596158002

Google Analytics

Views: 1175
Ratings: (0)

Do you know what people do when they visit your website or web app? Or how much the site contributes to your bottom line? Google Analytics keeps track and makes it easy for you to learn precisely what's happening. This hands-on guide shows you how to get the most out of this free and powerful tool -- whether you're new to Google Analytics or have been using it for years.

Google Analytics shows you how to track different market segments and analyze conversion rates, and reveals advanced techniques such as marketing-campaign tracking, a valuable feature that most people overlook. And this practical book not only provides complete code samples for web developers, it also explains the concepts behind the code to marketers, managers, and others on your team.

  • Discover exactly how the Google Analytics system works
  • Learn how to configure the system to measure data most relevant to your business goals
  • Track online marketing activities, including cost-per-click ads, email, and internal campaigns
  • Track events -- rather than page views -- on sites with features such as maps, embedded video, and widgets
  • Configure Google Analytics to track enterprise data, including multiple domains
  • Use advanced techniques such as custom variables and CRM integration

List price: $23.99

Your Price: $19.19

You Save: 20%


15 Slices

Format Buy Remix

1. Introducing Web Analytics


This book is about Google Analytics, and at some level that means it is also about web analytics. Its important to note that Google Analytics is not the same as web analytics. Web analytics is a business process used to continuously improve your online business. Google Analytics is a tool to quantitatively measure what happens on your website. Just because you have Google Analytics does not mean you are doing web analytics.

Before we dive into Google Analytics, I believe its important to establish how Google Analytics should fit into your overall analytics strategy.

Rather than creating another definition of web analytics (there are a lot of them out there), I prefer to reference Avinash Kaushiks concise yet thorough definition. In his book Web Analytics: An Hour a Day (Wiley), Kaushik defines web analytics as:

The analysis of qualitative and quantitative data from your website and the competition, to drive a continual improvement of the online experience that your customers, and potential customers have, which translates into your desired outcomes (online and offline).


2. Creating an Implementation Plan


Google Analytics is a business intelligence tool and, because every business has different data needs, your implementation may be very different from someone elses. Do not believe that you can simply slap some tags on the site and collect valid data. It is very rare that an implementation involves only page tagging. There are many configuration steps required to generate accurate, actionable data.

With that said, there are some standard things that everyone should do to get reliable data for analysis. Implementing Google Analytics does take some planning and foresight. The Google Analytics support documentation does contain a rough implementation guide that includes the various steps to get Google Analytics installed and running. I have modified that process as follows:

Gather and document business requirements.

Analyze and document website architecture.

Create a Google Analytics account and configure profiles.

Configure the Google Analytics tracking code and tag website pages.


3. Under the Covers: How Google Analytics Works


Understanding the Google Analytics architecturehow it collects data, processes data, and creates reportsis the key to understanding many of the advanced topics that we will discuss later in this book. Google Analytics can collect data from a number of different platforms using different tracking technologies, which makes things complicated.

Google Analytics is no longer a simple hit collector for websites, but rather an information aggregation system that collects data from standard websites, mobile websites, Adobe Air applications, and iPhone and Android apps. Google has progressively added more data collection methods as technology has driven new and different ways of distributing content to people.

In this book, we will primarily focus on tracking websites, but I will briefly discuss the other tracking methods as well. Lets start with the simplest configuration: tracking a website.

Figure3-1 shows how Google Analytics collects, processes, and displays data.

Google Analytics uses a common data collection technique called page tags. A page tag is a small piece of JavaScript that you must place on all the website pages you want to track. We affectionately call this code the Google Analytics Tracking Code, or GATC for short. If you do not place the code on a page, Google Analytics will not track that page.


4. Tracking Visitor Clicks, Outbound Links, and Non-HTML Files


The simple implementation for tracking visitor actions, or clicks, involves adding the _trackPageview() function to an HTML tag. For example, to track a visitor click on an image, just add _trackPageview() to the onclick event of that element:

When a visitor clicks on the above image, a pageview will be created for /image.jpg. You can also use this method to track non-HTML files:

When creating pageviews for non-HTML files, try to use a consistent naming convention. This will make it easier to identify them in the reporting interface. For example, you may want to create a virtual directory structure using _trackPageview().

In the previous code example, I added /vpv/downloads/pdf/ to the value passed to _trackPageview() (vpv stands for virtual pageview). This makes it easy to identify the non-HTML files in the reports.

Outbound links are tracked in the same manner:

This outbound link will appear as /vpv/outbound/ in the reports. Again, be logical in your naming convention. By placing all outbound links in the /vpv/outbound/ directory, you can easily filter the data in the Top Content report or the Content Drilldown report.


5. Google Analytics Accounts and Profiles


Google Analytics is divided into a simple hierarchy of accounts and profiles. Many people confuse a Google Analytics account with a Google account. A Google account is a way for Google to identify you, as a person. A Google Analytics account is your instance of Google Analytics used to track websites.

Google uses an email address to identify your Google account. Some people believe that you must have a Gmail address, like, to have a Google account. This is not true. You can turn any email address into a Google account. This means that your work email address, like, can be a Google account.

Once you have a Google account, Google attaches various services to your account. These services can include Gmail, Google Docs, AdWords, etc. Google Analytics is just one service that you can associate with your Google account. If youve ever signed up for a Google service, you have a Google account. Figure5-1 represents the hierarchy of Google accounts and the Google Analytics account.


6. Filters


There is no Google Analytics concept that is more important but less understood than filters. Functionally, filters are business rules. You add them to a profile when you have a business need to modify the data in a profile. For example, it is very common to exclude website traffic generated by internal employees. This data can skew the data generated by actual customers, thus causing incorrect analysis.

You can apply multiple filters to a profile to create data that meets your needs and the needs of your organization.

The key to understanding filters is understanding how Google Analytics structures website data. I discussed this earlier in Chapter3; if you have not read that chapter, please do so.

There are two types of filters in Google Analytics: predefined filters and custom filters. Predefined filters are common filters that most people use. Google has bundled these common filters together and simplified their implementation.

Custom filters are different. You need to do all the configuration work when creating a custom filter. While it can be challenging, custom filters truly offer you advanced control over the data in your profiles.


7. Tracking Conversions with Goals and Funnels


Another common profile configuration is the creation of goals and funnels. Goals provide a way to measure conversions in Google Analytics. Hands down, specifying goals is the most important configuration step because they directly align business outcomes on your website with your Google Analytics configuration.

A conversion occurs when a site visitor completes a task on your website. Why is this important? Every website exists for a reason. It is not enough to measure traffic to your website, you want to measure how often visitors complete the tasks and processes that you create.

While it is not necessary to create any goals or funnels, it is highly recommended. How else will you measure business outcomes on your website if you do not configure goals?

A goal can be almost any visitor activity on your website. This includes viewing a specific page, spending a certain amount of time, or viewing a minimum number of pages during a visit.

Time on Site goals are triggered when a visitors visit reaches or does not reach a certain length of time on your site. Time on Site goals are useful when trying to understand if visitors are engaging with your content.


8. Must-Have Profiles


There are some filters and profiles that you should be using regardless of how you have configured Google Analytics. Each additional profile can help create segmented sets of data that can aid in analysis. Remember, you cannot create a new profile and reprocess historical data, so its best to create these profiles during the initial setup, even if you dont need them right away. As you use Google Analytics, you will become a better analyst, your data needs will change, and these profiles will become useful.

You should create several different profiles to perform different functions, such as protecting your data and controlling access.

The raw data profile should have no configuration. It should be an unmodified set of data that you can use if other profiles fail. Hopefully you will never need to use it!

The master profile should not be altered or changed. You should initially refine the data within this profile as much as possible using filters and profile settings, and once the data is considered accurate, you should not change the profile unless absolutely necessary. If you must make any changes to a master profile, test them first using a test profile.


9. Marketing Campaign Tracking


Another important part of setting up Google Analytics correctly is configuring online marketing campaign tracking. Unlike other configuration steps, you dont perform marketing campaign tracking in the Google Analytics administrative interface or on your website. Marketing campaign tracking involves changing the links used in your marketing activities. Ill discuss this more in a moment.

The reason marketing campaign tracking is so important is that, by default, Google Analytics places your visitors in three basic referral segments:

Visitors who access your site by clicking on a search engine result (both organic search and paid search)

Visitors who access your site by clicking on a link on some other website

Visitors who go directly to your website by typing the URL in their browsers

While these segments are useful, they do not identify paid marketing activities. You want to measure paid marketing activities so you can better understand if theyre successful, and you can only do this via marketing campaign tracking. Using marketing campaign tracking adds a fourth segment to the list above: campaigns.


10. Advanced Tracking Techniques


This chapter addresses common website architectures that can cause problems with the Google Analytics tracking. Remember, the technology that Google Analytics uses to track visitors, called page tagging, is based on JavaScript and cookies. So any website architecture, like multiple domain names, that affects cookies or JavaScript can interfere with tracking. You usually make most of the changes required to deal with these website configurations to your website and not Google Analytics directly.

If your website contains a small number of static HTML pages, it is very likely that this chapter will not apply to you. However, if you have a dynamic website that crosses multiple domains and subdomains, this chapter will offer valuable information about how, and why, you should configure Google Analytics.

Google Analytics can track visitors across multiple domains. This functionality is primarily used on websites that have a third-party shopping cart, but you can use this capability for other purposes. If your website traverses multiple domains, you will want to track your visitors as they move from one domain to another. If you do not track them across domains, each visitor will appear as a new visitor each time she moves from one of your websites to another. It will also be difficult to attribute conversions to different marketing activities.


11. Enterprise Implementation Considerations


There has been much debate as to whether Google Analytics is an enterprise-class web analytics tool. The simple fact is that if Google Analytics meets your reporting and analysis needs, it is a viable solution for your organization. Ive worked with many organizations that would traditionally be classified as enterprise; they are global organizations with hundreds of websites and many different types of analytics users.

When implementing Google Analytics in these types of organizations, many unique issues can arise. It can take some work to design a solution that is technically viable and meets the overall business needs of the organization. If youre dealing with an enterprise implementation, keep an eye out for these issues.

Large organizations tend to have more sites, and more sites mean more data. Collecting the data in a business-centric fashion that allows room for growth and appropriate access for users takes time and planning.

During an enterprise implementation, we usually create a series of accounts and profiles that collect and segment the data based on business logic and access needs. We create a data hierarchy that provides high-level aggregate tracking across the entire online experience (i.e., roll-up reporting) and detailed tracking for each individual property (i.e., website).


12. CRM Integration


You can use the data stored in the Google Analytics tracking cookies in other applications. After all, the cookies are standard first-party cookies that can you can access using JavaScript or server-side application code. One popular way to use Google Analytics cookie data is with a Customer Relationship Management (CRM) system.

What kind of data can we get from the Google Analytics cookies? Marketing data, custom variable data, and visit history data.

Google AnalyticsCRM integration involves extracting the cookie data and adding it to a lead generation form. When the visitor submits the form, the Google Analytics cookie data (which is marketing data, custom segment data, and visit history data) is connected to other information that the individual provides (usually her name and other contact information). Knowing the marketing message that an individual responds to is a valuable piece of information for a sales team.

Direct CRM integration depends on the CRM platform. Some systems allow you to pull form fields directly into the application, and some systems may have a specific Google Analytics plug-in. Check with your CRM provider for information about your specific system.


13. Tools and Add-Ons


When Google Analytics announced a standard API for extracting data, it opened the floodgates to third-party developers. The result was many different types of tools that facilitate implementation, reporting, and analysis. The response was so strong that Google created an Analytics App Marketplace to showcase tools built on the Analytics API. You can find the Analytics Application Gallery at Some of my favorite tools are listed below.

One of the strong points of Google Analytics is the reporting interface. Its intuitive, easy to use, and facilitates analysis. But sometimes you need a little something extra to get the job done. Below are a few tools that enhance the reporting capabilities of Google Analytics.

Concentrate (, from Juice Analytics, is a keyword tool that categorizes keywords to help you understand the key phrases people use to find your site. Anyone doing CPC or SEO should be using this tool.


A. Google Analytics Compliance with WAA Standards


TableA-1 includes a list of all standards defined in the Web Analytics Association (WAA) metrics definitions document and Google Analytics compliance with each definition. Google Analytics is compliant with 19 of the 26 metrics. Most of the noncompliance is due to the fact that Google Analytics does not offer all the metrics that the WAA defines. You can learn more about the WAA standards on the WAA website,

TableA-1.Google Analytics compliance with WAA standards



WAA definition

Google Analytics definition



A page is an analyst-definable unit of content.

Same as WAA.

Page view


The number of times a page (an analyst-definable unit of content) was viewed.

Same as WAA.

Google Analytics refers to this metric as the pageview.

A pageview is created each time the _trackPageview() method is executed. Any value passed to the _trackPageview() method will appear in the Content reports, thus making a page analyst-definable.


B. Regular Expressions


A regular expression (sometimes referred to as a regex) contains a mix of regular characters (like letters and numbers) and special characters that form a pattern. The pattern is applied to a piece of data and, if the pattern matches, the regular expression returns a positive result.

Many regular expressions include regular alphanumeric characters. For example, you may have a list of keywords, and you need to identify those keywords that contain goo. These three characters are a valid regular expression. Google Analytics will apply goo to the target datain this case, the keywords. If goo matches any part of the data, the regex will return a positive result. TableB-1 shows some simple patterns and gives examples of data that match.

TableB-1.Regular expressions that contain only alphanumeric characters



Example matches


Match the characters go

google, go, merry-go-round, golf


Match the characters bos

boss, boston, my boss, emboss



Print Book

Format name
File size
0 Bytes
Not Allowed
Not Allowed
Read aloud
Format name
Read aloud
In metadata
In metadata
File size
In metadata