Setting Up Google Analytics 4: A Complete Walkthrough
Most GA4 accounts in the wild are broken. They were migrated from Universal Analytics by checking a box, never properly configured, and now report numbers that don’t match Google Ads, Search Console, or the company’s CRM. Marketing teams stare at dashboards that nobody trusts.
This guide walks through a clean GA4 setup from scratch — the way it should have been done. By the end, you’ll have a property that reports accurate data, integrates cleanly with Google Ads, and provides the attribution backbone for everything else in your marketing stack.
Before you start: what GA4 actually is
GA4 is fundamentally different from Universal Analytics. The conceptual shift:
- UA: a session-based pageview model. Hits roll up into sessions, sessions into users.
- GA4: an event-based model. Every interaction is an event. Sessions are derived from events, not the other way around.
What this means in practice:
- Every interaction worth measuring needs to be sent as an event.
- Some events are sent automatically; many you have to configure.
- The metrics you knew from UA (bounce rate, average session duration) are calculated differently or replaced.
If you’re migrating, don’t expect numbers to match UA. They won’t. Within 5-15% is normal; further differences usually mean a configuration issue.
Step 1: Create the GA4 property
Go to analytics.google.com. If you don’t have an account: create one. If you do: Admin → Create → Property.
Setup wizard fields:
- Property name: your domain (“digitelia.co”). Keep it short.
- Time zone: your business’s reporting time zone. This affects how days are computed.
- Currency: your reporting currency (separate from any conversion values).
- Industry category: pick the closest. Affects benchmarks.
- Business size: pick the closest.
- Business objectives: select all that apply — affects default reports shown in the UI.
Then create the property. You’ll land on the data streams page.
Step 2: Configure data streams
A data stream is where data comes from. Most accounts need one Web data stream; ecommerce stores may need an additional Apps stream if they have mobile apps.
For web:
- Click “Web” as the platform.
- URL: your domain, with https:// protocol.
- Stream name: just the domain again.
- Enhanced measurement: enable. This auto-tracks scrolls, outbound clicks, site searches, video engagement, file downloads. Saves dozens of hours of GTM work.
After creating, copy the Measurement ID (format: G-XXXXXXXXXX). You’ll need this for tag installation.
Step 3: Install the tag
Three installation options, in order of preference for most stacks:
Option 1: Google Tag Manager (recommended)
If you have GTM (and you should), add a Google tag in GTM:
- Tags → New → Tag Configuration → “Google tag”
- Tag ID: paste your Measurement ID (
G-XXXXXXXXXX) - Trigger: All Pages
Publish the GTM container. Done. Verify by opening your website with the GTM Preview mode on — the Google tag should fire on every page.
Option 2: Native installation (Astro / Next.js / etc.)
Add the tag directly to your <head> via a partial layout component. For Astro:
<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 3: CMS plugin (WordPress, etc.)
Use a plugin like “Site Kit by Google” or “GA4 by MonsterInsights.” Easiest path but adds another dependency.
Step 4: Validate data is flowing
Wait 24-48 hours, then verify. Go to GA4 → Reports → Realtime. Browse your own site. You should see at least 1 user (you) in real-time.
If not — common debug steps:
- Check the page source: is the gtag tag actually in the HTML? View page source (Ctrl+U) and search for “G-XXXXXXXXXX”.
- Browser ad blockers: many block GA. Test in incognito with no extensions.
- GTM Preview mode: confirm the tag fires.
- Tag Assistant Companion: Chrome extension that validates Google tags. Indispensable.
Once realtime works, look at the 24-hour Reports → Acquisition → Traffic Acquisition. If you see at least dozens of sessions there, the tag is working at scale.
Step 5: Configure events
GA4’s event model is the secret sauce. Some events are tracked automatically (page_view, session_start, first_visit, scroll, click on outbound link). Others need configuration.
For most websites, you want to track these events at minimum:
| Event | What it tracks | How to implement |
|---|---|---|
page_view | Page loads | Automatic via Enhanced Measurement |
scroll | 90% scroll depth | Automatic via Enhanced Measurement |
click | Outbound clicks | Automatic via Enhanced Measurement |
form_submit | Form submissions | Automatic (best-effort) or GTM custom event |
file_download | PDF, doc, zip downloads | Automatic via Enhanced Measurement |
video_start / video_progress / video_complete | YouTube embed engagement | Automatic via Enhanced Measurement |
generate_lead | Lead form submission (your specific form) | Custom event via GTM |
signup / trial_start | New user signup | Custom event via GTM or backend |
purchase | Ecommerce purchase | Custom event with full ecommerce parameters |
add_to_cart | Add to cart action | Custom event with item parameters |
view_item | Product detail page view | Custom event with item parameters |
begin_checkout | Checkout started | Custom event with cart parameters |
For each custom event, define what data to send (parameters). For generate_lead:
gtag('event', 'generate_lead', {
'currency': 'USD',
'value': 50.00, // estimated value of this lead
'form_id': 'contact-form-homepage',
'form_name': 'Get a Quote'
});
Implementing events via GTM (recommended)
For each event, create a GTM tag:
- Tag type: “Google Analytics: GA4 event”
- Configuration tag: select your GA4 tag
- Event name: e.g.,
generate_lead - Event parameters: as needed
- Trigger: form submission, link click, custom event, etc.
This is far cleaner than scattering gtag() calls across your codebase.
Step 6: Mark events as conversions
GA4 separates events from conversions. Every conversion is an event, but not every event is a conversion. You mark the important ones.
Go to Admin → Events → toggle “Mark as conversion” for these typical conversions:
generate_leadsignuppurchasesubscribe(newsletter)
Conversions then become available in attribution reports, audience definitions, and most importantly, they sync to Google Ads if you’ve linked the accounts.
Step 7: Define audiences
Audiences are reusable segments. Build at least these four:
1. All users (default, already exists).
2. Engaged users: users with 2+ sessions in last 30 days OR who triggered any conversion. Useful for retargeting.
3. Cart abandoners (ecommerce): triggered add_to_cart but not purchase in last 14 days.
4. Lead form viewers who didn’t submit: viewed the contact page but didn’t trigger generate_lead. Useful for retargeting with a softer offer.
To build:
- Admin → Audiences → New Audience
- Define conditions (event-based, page-based, user property-based)
- Save
Each audience can be exported to Google Ads (auto-sync if accounts are linked), used in BigQuery exports, and visible in audience-based reports.
Step 8: Link Google Ads
Critical: this enables conversion data to flow from GA4 to Google Ads, and audience lists to sync.
- GA4 → Admin → Google Ads links → Link → Choose your Google Ads account
- Enable: “Enable Personalized Advertising” (lets you build remarketing audiences in GA4 and use them in Google Ads)
- Enable: “Auto-tagging” (this is critical — without it, GA4 can’t see Google Ads click data properly)
Then in Google Ads:
- Tools → Conversions → Import → GA4 → Select the GA4 conversion events you want to import
- Mark them as primary or secondary as appropriate
Now Google Ads optimizes against the same conversion data you see in GA4.
Step 9: Link other tools
Other links to set up:
Search Console: GA4 → Admin → Search Console links → Link. Enables the Search Console reports in GA4 (queries, landing pages, click data).
BigQuery: GA4 → Admin → BigQuery links → Link. Exports raw event data to BigQuery for advanced analysis. Free up to 1M events/day; necessary for any serious data work.
Display & Video 360 / Campaign Manager 360: enterprise-only, but if you use them, link here.
Merchant Center: ecommerce only. Links product data to GA4 reports.
Step 10: Configure data retention
GA4 defaults to 2 months of data retention for event-level data. That’s almost never enough.
- Admin → Data Settings → Data Retention → Change to 14 months (the max).
This doesn’t affect aggregated reports but is critical for any user-level or event-level analysis longer than 60 days.
Note: 14 months is the GA4 max. For longer retention, export to BigQuery.
Step 11: Set up enhanced ecommerce (if applicable)
For ecommerce stores, configure these events with proper parameters:
view_item/view_item_listadd_to_cartbegin_checkoutadd_payment_infopurchase
Each must include an items array:
gtag('event', 'purchase', {
'transaction_id': 'TX-12345',
'value': 84.99,
'currency': 'USD',
'items': [
{
'item_id': 'SKU-123',
'item_name': 'Cotton T-Shirt',
'price': 24.99,
'quantity': 2,
'item_category': 'Apparel',
'item_brand': 'YourBrand'
},
{
'item_id': 'SKU-456',
'item_name': 'Denim Jeans',
'price': 35.01,
'quantity': 1,
'item_category': 'Apparel',
'item_brand': 'YourBrand'
}
]
});
Most ecommerce platforms (Shopify, BigCommerce, WooCommerce) emit these via dataLayer; you read them in GTM and pass to GA4.
Step 12: Set up server-side tracking (advanced)
For maximum accuracy and to combat ad-blocking, server-side tracking sends events from your server (not the user’s browser) to GA4. This recovers 10-20% of conversion data lost to client-side blocking.
Server-side GTM setup:
- Provision a Google Cloud Platform project.
- Deploy server-side GTM container (Google has a free template).
- Configure your client-side GTM to send events to your server-side container instead of directly to Google.
- Server-side container forwards to GA4 (and other destinations).
This adds operational complexity but is increasingly standard for any serious marketing operation. Plan 1-2 weeks for setup + testing.
Common GA4 setup mistakes
1. Not enabling Enhanced Measurement. You then have to manually configure scroll, outbound clicks, video engagement, etc. — hours of work that GA4 does for free.
2. Forgetting cross-domain tracking. If your checkout is on a separate domain (e.g., checkout.yourbrand.com), users get split into two GA4 users without proper config. Admin → Data Streams → Configure tag settings → Configure your domains.
3. Internal traffic not filtered. Your office’s traffic counts as real users. Admin → Data Filters → set up internal traffic filter with your office IP.
4. Test/dev traffic in production. Filter out staging environments by adding dev/staging to the internal traffic filter, or by using a separate property entirely for non-production.
5. PII in event parameters. Don’t pass emails or names as event parameters. GA4 will flag and may purge data. Use hashed values or just omit.
6. Defining conversions inconsistently. A common bug: form submission marked as generate_lead on one page, lead_form_submit on another. Always use the same event name for the same business action.
7. Not testing with DebugView. Admin → DebugView shows events in real-time for your current session. Use it during setup to validate events are firing correctly.
Reports worth using
Most GA4 default reports are mediocre. The ones to actually look at:
Acquisition → Traffic acquisition. Sessions by channel and source. Your primary view for understanding where traffic comes from.
Engagement → Pages and screens. Top content. Filter by landing page for clearer SEO insight.
Monetization → Ecommerce purchases. Standard ecommerce report.
Advertising → Attribution → Model comparison. Compare data-driven attribution to last-click. Surface big discrepancies in how channels look.
Explore (custom reports). The real power of GA4. Build funnel reports, path explorations, segment overlap analyses. Worth 1-2 hours learning the interface.
A 30-day GA4 setup plan
Day 1-2: Property creation, tag installation, real-time validation.
Day 3-5: Configure custom events for your core conversions (leads, signups, purchases). Mark as conversions. Test with DebugView.
Day 6-10: Link Google Ads, Search Console, BigQuery. Build first 4-5 audiences.
Day 11-20: Set up dashboards (Looker Studio off GA4 data + BigQuery for the harder views).
Day 21-30: Validate against your CRM and Google Ads. Resolve discrepancies (there will be 5-15%; figure out what’s caused by which platform’s quirks).
By day 30, you have a functioning, trusted GA4 setup. Everything after that is incremental improvement.
Frequently asked questions
Will my old UA data carry over to GA4? No. UA data is read-only as of July 2024 and being phased out. GA4 starts collecting fresh from the day you install it.
Does GA4 work without GTM? Yes, but with GTM is much easier. Don’t fight this — use GTM.
Why don’t my GA4 and Google Ads conversion numbers match? Different attribution models, different time windows, different blocking. 5-15% variance is normal and expected. >25% means something is misconfigured.
Is GA4 GDPR/CCPA compliant out of the box? Out of the box, no. You need to implement Consent Mode v2, configure cookie banners, and ensure data isn’t collected from users who haven’t consented. GA4 has the tools; you have to wire them up.
How long until I can trust the data? 2-4 weeks of clean operation. Watch DebugView and Real-time during the first week to ensure events fire correctly. Validate against other sources (Google Ads, Search Console, CRM) by week 4. After that, the data is trustable for decision-making.
A clean GA4 setup is the foundation of everything else in your marketing stack. Google Ads optimization, Meta Ads attribution, CRM lead source tracking — all of it depends on GA4 (or its replacement infrastructure) being correctly configured. The cost of doing it right is 30 days; the cost of doing it wrong is years of decisions made on bad data.