Sub topic 1
Everything is an event: GA4's data model
Every number in the Engagement reports comes from events. Page views, sessions, engagement time, and conversions are all counted or derived from them. This chapter covers how GA4 stores an event, what its parts are, and how the metrics you read later come from that raw material.
Prerequisites
This chapter assumes you have:
- A GA4 property with a web data stream that is collecting data.
- Basic familiarity with the GA4 interface and the left-hand navigation.
- A basic idea of what a page view and a user session are.
- Optional: some JavaScript, so you can read the
gtagexamples.
From hits to events
Earlier versions of Google Analytics (Universal Analytics) stored data as different hit types. A page view was one kind of hit, an event was another, and a transaction was a third. Each type had its own fields, and sessions were the main unit of measurement.
GA4 uses a single record type, the event. A page view is an event named page_view. A scroll is an event named scroll. The start of a visit is an event named session_start. A purchase is an event named purchase. You will see these names throughout the Engagement reports.
This has two practical consequences:
- Any report is an aggregation over events. To understand a number, ask which events produced it.
- Concepts that look fundamental, such as "session", are derived from events and are not stored as separate objects.
Anatomy of an event
An event has four parts:
- A name. This is a string such as
page_vieworfile_download. It tells GA4 what happened. - Parameters. These are key-value pairs that describe the context of this one occurrence.
- User properties. These describe the person or device, and they carry over to later events.
- A timestamp and client identifiers. GA4 attaches these automatically so it can group events by user and session.
Items are a fifth, special case. Ecommerce events carry an items array, one entry per product. This chapter does not cover item scope.
Event parameters
A parameter adds detail to a single event. A page_view event carries the parameters page_location, page_referrer, and page_title. A file_download event carries file_name, file_extension, and link_url. You can also add your own.
Parameters are scoped to the event. If you send placement: "footer" on one event, the next event does not inherit it.
Some parameters are always present and do structural work:
| Parameter | What it does |
|---|---|
| `ga_session_id` | Groups events into the same session |
| `ga_session_number` | Counts how many sessions this user has had |
| `engagement_time_msec` | Reports how long the page was in the foreground since the last event |
| `page_location` | Holds the full URL, which the Pages and screens report uses to build page paths |
You rarely see these in the interface under their raw names. Reports translate them into dimensions and metrics such as "Page path" and "Average engagement time".
User properties
A user property describes the user and applies to all events from that user until it changes. A "plan type" value of premium is a typical example. Event parameters describe a moment, and user properties describe a person. Mixing the two is a common source of confusion when you design custom data.
What a hit looks like in code
On a page that already loads gtag.js, you send a custom event like this:
// Send a custom event with a parameter from a page that already loads gtag.js
gtag('event', 'newsletter_signup', {
placement: 'footer'
});The first argument, 'event', tells gtag that this is an event call. The second is the event name. The third is an object of parameters.
GA4 receives one event named newsletter_signup with one custom parameter, placement. The event appears by name in the Events report. The parameter value is stored with the event, but it does not appear as a report dimension until you register it as a custom dimension, which a later chapter covers.
The snippet above does not define gtag itself. It relies on the standard loader on the page, which includes this helper:
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }If gtag is undefined, the call throws a ReferenceError and nothing is sent.
How one visit becomes a stream of events
Suppose a visitor lands on a blog post, scrolls, and downloads a PDF. The data collected looks roughly like this:
session_startandfirst_visitfire as the visit begins.first_visitfires only for a new user.page_viewfires with the post's URL and title.scrollfires when the visitor reaches 90% of the page depth.file_downloadfires with the file name and link URL.user_engagementfires when the visitor leaves or the page goes to the background, carrying the accumulated engagement time.
The numbers you read later come from this stream:
- Sessions are counted from
session_startevents. - Views are counted from
page_viewevents. - Engaged sessions depend on engagement time, on key events in the session, and on page views.
- Event count in the Events report is the number of times an event fired.
The diagram shows how raw events feed the reports.
Limits and naming rules
GA4 enforces limits that affect how you design events. These apply to standard properties, and you should check Google's current documentation because limits change:
- Event names are limited to 40 characters. They must start with a letter and contain only letters, numbers, and underscores.
- An event can have up to 25 parameters.
- Parameter names are limited to 40 characters, and parameter values to 100 characters.
- Names are case-sensitive.
Newsletter_Signupandnewsletter_signupare two different events. - Some prefixes and names are reserved, such as
google_,ga_, andfirebase_. Events using them are dropped or ignored.
Case sensitivity causes more cleanup work than any other rule. A team that sends signup from one page and Signup from another ends up with two rows in the Events report and a split count. Choose snake_case names and keep a short list of agreed names.
Common errors with the event model
- Expecting a parameter to appear in reports immediately. A parameter sent with an event is stored, but a standard report shows it only after you register it as a custom dimension or metric. Registration applies going forward, not to past data.
- Using event names as values. Putting the page name inside the event name (
view_pricing_page,view_about_page) creates many event names. Send onepage_viewevent and readpage_location. The same goes for custom events: onevideo_playevent with avideo_titleparameter beats one event per video. - Treating the event count as a user count. The event count is how many times events fired. One user who triggers
scrollfive times adds five. Compare it against the number of users who triggered the event, which the Events report shows next to it. - Assuming sessions are stored. Sessions are inferred from the
ga_session_idparameter andsession_start. If those events or parameters are missing, for example because a tag fires before the config call, session numbers will be off. - Mixing up scopes. Putting user-level information in an event parameter means it is not carried to later events. Putting event-level detail in a user property means it overwrites itself on the next event.
Checking what GA4 actually receives
Reading the report tells you what GA4 processed, which can lag behind what your site sent by a day or more. To see events as they arrive, use DebugView (Admin, then DebugView) with debug mode enabled for your browser. It shows each event in order along with its parameters. When a number looks wrong later in this tutorial, compare it against the raw events here first.
Exercise
A visitor opens a pricing page, then scrolls to the bottom, then leaves. Name three events this could produce, and explain why the "Page path" dimension is available in reports without you having sent it as a custom parameter.
Show answer
Three possible events are pageview, scroll, and userengagement (sessionstart also fires if the visit is new). Page path is available because every pageview event carries the automatically collected page_location parameter, and GA4 derives the Page path dimension from that URL. It is a built-in dimension, so it needs no custom registration.
Exercise
Your team sends gtag('event', 'Newsletter_Signup', {placement: 'footer'}) from one page and gtag('event', 'newsletter_signup', {placement: 'header'}) from another. What will the Events report show, and how do you fix it?
Show answer
The report shows two separate rows, NewsletterSignup and newslettersignup, because event names are case-sensitive. Fix it by standardizing on one snake_case name in the code and keeping placement as the parameter that distinguishes footer from header. Past data stays split across the two names.