How Does Google Analytics Collect Information?

It uses the tracking code, of course! But there’s more to it than that. The latest version of Google Analytics (GA) – Universal Analytics – utilizes what is known as the Measurement Protocol to request, compile, and send the information to GA.

The Tracking Code

The first step is adding tracking code to your page. This post assumes you already have Google Analytics on your page, either through adding the JavaScript snippet to every page, or using a Google Analytics tag through Google Tag Manager.

When the tracking code loads on the page, a hit is generated and then sent to Google Analytics. This hit gathers all of the known information about the user at that exact moment in time – a snapshot of information. This information is transmitted every time a hit is sent to GA. This means every time a transaction is made, every time an event is triggered, and every time a page is viewed a new snapshot about what is happening is compiled and sent to GA.

What Can You Track with Google Analytics?

By default, this Google Analytics hit captures data like:

  • Page Information
    • URL – the URL of the page the user is viewing
    • Title – the title of the page the user is viewing
  • Browser Information
    • Browser name – the browser the user is using
    • Viewport or Viewing pane – the size of the browser window
    • Screen resolution – the resolution of the user’s screen
    • Java enabled – whether or not the user has Java enabled
    • Flash version – what version of Flash the user is using
  • User Information
    • Location – this is derived from the IP address where the hit originated. The IP address itself is not available in GA as it is personally identifiable information (PII) which violates the terms of Google Analytics.
    • Language – derived from the language settings of the browser

Remember, the hit sends a snapshot of information at a given time. So if the user changes the size of the viewport mid-session, GA would only know about the change if the user then triggered an event or viewed another page. If the user changed the size of the viewport and then left the page without firing another hit, GA would have no way of knowing.

Customizing Information

The default information from Google Analytics gives you information about the page, the browser, and the user – but you aren’t limited to this basic user information! If we know more about the page or the user, we can customize the information we send in order to collect more comprehensive data. Or, if there are other actions that can occur on a page, we can track that as well.

For example, we can store:

  • Custom dimensions and metrics
  • Event information – We can track actions on the page and record them in Google Analytics
  • User IDs – as long as they do not include any PII
  • Virtual pageviews – if the page doesn’t change but the user has done something you want to observe. For example: forms that have multiple steps can take place on the same page without changing the path. If you want to see users navigate through a form like this, you could fire virtual pageviews each time they click a button to move to the next section of the form.
  • Override default information – in order to make the information you capture as relevant to your site as possible and more easily understood by analysts and employees that will be looking at the GA reports
  • Completely customized data – either hard-coded JavaScript or Google Tag Manager