Sub topic 1
Properties and data streams: where data lands
Prerequisites
This chapter assumes that you know how websites load pages, that you have a Google Analytics 4 (GA4) account, and that you can read basic JavaScript. The examples use gtag.js, the tag library that sends data from a web page to GA4.
Properties and data streams
A GA4 property is the container that stores your analytics data. A property holds one or more data streams, and each stream is a source that sends data into the property. A website stream is tied to one domain and has a measurement ID that starts with G-, such as G-XXXXXXXXXX. An app uses its own stream type.
Reports are per property. Data sent to one property never appears in another, so decide on your streams before you start tracking. Moving data later splits your history.
Everything is an event
In GA4, every interaction is an event. A page view, a scroll, a click, and a purchase are all events. Each event has a name and can carry parameters. GA4 has no separate "pageview" or "hit" types, which older Universal Analytics used.
Kinds of events
GA4 sorts events into four groups:
- Automatically collected events, such as
first_visitandsession_start, which GA4 records without extra code. - Enhanced measurement events, such as
scrollandfile_download, which you turn on in the stream settings. - Recommended events, such as
add_to_cartandlogin, which have standard names that Google suggests you use. - Custom events, which you name yourself.
This code sends a custom event:
gtag('event', 'tutorial_step_completed', {
step_number: 3,
tutorial_name: 'ga4_data_model'
});Event parameters
Parameters describe what happened. In the example above, step_number and tutorial_name are event parameters attached to one event. Standard parameter names are reported without setup. Custom parameters appear in standard reports only after you register them as custom dimensions or metrics.
Exercise
A website sends data to the measurement ID G-XXXXXXXXXX. Which GA4 objects contain that ID, and in what order do data flow from them?
Show answer
The data stream contains the measurement ID, and the stream belongs to a property. Data flow from the stream into the property, where the events are stored.