Complete Guide to Google Analytics 4
Understanding Google Analytics 4
GA4 represents a significant shift from Universal Analytics. Here’s everything you need to know to master it.
Why GA4 Matters
Google Analytics 4 is the future of web analytics:
- Event-based tracking instead of session-based
- Cross-platform measurement (web + app)
- Privacy-first design for cookieless future
- Machine learning insights built-in
- Better data control and customization
Key Differences from Universal Analytics
Data Model:
- UA: Session and pageview based
- GA4: Event-based with parameters
Cross-Platform:
- UA: Separate properties for web and app
- GA4: Unified tracking across platforms
Reporting:
- UA: Pre-built reports
- GA4: Exploration-based analysis
Privacy:
- UA: Cookie-dependent
- GA4: Works without cookies
Setting Up GA4
Step 1: Create GA4 Property
- Go to Google Analytics Admin
- Click “Create Property”
- Enter property details
- Select “Web” as platform
- Add website URL
Step 2: Install Tracking Code
<!-- 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>
Step 3: Configure Data Streams
- Add data stream for your website
- Enable enhanced measurement
- Configure stream settings
Understanding Events in GA4
Everything in GA4 is an event. There are four types:
1. Automatically Collected Events:
- page_view
- session_start
- first_visit
- user_engagement
2. Enhanced Measurement Events:
- scroll (90% depth)
- outbound clicks
- site search
- video engagement
- file downloads
3. Recommended Events:
- login
- sign_up
- purchase
- add_to_cart
- begin_checkout
4. Custom Events: Events you create for specific needs
Creating Custom Events
Using gtag.js:
// Track button click
gtag("event", "button_click", {
button_name: "subscribe",
button_location: "header",
});
// Track form submission
gtag("event", "form_submit", {
form_name: "contact",
form_location: "footer",
});
Using Google Tag Manager:
- Create new tag
- Choose “Google Analytics: GA4 Event”
- Enter event name and parameters
- Set up trigger
- Publish container
Custom Dimensions and Metrics
Extend GA4’s capabilities with custom data.
Creating Custom Dimensions:
- Go to Admin > Custom Definitions
- Click “Create custom dimension”
- Set scope (Event or User)
- Add event parameter or user property
- Save
Example Custom Dimensions:
- User type (free vs. premium)
- Content category
- Author name
- Product SKU
- Video category
Setting Up Conversions
Mark important events as conversions:
- Go to Admin > Events
- Find your event
- Toggle “Mark as conversion”
- Confirm
Common Conversions:
- Purchase
- Sign up
- Download
- Contact form submission
- Add to cart
- Video completion
Building Reports
Reports Snapshot: Quick overview of key metrics
Realtime Report: See what’s happening now
Life Cycle Reports:
- Acquisition: How users find you
- Engagement: What users do
- Monetization: Revenue data
- Retention: User loyalty
User Reports:
- Demographics: Age, gender, location
- Tech: Device, browser, OS
- User attributes: Custom data
Exploration Reports
Powerful analysis tools for deep insights:
Free Form Exploration:
- Drag-and-drop interface
- Mix dimensions and metrics
- Create pivot tables
Funnel Exploration:
- Visualize conversion funnels
- Identify drop-off points
- Optimize user journeys
Path Exploration:
- See user navigation paths
- Understand behavior flow
- Identify popular routes
Segment Overlap:
- Compare user segments
- Find commonalities
- Discover new audiences
Cohort Exploration:
- Track user groups over time
- Measure retention
- Compare cohorts
User Explorer:
- Individual user journeys
- Detailed event streams
- Privacy-safe user analysis
Audience Building
Create audiences for targeting and analysis:
Example Audiences:
High-Value Users:
- Total revenue > $500
- Active in last 30 days
Engaged Users:
- Session duration > 3 minutes
- Pages per session > 5
Cart Abandoners:
- add_to_cart event
- No purchase event
- Last 7 days
E-Commerce Tracking
Track online store performance:
Required Events:
- view_item_list
- select_item
- view_item
- add_to_cart
- begin_checkout
- purchase
Implementation Example:
// Product view
gtag("event", "view_item", {
currency: "USD",
value: 29.99,
items: [
{
item_id: "SKU123",
item_name: "Product Name",
price: 29.99,
quantity: 1,
},
],
});
// Purchase
gtag("event", "purchase", {
transaction_id: "T12345",
value: 79.99,
tax: 7.99,
shipping: 5.0,
currency: "USD",
items: [
{
item_id: "SKU123",
item_name: "Product Name",
price: 29.99,
quantity: 2,
},
],
});
Privacy and Compliance
GA4 is designed for privacy:
Data Retention:
- Configure in Admin > Data Settings
- Options: 2 or 14 months
- Applies to user-level data
Google Signals:
- Enable for cross-device tracking
- Requires consent in EU
- Provides demographic data
IP Anonymization:
- Automatic in GA4
- IPs not logged or stored
- Privacy-friendly by default
Consent Mode:
- Respect user consent choices
- Adjust tracking behavior
- Model missing data
// Consent mode implementation
gtag("consent", "default", {
analytics_storage: "denied",
ad_storage: "denied",
});
// Update consent
gtag("consent", "update", {
analytics_storage: "granted",
});
Integration with Other Tools
Google Ads:
- Import conversions
- Create remarketing audiences
- Measure ad performance
Search Console:
- See search queries
- Understand organic traffic
- Identify GEO opportunities
BigQuery:
- Export raw data
- Advanced analysis
- Custom reporting
Data Studio (Looker Studio):
- Create custom dashboards
- Share with stakeholders
- Automate reporting
Debugging and Troubleshooting
GA4 DebugView:
- Enable debug mode
- View events in real-time
- Check event parameters
- Verify implementation
Enable Debug Mode:
// Add debug parameter
gtag("config", "G-XXXXXXXXXX", {
debug_mode: true,
});
Common Issues:
- Events not firing
- Parameters missing
- Incorrect data types
- Duplicate events
- Slow data processing
Best Practices
Event Naming:
- Use lowercase_with_underscores
- Be consistent
- Keep names descriptive
- Follow GA4 recommendations
Parameters:
- Limit to 25 per event
- Use standard parameter names when possible
- Add custom parameters as needed
- Keep parameter names consistent
Data Quality:
- Set up filters for internal traffic
- Exclude bot traffic
- Remove test data
- Regular data audits
Documentation:
- Document custom events
- Track implementation changes
- Maintain measurement plan
- Share with team
Advanced Features
Enhanced Conversions:
- Send hashed user data
- Improve conversion accuracy
- Better attribution
User-ID:
- Track across devices
- Unified user view
- Better lifetime value
Predictive Metrics:
- Purchase probability
- Churn probability
- Revenue prediction
Migration from Universal Analytics
Run Both in Parallel:
- Dual tagging during transition
- Compare data
- Validate setup
- Train team
Update Tracking:
- Convert pageviews to events
- Map goals to conversions
- Update custom dimensions
- Recreate reports
Communicate Changes:
- Brief stakeholders
- Explain differences
- Set expectations
- Provide training
Conclusion
GA4 is powerful but requires a mindset shift. Invest time in learning the event-based model, explore the new reporting interface, and leverage machine learning insights. The sooner you master GA4, the better prepared you’ll be for the future of analytics.