๐ Table of Contents
๐ What Is GA4 & Why It Matters
Google Analytics 4 (GA4) is the next-generation analytics platform from Google. It's a complete redesign of how analytics works โ moving from a session-based model to an event-based model that tracks user interactions across websites and apps.
- Privacy-first: Designed for a world without third-party cookies
- Cross-platform: Tracks users across websites AND mobile apps
- AI-powered insights: Google's machine learning provides predictive analytics
- Future-proof: Universal Analytics stopped processing data on July 1, 2024
- Event-based: Every interaction is an event โ unlimited flexibility
๐ฏ What GA4 Tracks
- Page views โ Every time a page loads
- Scrolls โ How far users scroll down a page
- Outbound clicks โ Clicks to external sites
- Site search โ What users search for on your site
- Video engagement โ Video plays and completions
- File downloads โ PDFs, documents, etc.
- Form interactions โ Form starts and submissions
- Custom events โ Whatever you want to track
๐ What GA4 Unlocks
- Predictive audiences โ Users likely to purchase or churn
- Funnel exploration โ See where users drop off
- Path analysis โ User journeys through your site
- Segmentation โ Analyze specific user groups
- Google Ads integration โ Import conversions and audiences
- BigQuery export โ Unrestricted data analysis
- Real-time reporting โ See user activity as it happens
โ๏ธ GA4 vs Universal Analytics: What's Changed?
Understanding the differences between GA4 and Universal Analytics is crucial for setting up your tracking correctly.
| Feature | Universal Analytics (UA) | GA4 | Why This Matters |
|---|---|---|---|
| Data Model | Session-based | Event-based | GA4 tracks every interaction as an event โ more flexibility |
| Privacy | Cookie-dependent | Privacy-first | GA4 works without third-party cookies |
| Cross-Platform | Website only | Website + App | Track users across all platforms in one property |
| Predicted Metrics | No | Yes | AI predicts future user behavior |
| Custom Events | Limited | Unlimited | Track anything you want |
| BigQuery Export | Paid only | Free | Unlimited raw data analysis for free |
| Data Retention | Unlimited | 14 months (standard) | You must extend to 14 months or export to BigQuery |
๐๏ธ Setting Up Your GA4 Account
Before you install anything, you need to create your GA4 property. Here's exactly how to do it, with detailed explanations of each step.
Go to analytics.google.com and sign in with your Google account.
Click the Admin gear icon (bottom-left), then click + Create Property.
Enter your Property Name (e.g., "MyWebsite GA4"), select your Reporting Time Zone, and choose your Currency.
Click Web (for a website) and enter your Website URL and Stream Name. Toggle on Enhanced Measurement (recommended).
Your Measurement ID is the unique identifier for your GA4 property. It looks like G-XXXXXXXXXX.
๐ง Installing GA4 on Your Site
There are two main ways to install GA4: direct code installation or Google Tag Manager. Here's both approaches with detailed explanations.
Option A: Direct Installation (Google Tag)
<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>
๐ฅ How to Install
- Copy the code above
- Paste it into the
<head>section of every page - Replace
G-XXXXXXXXXXwith your Measurement ID - Publish your site
๐ What This Does
- Loads the Google Analytics library
- Creates the
gtagfunction for sending data - Initializes GA4 with your Measurement ID
- Sends a page_view event on every page load
Option B: Google Tag Manager (Recommended)
In GTM, go to Tags โ New. Select Google Analytics: GA4 Configuration.
Paste your Measurement ID (G-XXXXXXXXXX) into the tag configuration.
Select All Pages as the trigger so the tag fires on every page load.
Click Submit โ Publish to make your changes live.
- No code changes needed โ Add, edit, or remove tags without touching site code
- Version control โ Track all changes and roll back if needed
- Preview mode โ Test tags before they go live
- Centralized management โ All your marketing tags in one place
- Built-in triggers โ Easily configure when tags fire
๐ Understanding Events in GA4
In GA4, everything is an event. This is the most important concept to understand. Unlike Universal Analytics (which was session-based), GA4 tracks every user interaction as a separate event.
An event is any user interaction that you want to measure. Each event has:
- Event Name โ What happened (e.g.,
page_view,purchase,add_to_cart) - Event Parameters โ Additional details (e.g.,
value,currency,items) - User Properties โ Information about the user (e.g.,
user_id,user_type)
Types of Events in GA4
๐ข Automatically Collected Events
- page_view โ Page loads
- first_visit โ First time user
- session_start โ New session
- user_engagement โ User engaged (focused window)
- scroll โ User scrolls to bottom
- click โ Outbound link clicks
- view_search_results โ Site search
- video_start โ Video playback starts
- video_progress โ Video reaches 25%, 50%, 75%
- video_complete โ Video finishes
- file_download โ File download
- form_start โ User starts filling a form
- form_submit โ User submits a form
๐ฃ Enhanced Measurement Events
- page_view (with enhanced data)
- scroll (with scroll depth)
- click (with link details)
- view_search_results (with search term)
- video_* (with video details)
- file_download (with file details)
- form_* (with form details)
Enhanced Measurement adds more detail to these events automatically.
๐ต Recommended Events
- purchase โ Complete purchase
- add_to_cart โ Add item to cart
- begin_checkout โ Start checkout
- add_payment_info โ Add payment info
- add_shipping_info โ Add shipping info
- view_item โ View product details
- view_item_list โ View product list
- select_item โ Select product from list
- sign_up โ User signs up
- login โ User logs in
- generate_lead โ Lead generation
These are Google's recommended event names for ecommerce and lead generation.
๐ Custom Events
- Any name you choose โ Complete flexibility
- Tip: Use descriptive names like
button_click_contactorsocial_share_linkedin - Best practice: Use snake_case (lowercase with underscores)
You can create unlimited custom events to track anything important to your business.
How to Send a Custom Event via GTM
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'button_click_contact',
'button_text': 'Contact Us',
'button_location': 'Header',
'page_url': window.location.href
});
- Be consistent: Use the same event names across your site
- Use parameters: Add context to every event
- Don't over-track: Only track events that matter to your business
- Use Google's recommended events: For ecommerce, use recommended names for better reporting
- Test before publishing: Use GTM Preview mode to verify events fire correctly
๐ฏ Setting Up Key Events (Conversions)
In GA4, conversions are called key events. A key event is any user interaction that's important to your business โ a purchase, a sign-up, a form submission, or any other valuable action.
Determine what actions are most valuable to your business. Common key events include:
- purchase โ Completed transaction
- generate_lead โ Form submission or contact
- sign_up โ Account creation
- add_to_cart โ Adding items to cart
- begin_checkout โ Starting checkout
- page_view (for specific pages like "Thank You" pages)
In GA4, go to Configure โ Key events.
Find the event you want to track, click the toggle to mark it as a Key Event.
In Google Ads, go to Conversions โ Summary โ + New conversion action โ Import โ Google Analytics 4 โ Select your key events.
- Only mark valuable events: Don't mark every event as a key event โ it dilutes the data
- Set a value: Assign a monetary value to each key event for better ROI calculation
- Use the right attribution window: Choose the attribution window that matches your business cycle
- Import to Google Ads: All key events should be imported to Google Ads for Smart Bidding
- Monitor regularly: Review key event performance monthly and adjust as needed
๐ฅ Building Audiences in GA4
Audiences are groups of users who share specific characteristics. In GA4, you can create audiences based on any combination of events, user properties, and engagement metrics.
๐ข Types of Audiences
- Predicted audiences โ AI predicts future behavior (e.g., likely to purchase in next 7 days)
- Behavioral audiences โ Based on user actions (e.g., added to cart but didn't purchase)
- User property audiences โ Based on user attributes (e.g., logged-in users)
- Sequential audiences โ Users who performed actions in a specific order
- Session audiences โ Based on session behavior (e.g., high-engagement sessions)
๐ How to Build an Audience
- Go to Configure โ Audiences
- Click New audience
- Choose a template or build custom
- Define your conditions (events, user properties, etc.)
- Click Save
- Publish to Google Ads for remarketing
Condition: Users who triggered add_to_cart but not purchase in the last 7 days.
Condition: Users who have completed purchase with value greater than $100 in the last 30 days.
- Use predictive audiences: "Likely to purchase" and "Likely to churn" are powerful for optimization
- Create sequential audiences: Track users through specific journeys
- Export to Google Ads: Use GA4 audiences for remarketing and lookalike campaigns
- Refresh regularly: Audiences should be dynamic โ users should enter and exit based on behavior
- Test different conditions: A/B test different audience definitions to find what works best
๐ Understanding GA4 Reports
GA4 has a completely new reporting interface. Here are the key reports you need to know.
๐ Standard Reports
- Acquisition: Where users come from (traffic sources)
- Engagement: What users do (events, conversions)
- Monetization: How much revenue (ecommerce, in-app purchases)
- Retention: How often users return (user loyalty)
- Demographics: Who users are (age, gender, location)
- Tech: What devices and browsers users use
๐ Exploration Reports
- Free Form: Custom pivot tables and charts
- Funnel Exploration: See where users drop off
- Path Exploration: User journeys through your site
- Segment Overlap: Compare different user segments
- User Lifetime: User value over time
- Cohort Exploration: User retention by cohort
- Start with acquisition: Understand where your traffic comes from
- Then engagement: See what users do on your site
- Then monetization: Measure revenue and conversions
- Use explorations for deep dives: Standard reports give you the overview, explorations give you the detail
- Compare date ranges: Always compare current period to previous period to spot trends
- Apply segments: Segment your data to understand different user groups
๐ Linking GA4 to Google Ads
Linking GA4 to Google Ads is one of the most important things you can do. It enables cross-platform reporting, audience sharing, and conversion import.
In GA4, click Admin โ Google Ads Links โ Link.
Choose the Google Ads account you want to link. You'll see a list of all accounts you have access to.
Choose what data to share:
- Enable personalized advertising: Allows Google Ads to use GA4 data for audience targeting
- Enable auto-tagging: Automatically adds GCLID parameters to ad clicks
In Google Ads, go to Conversions โ Summary โ + New conversion action โ Import โ Google Analytics 4.
- Cross-platform reporting: See Google Ads data in GA4 reports
- Audience sharing: Use GA4 audiences for Google Ads remarketing
- Conversion import: Use GA4 key events as Google Ads conversions
- Better attribution: Google Ads gets more detailed user journey data
- Unified measurement: Consistent metrics across platforms
๐ Consent Mode & Privacy
GA4's Consent Mode allows you to respect user privacy choices while still collecting data. It's essential for GDPR and CCPA compliance.
Consent Mode reads a user's consent state from your consent banner and adjusts Google tags accordingly. If a user denies consent, Google tags will not collect personal data โ but they'll still send aggregated, anonymized data.
Setting Up Consent Mode
<script>
// Set default consent state
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'functionality_storage': 'denied',
'personalization_storage': 'denied',
'security_storage': 'granted',
'wait_for_update': 500
});
// Update when user gives consent
function updateConsent() {
if (userConsentGiven) {
gtag('consent', 'update', {
'ad_storage': 'granted',
'analytics_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted'
});
}
}
</script>
- Use a consent banner: CookieYes, Complianz, OneTrust, or similar
- Set default consent to "denied": Respect user privacy until they choose
- Implement wait_for_update: Wait up to 500ms for consent to be set before firing tags
- Use modelled conversions: Google provides modelled data for non-consenting users
- Test consent flows: Verify that tags behave correctly in different consent states
๐ Enhanced Measurement
Enhanced Measurement is a GA4 feature that automatically tracks common user interactions without you needing to write any code.
๐ข What Enhanced Measurement Tracks
- Page views: Every page load
- Scrolls: When users scroll to the bottom of the page
- Outbound clicks: Clicks to external domains
- Site search: Internal search queries
- Video engagement: Video starts, progress, and completions
- File downloads: Downloads of documents, PDFs, etc.
- Form interactions: Form starts and submissions
โ๏ธ How to Enable It
- In GA4, go to Admin โ Data Streams
- Click your data stream
- Click the gear icon next to Enhanced Measurement
- Toggle on each feature you want to track
- Click Save
- That's it โ no code needed!
- Immediate tracking: Start collecting valuable data from day one
- No code required: All configuration is done in the GA4 interface
- Comprehensive data: Track 7+ user interaction types automatically
- Consistent tracking: All users are tracked the same way
- Easy to customize: You can turn individual features on or off
- Enable all features: Unless you have a specific reason not to, enable everything
- Check event counts: Enhanced Measurement events count toward your monthly event limit
- Customize as needed: You can exclude specific types of outbound clicks or file downloads
- Combine with custom events: Enhanced Measurement captures the basics, custom events capture everything else
๐ Custom Dimensions & Metrics
Custom dimensions allow you to collect and report on data that Google doesn't track by default. They give you the flexibility to track anything important to your business.
๐ข What Are Custom Dimensions?
Custom dimensions are user properties or event parameters that you define and send to GA4. They allow you to segment and report on data that matters specifically to your business.
Examples: User type (new vs. returning), content category, product SKU, campaign source, etc.
๐ How to Set Up Custom Dimensions
- In GA4, go to Admin โ Custom Definitions
- Click Create Custom Dimension
- Enter a Dimension Name and Description
- Choose the Scope (Event, User, Item, Session)
- Enter the Event Parameter name
- Click Save
Let's say you want to segment users by whether they're new or returning. Here's how:
- Dimension Name: User Type
- Scope: User
- Event Parameter: user_type
- Plan before you create: Think about what data you need before creating dimensions
- Use consistent naming: Use snake_case for parameter names (e.g.,
user_type) - Choose the right scope: Event scope for event-specific data, User scope for user-level data
- Don't exceed limits: You have a limited number of custom dimensions โ use them wisely
- Test before publishing: Verify that your custom dimensions are being populated correctly
๐๏ธ BigQuery Integration
BigQuery is Google's enterprise data warehouse. With GA4, you can export your raw analytics data to BigQuery for free โ giving you unlimited analysis capabilities.
- Raw, unsampled data: Every single event, with all parameters
- Unlimited analysis: No data limits โ analyze as much data as you want
- Custom queries: Write SQL to answer any business question
- Integration with other data: Combine GA4 data with CRM, sales, or other data
- Free storage: Up to 1 TB of free query processing per month
Go to Google Cloud Console โ + Create Project.
In GA4, go to Admin โ BigQuery Links โ Link.
Choose your export settings:
- Export frequency: Daily or streaming (real-time)
- Data retention: How long to keep data in BigQuery
- Data set location: Where to store your data
SELECT
DATE(event_timestamp) AS event_date,
event_name,
COUNT(*) AS event_count,
SUM(SAFE_CAST((SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'value') AS FLOAT64)) AS total_value
FROM
`project_id.dataset_id.events_*`
WHERE
_TABLE_SUFFIX BETWEEN '20260701' AND '20260728'
AND event_name IN ('purchase', 'add_to_cart', 'page_view')
GROUP BY
event_date, event_name
ORDER BY
event_date DESC;
- No sampling: Analyze ALL your data, not just a sample
- Historical analysis: Keep data for years, not just 14 months
- Combine data sources: Join GA4 data with CRM, sales, or other data
- Custom reporting: Build exactly the reports you need
- It's free: Up to 1 TB of query processing free per month
๐งฎ Interactive Calculators
Use these calculators to understand the impact of your GA4 implementation and make data-driven decisions.
๐ GA4 Data Retention Impact Calculator
Understand how GA4's data retention limits affect your historical analysis and when to export to BigQuery.
๐ก Why this matters: GA4 only keeps data for up to 14 months in its interface. If you need to compare year-over-year data or analyze trends over multiple years, you must export to BigQuery.
๐ GA4 Event Limit Tracker
Monitor your GA4 event usage against the 500-event limit per session and plan your tracking accordingly.
๐ก Why this matters: GA4 has a 500-event limit per session. If users generate more than 500 events in a single session, subsequent events are not recorded. Track your event count to ensure you don't lose critical data.
๐ GA4 vs Universal Analytics Data Loss Calculator
Calculate how much data you lost or gained after migrating from Universal Analytics to GA4.
๐ก Why this matters: GA4 and UA use different attribution models and data collection methods. Expect a 5-15% difference in metrics. If the difference is larger, you may have setup issues.
๐ง Troubleshooting & Testing
๐ข How to Test Your GA4 Setup
- Use GA4 DebugView: See real-time events in GA4
- Use GTM Preview Mode: Test tags before publishing
- Use Google Tag Assistant: Chrome extension for debugging
- Use console logs: Check for errors in browser console
- Use dataLayer inspector: See what data is being pushed
โ Common Issues & Fixes
- No data in GA4: Check Measurement ID, check GTM trigger
- Low event counts: Check consent mode, check GTM configuration
- Duplicate events: Check for multiple GA4 tags firing
- Cross-domain issues: Configure cross-domain measurement
- Consent issues: Verify consent mode configuration
// Check if GA4 is loaded
if (typeof gtag !== 'undefined') {
console.log('โ GA4 is loaded');
} else {
console.log('โ GA4 is not loaded');
}
// Force a test event
gtag('event', 'test_event', {
'test_value': 'This is a test',
'test_timestamp': new Date().toISOString()
});
console.log('โ Test event sent');
- โ GA4 tag fires on all pages
- โ Page views appear in GA4 Real-Time report
- โ Enhanced Measurement events are firing (scrolls, outbound clicks, etc.)
- โ Custom events are firing and appear in GA4
- โ Key events are being recorded
- โ GA4 is linked to Google Ads
- โ Consent Mode is working correctly
- โ Custom dimensions are populating
- โ BigQuery export is working (if configured)
๐ Summary & Best Practices
Set Up Correctly
- Use GTM for installation
- Enable Enhanced Measurement
- Set up key events
- Link to Google Ads
Privacy First
- Implement Consent Mode v2
- Use a consent banner
- Respect user choices
- Stay GDPR compliant
Advanced Features
- Use custom dimensions
- Export to BigQuery
- Build predictive audiences
- Use exploration reports
- Install GA4 immediately if you haven't already โ Universal Analytics no longer processes data
- Use GTM for all your GA4 implementation โ it gives you flexibility and control
- Enable Enhanced Measurement โ it tracks 7+ user interactions automatically
- Set up key events โ mark all important actions as key events
- Link GA4 to Google Ads โ enable cross-platform reporting and conversion import
- Implement Consent Mode โ respect user privacy while still collecting data
- Export to BigQuery โ unlock unlimited historical analysis
- Build audiences โ use predictive audiences for smarter remarketing
- Explore with explorations โ use funnels, path analysis, and free form reports
- โ GA4 property created and configured
- โ GA4 installed via GTM (or direct code)
- โ Enhanced Measurement enabled
- โ Key events set up for all valuable actions
- โ GA4 linked to Google Ads
- โ Consent Mode v2 implemented
- โ Custom dimensions set up (if needed)
- โ BigQuery export configured (if needed)
- โ Audiences built for remarketing
- โ Testing complete using DebugView and GTM Preview
- โ Team trained on GA4 reporting
- Start with the free GA4 certification โ Google's Skillshop offers comprehensive training
- Explore the demo account โ Google provides a demo GA4 account for practice
- Join the GA4 community โ Learn from other marketers and developers
- Set up custom reports โ Build reports that matter to your business
- Monitor regularly โ Check your GA4 data weekly and adjust as needed