Crash Course · Beginner → Advanced

Google Analytics 4 (GA4) Crash Course: Setup, Events, Reports and Advanced Tracking

Go from zero to confidently setting up, tracking, reading and automating Google Analytics 4 — with copy-ready code for every step.

Beginner → Advanced25 min readCode + Examples

In One Line

Google Analytics 4 (GA4): Google’s free tool that collects events from your website or app (page views, clicks, sign-ups, purchases), processes them and shows reports about who your visitors are, where they come from and what they do.

What You Will Learn

  • How GA4 works: the data flow and the Account → Property → Data stream structure
  • Core metrics: users, sessions, engagement rate, bounce rate and key events — with formulas
  • Set up an account, property and web data stream step by step
  • Install the tag three ways: gtag.js, Google Tag Manager or the Site Kit WordPress plugin
  • Verify tracking with Realtime, DebugView and Tag Assistant
  • Track custom events, purchases and key events with code
  • Measure campaigns with UTM parameters
  • Read standard reports and build explorations (funnels, paths, segments)
  • Advanced: audiences, attribution, BigQuery export, Measurement Protocol and the Data API
  • Privacy: Consent Mode v2, data retention and avoiding personal data
  • Fix the most common tracking mistakes

Core Metrics as Formulas

Engagement rate = Engaged sessions ÷ Sessions  ·  Bounce rate = 1 − Engagement rate
SessionA group of interactions by one user in a time window (ends after 30 minutes of inactivity by default).
Engaged sessionA session that lasts longer than 10 seconds, has a key event, or has 2+ page or screen views.
Engagement rateShare of sessions that were engaged.
Bounce rateShare of sessions that were not engaged (the opposite of engagement rate).
Key event rateSessions with a key event ÷ Sessions — how often visits achieve a goal.
Average engagement timeTotal engagement time ÷ active users.

Worked example: 1,000 sessions, 620 engaged → engagement rate 62%, bounce rate 38%. If 25 sessions included a purchase (key event), the session key event rate is 25 ÷ 1,000 = 2.5%.

How GA4 Works: The Data Flow

  • Collect: a small Google tag on every page sends an event (e.g. page_view) with parameters (page title, URL) to Google’s servers.
  • Process: Google groups events into users and sessions, adds traffic source, device and location, and applies your settings (filters, key events).
  • Report: processed data appears in reports and explorations — Realtime within seconds, standard reports usually within 24–48 hours.
  • Act: you use the insights to improve content, marketing and the product.
Everything is an event. In GA4 a page view, a scroll, a click and a purchase are all events: event name + parameters.

Account, Property and Data Stream

Account

Top level — usually one per company. Holds users and permissions.

Property

One per website or app (or one per product that combines web + app). Holds reports, settings, time zone and currency.

Data stream

A source of data inside a property: Web, iOS or Android. A web stream gives you a Measurement ID like G-XXXXXXXXXX.

Step 1: Create Your Account and Property

  • Go to analytics.google.com and sign in with a Google account you control long term.
  • Click Admin → Create → Account, enter the account name and choose data-sharing settings.
  • Create a Property: name, reporting time zone and currency (set these correctly — they affect daily totals and revenue).
  • Fill in business details and objectives (they decide which report collections you see first).
  • Choose platform Web, enter your site URL and stream name, and keep Enhanced measurement on.
  • Copy the Measurement ID (G-…) — you need it to install the tag.
Enhanced measurement tracks automatically, with no code: page views, scrolls (90% depth), outbound clicks, site search, video engagement (YouTube embeds), file downloads and form interactions.

Step 2: Install the Tag (3 Ways)

Option A — gtag.js directly in the <head>

Paste this immediately after the opening <head> tag on every page, replacing the ID with yours:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

Option B — Google Tag Manager (best for growing sites)

  • Create a container at tagmanager.google.com and install its two snippets (one in <head>, one after <body>).
  • Add a tag: Google Tag → paste your Measurement ID.
  • Trigger: Initialization – All Pages (or All Pages).
  • Click Preview to test, then Submit → Publish.

Option C — WordPress with Site Kit by Google

  • Install and activate the Site Kit by Google plugin.
  • Click Start setup, sign in, verify the site and allow access.
  • Connect Analytics and choose your property/stream — Site Kit inserts the tag for you.
Use only one method. Two tags for the same ID (for example Site Kit and another analytics plugin) double-count page views and break engagement metrics.

Step 3: Verify Your Tracking

Realtime report

Open your site in another tab; you should appear as an active user within seconds.

DebugView

Admin → DebugView shows every event and parameter live while debug mode is on.

Tag Assistant

tagassistant.google.com connects to your site and lists every tag that fired.

Turn on debug mode for your own testing:

gtag('config', 'G-XXXXXXXXXX', { debug_mode: true });
TypeExamplesSetup
Automatically collectedfirst_visit, session_start, page_view, user_engagementNone
Enhanced measurementscroll, click (outbound), view_search_results, file_download, form_startToggle in the web stream
Recommendedsign_up, login, generate_lead, purchase, add_to_cartCode or GTM, using Google’s names
Customdownload_syllabus, quiz_completeCode or GTM, your own names

Send a recommended event

// When someone signs up
gtag('event', 'sign_up', { method: 'Google' });

// When an order is completed
gtag('event', 'purchase', {
  transaction_id: 'T_12345',
  value: 49.99,
  currency: 'USD',
  items: [{ item_id: 'SKU_1', item_name: 'GA4 Course', price: 49.99, quantity: 1 }]
});

Send an event through Tag Manager’s dataLayer

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'generate_lead',
  form_name: 'contact'
});

In GTM, create a Custom Event trigger for generate_lead and a GA4 Event tag that sends it with the form_name parameter.

Make events useful in reports

  • Key events: Admin → Events → mark purchase or generate_lead as a key event (formerly called conversions).
  • Custom dimensions: Admin → Custom definitions → register a parameter (e.g. form_name) so it appears as a dimension in reports.

Step 5: Track Campaigns with UTM Parameters

Add UTM tags to links you share so GA4 knows exactly which campaign brought each visitor:

https://enneafintech.com/?utm_source=newsletter&utm_medium=email&utm_campaign=nov_launch&utm_content=header_button
ParameterMeaningExample
utm_sourceWhere the traffic comes fromnewsletter, facebook, google
utm_mediumType of channelemail, social, cpc
utm_campaignCampaign namenov_launch
utm_contentWhich link or creativeheader_button
utm_termPaid keyword (optional)ga4 course
Rules: use lowercase, keep names consistent, and never put UTM tags on internal links — they start a new session and overwrite the real source.

Step 6: Read the Reports

Realtime

Users in the last 30 minutes, live events and pages.

Acquisition

User acquisition = how new users first arrived. Traffic acquisition = source of every session.

Engagement

Events, pages and screens, landing pages, engagement time.

Monetization

Revenue, purchases, items and ads (needs ecommerce events).

Retention

New vs returning users and cohorts over time.

Tech & demographics

Device, browser, country, language.

Explorations (Explore tab)

  • Free form: drag dimensions and metrics into a custom table or chart.
  • Funnel exploration: e.g. view course → sign up → purchase, with drop-off at each step.
  • Path exploration: what users do before or after a page or event.
  • Segment overlap: how audiences intersect (mobile × returning × buyers).
  • Cohort exploration: retention of users grouped by first visit week.

Advanced: Audiences and Attribution

Audiences

Groups of users built from conditions (e.g. viewed the pricing page 2+ times but didn’t buy). Use them in reports and, when linked, in Google Ads remarketing.

Attribution

Decides which channel gets credit for a key event. GA4 uses data-driven attribution by default; you can compare models in Advertising → Attribution.

Internal traffic filter

Admin → Data streams → Define internal traffic (your IPs), then activate the data filter so your own visits don’t pollute reports.

Advanced: BigQuery Export and SQL

Link GA4 to BigQuery (Admin → Product links → BigQuery) to get raw, event-level data you can query with SQL. Standard properties get a free daily export (with a daily event limit).

-- Top events in October 2026
SELECT event_name, COUNT(*) AS events
FROM `my-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20261001' AND '20261031'
GROUP BY event_name
ORDER BY events DESC;

Advanced: Measurement Protocol (Server-Side Events)

Send events from your server, CRM or backend (for example an offline sale) using the Measurement Protocol. Create an API secret in Admin → Data streams → Measurement Protocol API secrets.

curl -X POST "https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXXXXXX&api_secret=YOUR_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"client_id":"123456.7654321","events":[{"name":"purchase","params":{"transaction_id":"T_12345","value":49.99,"currency":"USD"}}]}'

Test first with the validation endpoint /debug/mp/collect, which returns errors instead of silently dropping bad events.

Advanced: Pull Reports with the Data API (Python)

Automate reporting with the GA4 Data API. Install the client library:

pip install google-analytics-data

Then run a report (authenticate with a service account that has Viewer access to the property):

from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import RunReportRequest, Dimension, Metric, DateRange

client = BetaAnalyticsDataClient()
request = RunReportRequest(
    property="properties/123456789",
    dimensions=[Dimension(name="country")],
    metrics=[Metric(name="activeUsers")],
    date_ranges=[DateRange(start_date="7daysAgo", end_date="today")],
)
response = client.run_report(request)
for row in response.rows:
    print(row.dimension_values[0].value, row.metric_values[0].value)

In regions that require consent, set default consent before the config command, then update it when the visitor chooses:

// 1. Default: everything denied until the visitor decides
gtag('consent', 'default', {
  ad_storage: 'denied',
  analytics_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied'
});

// 2. After the visitor accepts analytics cookies
gtag('consent', 'update', { analytics_storage: 'granted' });
  • No personal data: never send names, emails or phone numbers in events, URLs or parameters.
  • Data retention: Admin → Data retention — 2 or 14 months for event-level data used in explorations (standard reports are not affected).
  • IP addresses are not logged or stored in GA4.
  • Privacy policy: disclose that you use Google Analytics and cookies, and link to Google’s policy.

Common Mistakes and How to Fix Them

ProblemSymptomFix
Tag installed twiceEvery page view counted twice, very low bounceKeep one method (gtag, GTM or plugin)
Wrong time zone / currencyDays and revenue don’t match your shopFix in Property settings (affects data from then on)
Payment gateway as referralPurchases credited to paypal.comAdd it to List unwanted referrals
Multiple domainsSessions split between domainsConfigure cross-domain measurement in the web stream
Own visits countedInflated traffic from your officeDefine internal traffic and activate the filter
Custom parameter missing in reportsParameter visible in DebugView onlyRegister it as a custom dimension

Step-by-Step Installation Guide (gtag and GTM)

Interview Questions

What is the main difference between Universal Analytics and GA4?

Universal Analytics was session- and hit-based with fixed hit types; GA4 is event-based — every interaction is an event with parameters — and it combines web and app data in one property.

How is bounce rate calculated in GA4?

Bounce rate = 1 − engagement rate, i.e. the percentage of sessions that were not engaged (shorter than 10 seconds, no key event and only one page view).

What is a key event?

An event you mark as important for your business, such as purchase or generate_lead. It was previously called a conversion in GA4.

How do you track a custom button click?

Send a custom event with gtag(‘event’, ‘name’, {params}) or a GTM trigger on the click, then register any parameters you need as custom dimensions.

When would you use the Measurement Protocol?

To send events that happen outside the browser — server-side purchases, offline sales or CRM updates — using a client_id and an API secret.

Why link GA4 to BigQuery?

To access raw event-level data for custom SQL analysis, joins with other business data and long-term storage beyond GA4’s retention limits.

What does Consent Mode do?

It adjusts how Google tags behave based on the visitor’s consent choices, so analytics and ads storage are only used when allowed.

What are the two main ways to install GA4 on a website?

Add the Google tag (gtag.js) directly to every page’s <head>, or install Google Tag Manager once and deploy a Google tag with an Initialization – All Pages trigger. Use only one method per Measurement ID. See the step-by-step install guide.

Exam Quick Revision

  • Everything in GA4 is an event = name + parameters.
  • Account → Property → Data stream (Measurement ID G-…).
  • Engaged session: >10 s, or a key event, or 2+ page views.
  • Engagement rate = engaged ÷ sessions; bounce = 1 − engagement.
  • Install once: gtag.js, GTM or Site Kit — never two.
  • Verify with Realtime, DebugView, Tag Assistant.
  • Key events = goals; custom dimensions make parameters reportable.
  • UTM: source, medium, campaign (+ content, term).
  • Advanced: BigQuery, Measurement Protocol, Data API.
  • Consent Mode default → update; never send personal data.
Scroll to Top