, I had the opportunity to work with Google Analytics, a powerful platform for tracking and understanding user behaviour across an e-commerce website that sells clothing.
My task was to build a data pipeline that exports GA4 data to BigQuery, a Google Cloud data warehouse. However, I quickly ran into a common issue: many of the available guides were outdated or inconsistent, which made the process more time-consuming than expected.
In this article, I’ll walk you through a clear and up-to-date overview of Google Analytics, explain its key concepts, highlight the most important reports, and show you a working example of how to export GA4 data using the Google Analytics Data API with Python.
Curious to see what GA4 can do for you? Let’s dive in!
Table of Contents:
- Life Cycle of Google Analytics
- Dimensions and Metrics
- Explore Core Reports of GA4
- Explore Data API
Life Cycle of Google Analytics
Google Analytics allows to understand the different stages of the customer journey, offering valuable insights at each step.
It begins with the Acquisition, where you attract users and spark user interest in your business. This stage focuses on channels and strategies that bring the customer to your website or app.
Next is Engagement, which looks at how users interact with your content or products. For example, they might browse pages, watch videos, or add items to their shopping cart.
Then comes Monetization and Retention, which are part of the most critical phase. Monetization phase allows to understand where users make purchases, turning them into customers, whereas Retention measures how often users return, helping to assess long-term satisfaction and loyalty.
By analyzing each stage of the journey, it’s possible to identify what’s working, uncover areas for improvement and make smarter and data-driven decisions to boost the brand’s performance.
Dimensions and metrics
Before going further, it’s important to understand a fundamental concept in Google Analytics: every report is built using dimensions and metrics. Understanding how dimensions and metrics work together is essential for interpreting reports and turning data into meaningful information.
Dimensions
Dimensions are qualitative attributes that group your data. The core dimensions are:
- Campaign is a paid promotion or Marketing campaign
- Source is where the user came from. For instance, it can be from a website or a social network like Instagram and Facebook.
- Medium is the general category of the traffic source, such as organic, CPC and referral.
- Channel is a rule-based group of traffic sources, mediums, or other rules to separate traffic. Examples of channels are Organic Search, Paid Search and Social.
Metrics
On the other hand, metrics contain quantitative values. The most important metrics are:
- Active users are people who engage with the site or app
- New users are people who visit the site or app for the first time
- Returning users are people who have visited previously
- Sessions are groups of user interactions within a given time frame
- Engaged Sessions are sessions lasting at least 10 seconds
- Event is any tracked user action, like clicking, scrolling and visiting for the first time
- Key event is a significant action that contributes to business goals, such as a purchase or a sign-up
- Total revenue is the income from purchases, subscriptions, and advertising
Start to play with Google Analytics

Once you are familiar with the key concepts of Google Analytics, it’s time to put them into practice on the platform itself. A great starting point is Google’s introduction course to Google Analytics, which provides access to a free demo account. This account allows you to explore real-world data and experiment with the platform’s features.
In this tutorial, we’ll use Google Analytics to explore and analyse the data from the Google Merchandise Store, an online store that sells Google-branded products. It’s a perfect sandbox for learning how to track user behaviour, monitor performance, and gain actionable insights. You can access the Google Analytics demo account using this link. You should see a page like the screenshot below.

These are pages that are going to be explored:
- General overview
- Acquisition overview
- Engagement overview
- Monetisation overview
- Retention overview
General Overview

The first page you’ll see is the home page, which provides a high-level summary of user behaviour on the Google Merchandise Store. It highlights key performance indicators, such as Active users, Key events, Total event count and Purchases. These metrics offer a quick overview of how users are engaging with the website or app and how well it’s performing.
To view the metrics in real-time, click the Reports button and select Real-time overview. This feature gives a live snapshot of current user activity, making it easy to monitor what’s happening on the website as it occurs.

At the top of the Real-time Overview report, you’ll find key performance indicators, including the number of active users in the last 5 and 30 minutes. Below, a series of tables provide a detailed breakdown of user activity, showing:
- Where users are coming from. It can be measured by metrics like source, medium and channel.
- Demographic and geographic data can help to understand who the users are.
- What content they are viewing. Examples of content are page titles and screen names.
- What actions they are taking.
- Which key events they complete.
Acquisition Overview

The acquisition report is a valuable tool for understanding where users and traffic are coming from. At the top, you’ll find KPIs like Active users and New users, giving a snapshot of user activity. Just below the KPIs, different tables provide specific details of how users are arriving at the website.
Within the overview section, there are two detailed reports. The first report is the user acquisition report, which focuses on campaign source and medium that we see from that user. Next is the traffic acquisition report, which concerns session source, session medium and session campaign.
Engagement Overview

While the acquisition report answers the question “Where are Users and traffic coming from?”, the engagement report helps to understand how users are interacting with the site or app.
Key Performance Indicators in this report include the average engagement time per active user, the average engaged session count per active user, the number of page views (for website) or screen views (for app), and the count of events.
Below KPIs, two main tables provide high-level details of user activity. The table grouping data by event name shows what users are doing on the website or app. Common events are viewing a web page, beginning a session or seeing a promotion banner or offer. The other table segments the data by page title and screen class allowing us to understand which pages people are staying on the longest or the most viewed pages.
Monetization Overview

Now, we have the Monetization overview which presents high-level metrics to quantify revenue. These include total revenue, total revenue from purchases and the total revenue from advertising.

To dive deeper into sales performance, you can explore the e-commerce purchase report. This report contains a table broken down by item name, allowing us to see which products are the most profitable, viewed, added to the cart or purchased.
From the table, the Super G Quilt Socks stand out as the most performing items with the highest revenue.
Retention Overview

Finally, there is the retention overview report that gives an idea of how well the website or app retains users over time. Key performance indicators include the total number of new users and the total number of returning users.
One of the most useful features of this report is the User Retention visualisation that shows how frequently users return after their initial visit. For instance, it answers questions like “How many users who first visited on a specific date (date 0) came back in the following days?”.
This report is essential for evaluating user loyalty and long-term engagement, helping to identify trends and improve strategies to keep users coming back.
Explore Data API
Now that we understand how the reports are structured, let’s take a step further and see how to export data using the Google Analytics Data API.
Set up Data API
Before writing any code, we need to complete a few setup in Google Cloud Console:
- Create a new project or select an already existing one
- Enable the “Google Analytics Reporting API” for your project
- Create a service account, generate the credentials and download the JSON file.
For deeper details, I recommend this YouTube video, which helped me a lot with Google Cloud Console setup.
After we must find the property ID, which is needed in the code later. This time we need to visit Google Analytics, press Admin from the menu and select Property Details. Just copy and paste the property ID in your code.
The last step consists of installing the necessary Python libraries:
pip install google-analytics-data==0.18.18
pip install google-auth-oauthlib==1.2.2
Export report Data using Data API
Once the setup is complete, we can use the Google Analytics Data API to download the report data with Python. Let’s say we want to export a report showing active users and new users, broken down by date. In this case:
- Metrics:
activeUsers
,newUsers
- Dimensions:
date
To find the correct field names for dimensions and metrics used by Data API, refer to the official GA4 API reference. It includes comprehensive tables for each.
Now, it’s time to show an example of code to export the data. First, we instantiate the analytics data client. Then, we define the report request with the dimensions, metrics and date range. Finally, we can execute the report request.
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import (
DateRange,
Dimension,
Metric,
RunReportRequest,
)
PROPERTY_ID = "your-property-id"
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "your-path-to-json-file"
client = BetaAnalyticsDataClient()
request = RunReportRequest(
property=f"properties/{property_id}",
dimensions=[Dimension(name="city")],
metrics=[Metric(name="activeUsers"),Metric(name="newUsers")],
date_ranges=[DateRange(start_date="2024-01-01", end_date="yesterday")],
)
response = client.run_report(request)
To convert the API response into a pandas Dataframe, we need some other lines of code:
# Extract column headers
headers = [header.name for header in response.dimension_headers] + \
[header.name for header in response.metric_headers]
# Extract rows
rows = []
for row in response.rows:
row_data = [dimension_value.value for dimension_value in row.dimension_values] + \
[metric_value.value for metric_value in row.metric_values]
rows.append(row_data)
# Create a DataFrame
df = pd.DataFrame(rows, columns=headers)
That’s great! We have successfully retrieved the report data from Google Analytics using the Data API.
Final thoughts:
This was an overview of Google Analytics, its core reports and Data API. With these tools, you can gain a deeper understanding of where users are coming from, how they engage with your content, which products are performing well and how effectively your site is retaining visitors over time.
However, it’s worth noticing a few limitations of the Data API. There may be discrepancies between the API and the GA4 User Interface due to data processing delays. Google Analytics interface can update even previous day’s data after a short lag. Moreover, Google Analytics sometimes applies data sampling, especially on large datasets, which may lead to mismatches when comparing results with the raw API output.
Despite the challenges, getting started with Google Analytics is a valuable step toward making data-informed decisions. I hope this tutorial offered a clear and practical starting point to begin with confidence. Thanks for reading! Have a nice day!
Useful resources: