, I had the chance to work with Google Analytics, a strong platform for monitoring and understanding person behaviour throughout an e-commerce web site that sells clothes.
My activity was to construct a knowledge pipeline that exports GA4 knowledge to BigQuery, a Google Cloud knowledge warehouse. Nonetheless, I rapidly bumped into a standard difficulty: lots of the out there guides had been outdated or inconsistent, which made the method extra time-consuming than anticipated.
On this article, I’ll stroll you thru a transparent and up-to-date overview of Google Analytics, clarify its key ideas, spotlight an important experiences, and present you a working instance of how you can export GA4 knowledge utilizing the Google Analytics Information API with Python.
Curious to see what GA4 can do for you? Let’s dive in!
Desk of Contents:
- Life Cycle of Google Analytics
- Dimensions and Metrics
- Discover Core Experiences of GA4
- Discover Information API
Life Cycle of Google Analytics
Google Analytics permits to know the completely different levels of the shopper journey, providing invaluable insights at every step.
It begins with the Acquisition, the place you entice customers and spark person curiosity in your corporation. This stage focuses on channels and techniques that convey the shopper to your web site or app.
Subsequent is Engagement, which seems at how customers work together along with your content material or merchandise. For instance, they may browse pages, watch movies, or add gadgets to their purchasing cart.
Then comes Monetization and Retention, that are a part of essentially the most important part. Monetization part permits to know the place customers make purchases, turning them into clients, whereas Retention measures how typically customers return, serving to to evaluate long-term satisfaction and loyalty.
By analyzing every stage of the journey, it’s potential to determine what’s working, uncover areas for enchancment and make smarter and data-driven choices to spice up the model’s efficiency.
Dimensions and metrics
Earlier than going additional, it’s essential to know a elementary idea in Google Analytics: each report is constructed utilizing dimensions and metrics. Understanding how dimensions and metrics work collectively is crucial for deciphering experiences and turning knowledge into significant info.
Dimensions
Dimensions are qualitative attributes that group your knowledge. The core dimensions are:
- Marketing campaign is a paid promotion or Marketing marketing campaign
- Supply is the place the person got here from. As an illustration, it may be from an internet site or a social community like Instagram and Fb.
- Medium is the final class of the visitors supply, comparable to natural, CPC and referral.
- Channel is a rule-based group of visitors sources, mediums, or different guidelines to separate visitors. Examples of channels are Natural Search, Paid Search and Social.
Metrics
However, metrics include quantitative values. Crucial metrics are:
- Energetic customers are individuals who interact with the positioning or app
- New customers are individuals who go to the positioning or app for the primary time
- Returning customers are individuals who have visited beforehand
- Periods are teams of person interactions inside a given timeframe
- Engaged Periods are classes lasting not less than 10 seconds
- Occasion is any tracked person motion, like clicking, scrolling and visiting for the primary time
- Key occasion is a big motion that contributes to enterprise objectives, comparable to a purchase order or a sign-up
- Whole income is the revenue from purchases, subscriptions, and promoting
Begin to play with Google Analytics

As soon as you might be accustomed to the important thing ideas of Google Analytics, it’s time to place them into observe on the platform itself. An important start line is Google’s introduction course to Google Analytics, which supplies entry to a free demo account. This account permits you to discover real-world knowledge and experiment with the platform’s options.
On this tutorial, we’ll use Google Analytics to discover and analyse the info from the Google Merchandise Retailer, an internet retailer that sells Google-branded merchandise. It’s an ideal sandbox for studying how you can monitor person behaviour, monitor efficiency, and acquire actionable insights. You’ll be able to entry the Google Analytics demo account utilizing this link. It is best to see a web page just like the screenshot under.

These are pages which might be going to be explored:
- Basic overview
- Acquisition overview
- Engagement overview
- Monetisation overview
- Retention overview
Basic Overview

The primary web page you’ll see is the house web page, which supplies a high-level abstract of person behaviour on the Google Merchandise Retailer. It highlights key efficiency indicators, comparable to Energetic customers, Key occasions, Whole occasion depend and Purchases. These metrics supply a fast overview of how customers are partaking with the web site or app and the way properly it’s performing.
To view the metrics in real-time, click on the Experiences button and choose Actual-time overview. This characteristic provides a dwell snapshot of present person exercise, making it simple to watch what’s taking place on the web site because it happens.

On the prime of the Actual-time Overview report, you’ll discover key efficiency indicators, together with the variety of lively customers within the final 5 and half-hour. Beneath, a collection of tables present an in depth breakdown of person exercise, displaying:
- The place customers are coming from. It may be measured by metrics like supply, medium and channel.
- Demographic and geographic knowledge may help to know who the customers are.
- What content material they’re viewing. Examples of content material are web page titles and display names.
- What actions they’re taking.
- Which key occasions they full.
Acquisition Overview

The acquisition report is a invaluable device for understanding the place customers and visitors are coming from. On the prime, you’ll discover KPIs like Energetic customers and New customers, giving a snapshot of person exercise. Just under the KPIs, completely different tables present particular particulars of how customers are arriving on the web site.
Inside the overview part, there are two detailed experiences. The primary report is the person acquisition report, which focuses on marketing campaign supply and medium that we see from that person. Subsequent is the visitors acquisition report, which considerations session supply, session medium and session marketing campaign.
Engagement Overview

Whereas the acquisition report solutions the query “The place are Customers and visitors coming from?”, the engagement report helps to know how customers are interacting with the positioning or app.
Key Efficiency Indicators on this report embrace the common engagement time per lively person, the common engaged session depend per lively person, the variety of web page views (for web site) or display views (for app), and the depend of occasions.
Beneath KPIs, two important tables present high-level particulars of person exercise. The desk grouping knowledge by occasion title exhibits what customers are doing on the web site or app. Frequent occasions are viewing an online web page, starting a session or seeing a promotion banner or supply. The opposite desk segments the info by web page title and display class permitting us to know which pages persons are staying on the longest or essentially the most considered pages.
Monetization Overview

Now, we now have the Monetization overview which presents high-level metrics to quantify income. These embrace whole income, whole income from purchases and the full income from promoting.

To dive deeper into gross sales efficiency, you possibly can discover the e-commerce buy report. This report comprises a desk damaged down by merchandise title, permitting us to see which merchandise are essentially the most worthwhile, considered, added to the cart or bought.
From the desk, the Tremendous G Quilt Socks stand out as essentially the most performing gadgets with the very best income.
Retention Overview

Lastly, there may be the retention overview report that provides an concept of how properly the web site or app retains customers over time. Key efficiency indicators embrace the full variety of new customers and the full variety of returning customers.
One of the helpful options of this report is the Person Retention visualisation that exhibits how often customers return after their preliminary go to. As an illustration, it solutions questions like “What number of customers who first visited on a selected date (date 0) got here again within the following days?”.
This report is crucial for evaluating person loyalty and long-term engagement, serving to to determine developments and enhance methods to maintain customers coming again.
Discover Information API
Now that we perceive how the experiences are structured, let’s take a step additional and see how you can export knowledge utilizing the Google Analytics Information API.
Arrange Information API
Earlier than writing any code, we have to full just a few setup in Google Cloud Console:
- Create a brand new challenge or choose an already current one
- Allow the “Google Analytics Reporting API” on your challenge
- Create a service account, generate the credentials and obtain the JSON file.
For deeper particulars, I like to recommend this YouTube video, which helped me lots with Google Cloud Console setup.
After we should discover the property ID, which is required within the code later. This time we have to go to Google Analytics, press Admin from the menu and choose Property Particulars. Simply copy and paste the property ID in your code.
The final step consists of putting in the required Python libraries:
pip set up google-analytics-data==0.18.18
pip set up google-auth-oauthlib==1.2.2
Export report Information utilizing Information API
As soon as the setup is full, we are able to use the Google Analytics Information API to obtain the report knowledge with Python. Let’s say we wish to export a report displaying lively customers and new customers, damaged down by date. On this case:
- Metrics:
activeUsers
,newUsers
- Dimensions:
date
To seek out the right subject names for dimensions and metrics utilized by Information API, discuss with the official GA4 API reference. It contains complete tables for every.
Now, it’s time to point out an instance of code to export the info. First, we instantiate the analytics knowledge shopper. Then, we outline the report request with the size, metrics and date vary. Lastly, we are able to execute the report request.
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.varieties import (
DateRange,
Dimension,
Metric,
RunReportRequest,
)
PROPERTY_ID = "your-property-id"
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "your-path-to-json-file"
shopper = 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 = shopper.run_report(request)
To transform the API response right into a pandas Dataframe, we’d like another strains 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 nice! We’ve efficiently retrieved the report knowledge from Google Analytics utilizing the Information API.
Ultimate ideas:
This was an outline of Google Analytics, its core experiences and Information API. With these instruments, you possibly can acquire a deeper understanding of the place customers are coming from, how they interact along with your content material, which merchandise are performing properly and the way successfully your web site is retaining guests over time.
Nonetheless, it’s value noticing just a few limitations of the Information API. There could also be discrepancies between the API and the GA4 Person Interface as a result of knowledge processing delays. Google Analytics interface can replace even earlier day’s knowledge after a brief lag. Furthermore, Google Analytics typically applies knowledge sampling, particularly on giant datasets, which can result in mismatches when evaluating outcomes with the uncooked API output.
Regardless of the challenges, getting began with Google Analytics is a invaluable step towards making data-informed choices. I hope this tutorial supplied a transparent and sensible start line to start with confidence. Thanks for studying! Have a pleasant day!
Helpful sources: