How Google Analytics collects data from a website?
First of all, you need to add a JavaScript tracking code to every web page of your website, that’s how GA can start to track each user interaction that occurs on your website.
- Users make actions on your website, eg: click a button, open a form, leave a comment, etc.
- Every action of users is a “hit”, Google Analytics tracking code will send all the hits data to the Google Analytics platform. This is how the hit looks like in the URL.
- GA platform will read user’s information through the complex URL string:
- user’s language
- the name of the page
- the screen resolution of the user’s device
- the Analytics account ID
- user’s location
- the browser and operating system
- their age and gender
- the source that referred them to a site
- GA platform will process these data, together with additional data from other channels, then generate a report.
How to measure a hit?
There are a lot of hit types, the three most common types are: pageview hits, event hits, transaction hits.
Pageview hits
As long as the user visits a webpage with the tracking code, GA will count it as a pageview hit.
Event hits
Once a user interacts with an element on your website, GA will count it as an event hit. For example, if you add a code on a video play button, once the user clicks the button, GA will count it in a separate category in the report.
Event hits pass four parameters of data in the URL: event action, category, label, and value.
Transaction hits
It’s particular for an eCommerce shop, you can keep tracking the shop purchases such as products purchased, stocks, etc.
Social hits
It can be used to collect likes, shares, or tweet data on social media platforms.
All types of hits then will make up your reports in Google Analytics.
How does Google Analytics process data?
1. Determine new users or returning users
When a user visits a page with a tracking code, Google Analytics creates a random, unique ID that gets associated with the user’s browser cookie.
- Every time a new ID is detected, Google Analytics counts a “new user”.
- When Analytics detects an existing ID, users will be counted as a “returning user”.
If a user clear or blocked his cookie, Google Analytics will consider that user as a new user even if he visited the website before.
As long as the sessions happen in the same browser on the same device, Google Analytics can identify users over multiple sessions.
If users visit your website from different devices, Google Analytics will consider them as different users. If you wish to track users across devices, you need to set up the User ID feature.
2. Categorize hits into session
Next steps, Google Analytics will group user hits based on the time, this metric is called “sessions.”
- A session begins: when a user visits a web page.
- A session ends: if no other hits are recorded after 30 minutes. The 30 minutes can be changed in the GA platform based on your needs.
If the user returns to a page after a session ends, a new session will begin.
- For example, if a user visited the homepage of the Digital Marketing Ted and then left after 10 minutes without clicking on anything. That’s one pageview hit in one session.
- If a user visited the homepage of the Digital Marketing Ted, then the user clicks the video play button. That’s one pageview hit and one event hit in one session.
- If a user visited the homepage of the Digital Marketing Ted, then open a new tab to view another website for more than 30 minutes, and then go back to the Digital Marketing Ted page to click the video play button. That’s one pageview hit and one event hit in two sessions.
Once Google Analytics has organized data by session, it will show up in your reports. That’s where the metric come from, such as sessions, pages per session, average session duration, and bounce rate.
3. Joins data with other data sources
- Google Analytics can link from other Google marketing tools like Google Ads, AdSense, or the Google Search Console. That allows you to check some Google Ads data (clicks, cost data, etc.) on the Google Analytics platform.
- The measurement protocol allows you to send data from any web-connected device like point-of-sale systems to Google Analytics. However, you must pass the data collection hits manually in a URL string.
Data configuration rules
Google Analytics will collect data, and you can tell GA how to process them by using data filters, goals, custom metrics and dimensions, etc.
Data Filters
You can set a filter to exclude some data during the processing, for example, you can exclude the traffic from your home or company to get a more accurate report.
The filter is essentially rules applied to the data, if the filter type is true, means GA will apply this rule. if the filter type is false, then GA won’t apply the filter.
Under the below common situation, you may need to apply filters.
- Transform the data that shows up. For example, you want to include data from certain countries.
- Exclude the data that shows up. Like we mentioned if you want to exclude any internal traffic.
Goals
Let’s find out what kind of data you want GA to collect. There are four types of Goals in Google Analytics:
- Destination or Pageview Goals: A user views a particular page on your website.
- Event Goals: A particular action defined as an event is triggered.
- Duration Goals: The sessions that last over a set amount of time.
- Pages or Screens per Session Goals: Whether a user has viewed a set amount of pages in a session.
A conversion is counted once per session per configured goal. For example, if you’ve defined an Event goal of clicking the video play button, and the user clicks the button 3 times in one session, it’ll be counted as one conversion.
When Analytics detects hit data for a goal, it calculates below elements in your report:
- the goal completions
- goal value (if you’ve indicated)
- goal conversion rate
Custom Dimensions and Metrics
After you tell GA how to collect data, and what kind of data you need, the next step is to tell GA how you want to organize the data. Besides the standard report, you can also create a customized report:
- Channel Groupings allows you to organize your data into customized channels
- Content Grouping allows you aggregate metrics within reports
Custom Dimensions help you define a group of metric data that’s specific to your business, it can be used as a secondary dimension in standard reports, a primary dimension in a Custom Report, or as a segment.
Custom Metrics can be collected for any standard dimension or Custom Dimension that can’t be measured by any predefined metric in Google Analytics.
You can also upload your own data to Google Analytics including hit data, extended data. This kind of data usually is exported from an offline business tool like a content management system or customer relationship management system.
You need to set up the configuration rules before the data is processed, as data can’t be retroactively applied configuration.
Generate reports
Once you set up the rules of your data configuration, Google Analytics will generate the report accordingly.
All Google Analytics reports only have one dimension and the corresponding metrics. Most reports in Analytics use rows for dimensions and columns for the associated metric data.
Analytics calculates the metrics that get grouped in various dimensions in two ways:
- Metrics are calculated in aggregates such as total sessions, users, or page views
- Metrics are calculated in specific dimensions such as Sessions or New Users per country.
Several key metrics are calculated as:
- Time on Page: the timestamp of a pageview hit – the timestamp of the next pageview hit.
- Pages per session: the average of how many unique pageviews hits the user-generated during their session.
- Average session duration: the average time spent from the first hit until the last hit before a user leaves the site or the session times out.
- Bounce rate: calculated by looking at users who only had one interaction on your site without a second interaction during the session. If this occurs, the pageview of a bounced visit is assigned a session duration and Time on Page of zero.
Once you create custom dimensions and metrics, Google Analytics will process the data accordingly.
Dimensions and metrics have one of three scopes:
- hit-level
- session-level
- user-level
You can only pair metrics with dimensions if they are both in the same scope.
For example, since “Page Title” changes with each hit, but the “sessions” count changes with the completion of each session. There is no point to pair Page titles and sessions.
You’ll need to manually set the scope for any Custom Dimensions or Custom Metrics you create.
You can also create secondary dimensions to generate your own custom report.
For standard users, session sampling occurs at the property level, not the view level. This means that the sample set will be determined at the property level before view-level filters are applied. So views that have filters applied may have fewer sessions in the sampled calculation.
For Analytics 360 customers, sampling occurs at the view level, so view filters won’t impact the sample size.
Noted that when data is collected and processed, it can’t be changed. For example, if you set a filter to exclude data on a view, that data will be permanently removed during processing from the reports in that view and cannot be recovered.
Make a measurement plan
It’s better to take some time to think about the below questions:
- What is your main business objectives – measured as macro conversions
- What kind of strategy can help you achieve your main objectives
- What are smaller goals to make your strategy work – measured as micro conversions
I’ll give you some examples of macro and micro conversions:
- For an E-commerce site: macro-conversion could be to purchase a product, micro-conversion could be the subscription of newsletters.
- For a lead generation site: macro-conversion could be filling out a contact form, micro-conversion could be the engagement on the website.
- For a content publisher: macro-conversion could be engaging with a particular amount of content, micro-conversion could be the amount of click into an article.
Once you’ve defined your macro- and micro-conversions, you can start marketing a measurement plan to help you achieve your business objectives:
- An overall business objective
- Multiple strategies that support that objective
- Tactics that will help you achieve your strategies. Each tactic will have key performance indicators (or KPIs) that help you measure macro- and micro-conversions.