Sub topic 1
Start with a GA4 property and a web data stream
Prerequisites
You should understand the basics of web analytics, including users, sessions, and events. You need a Google account, permission to edit your site's HTML or platform settings, and a working idea of the script tag in a page's <head>.
Create the property and the web data stream
A Google Analytics 4 (GA4) property stores your analytics data. A web data stream connects one website to that property. To create both:
- Sign in to Google Analytics and open Admin.
- Create a property, then choose Web as the platform.
- Enter your site URL and a stream name, then save.
A property can hold several web data streams, but each web stream records data for one website.
Find and understand the Measurement ID
After you create the stream, GA4 shows a Measurement ID in the form G-XXXXXXXXXX. The ID tells the Google tag which property receives the events. It is not a password, but it must match the property you want. Copy it exactly.
What the Google tag is and what it does
The Google tag is a JavaScript library, loaded from gtag.js, that runs in the visitor's browser. It sends page views and events to Google. Your Measurement ID goes into the config call:
<!-- 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>Place this snippet high in the <head> of every page so it loads before visitors leave.
Choose how to install
Three routes deliver the Google tag:
| Route | Best for | Trade-off |
|---|---|---|
| Manual HTML | Small sites where you can edit files | You edit code for every change |
| Platform integration | Sites built on a website platform | You get only the options the plugin exposes |
| Google Tag Manager | Teams that add several tags over time | You maintain an extra container |
Exercise
Your site runs on a website platform that offers a GA4 plugin. Which installation route should you choose, and why?
Show answer
Choose the platform integration. The plugin adds the Google tag with your Measurement ID through the platform settings, so you do not need to edit HTML.