How Google Analytics collects data

Introduction

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

Let’s start by showing you some specifics on how Google Analytics collects data. Remember that website data collection begins with a snippet of JavaScript tracking code that’s included on every web page of the site where you want to collect data. The goal of the tracking code is to track each user interaction that occurs on your website. These interactions can be as simple as loading a page or something more specific like clicking a video play button or a link.

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 and operating system;
  • 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.

Was this helpful?

How can we improve it?
true
Choose your own learning path

Check out google.com/analytics/learn, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

Search
Clear search
Close search
Main menu
17512109208927166199
true
Search Help Center
true
true
true
true
true
69256
false
false