How Google Analytics collects data
Hi, I’m Justin Cutroni. And I’m Krista Seiden. We’re Analytics Advocates at Google. Welcome to Advanced Google Analytics. If you’ve already taken our course Google Analytics for Beginners, you should be well prepared to take this next step in your understanding of Analytics.
Website data collection
The Analytics tracking code uses the domain of the website you are tracking to define it as a “site” in your reports. With the tracking code installed, Google Analytics will drop a cookie in the user’s browser for that website and any related subdomains. This makes it easy to track traffic on a single website URL domain or subdomain by default.
Note that if you install the same default tracking code on pages with different domains, Analytics will count these users and sessions separately. If you need to track users across different domains, you will need to set up cross-domain tracking, which we’ll discuss later.
Anatomy of a "hit"
With each user interaction on your website, the Analytics tracking code sends what’s called a “hit” to Google Analytics. A “hit” is a URL string with parameters of useful information about your users. It looks something like this:
If we break down the URL string, you can see that it’s passing some useful information to Analytics about the user that triggered the hit. For example, we can see things like:
- the language the user’s browser is set to
- the name of the page they’re viewing
- the screen resolution of the user’s device
- and the Analytics ID that associates that hit to the correct Analytics account.
This is just some of the information passed in the hit, depending on the user interaction with the site and what is being tracked. The hit will also include other information like a randomly-generated user identifier. This will allow Google Analytics to differentiate between new and returning users.
The three most common types of hits are:
- “pageview” hits
- “event” hits
- and “transaction” hits
A “pageview” hit is triggered when a user loads a webpage with the tracking code. This is the most common type of hit sent to Analytics. Every time a user opens a page with the tracking code, a new pageview hit will be sent.
An “event” hit lets you track every time a user interacts with a particular element on your website. For example, you can track whether users click a video Play button, a particular URL, or a product carousel. Event hits pass four parameters of data in the URL: event action, category, label, and value. You can use these to categorize interactions in reports that are specific to your website. We’ll go into more detail on event tracking a little later.
A “transaction” hit (also called an “ecommerce” hit) can pass data to Analytics about ecommerce purchases such as products purchased, transaction IDs, and “stock keeping units” (or SKUs).
If you’ve set up Enhanced Ecommerce within Google Analytics, you can also pass additional ecommerce data like product category, whether items have been added or removed from a shopping cart, and how many times users viewed a product on a website.
There are additional hits such as “social hits” that can pass likes, shares, or tweet data; and “page timing hits” that allow you to report on page timings, but the Pageview, Event, and Transaction hits are the three most common.
We’ve discussed some of the information passed in hits such as Language and Page Title. But Google Analytics widens that data using other sources such as IP address, server-log files, and other ad-serving data. Using this additional information, Analytics can understand things like:
- a user’s location;
- specifics about their browser, operating system and service provider;
- their age and gender;
- and the source/medium that referred them to a site.
You’ll recognize many of these parameter names passed in the hit or widened with additional data because they get turned into the dimensions that make up your reports in Google Analytics. Remember that dimensions are just ways to categorize metric data like all the metrics for a specific “country” or “device type.”
Once the hit is sent to Google Analytics and combined with additional data, all of this information is ready for processing by the Analytics servers. Understanding how Analytics collects and processes data can help you better understand your reports and what the data means.