Installing Google Analytics 4 on Webflow
Google Analytics 4 (GA4) is the latest version of Google's analytics platform. This guide covers multiple methods to install GA4 on your Webflow site, from the simplest native integration to advanced custom implementations.
Prerequisites
Before installing GA4 on Webflow, you need:
- A Webflow account with access to Project Settings
- A Google Analytics 4 property - Create one in Google Analytics
- Your GA4 Measurement ID (format:
G-XXXXXXXXXX) - A published Webflow site (tracking only works on published sites, not in Designer preview)
Method 1: Native Webflow Integration (Recommended for Simple Sites)
Webflow offers a built-in Google Analytics integration for basic tracking needs.
Step 1: Access Site Settings
- Open your Webflow project
- Click the Settings icon (gear icon) in the left sidebar
- Navigate to Integrations tab
Step 2: Add GA4 Measurement ID
- Find the Google Analytics section
- Paste your GA4 Measurement ID (format:
G-XXXXXXXXXX) - Click Save Changes
Step 3: Publish Your Site
- Click Publish in the top right
- Select your publishing destination
- Confirm publication
Limitations of Native Integration
- Basic tracking only: Page views are tracked automatically
- No custom events: Cannot track forms, clicks, or custom interactions
- Limited configuration: Cannot customize GA4 settings
- No ecommerce tracking: Webflow Ecommerce events not automatically tracked
Use native integration if: You only need basic page view tracking and don't require custom events or ecommerce tracking.
Method 2: Custom Code Installation (Recommended for Most Sites)
Installing GA4 via custom code provides full control over tracking configuration.
Step 1: Get Your GA4 Tag Code
- Go to Google Analytics
- Navigate to Admin > Data Streams
- Click your Web data stream
- Click View tag instructions
- Select Install manually
- Copy the full Global site tag (gtag.js) code
The code looks like this:
<!-- 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 2: Add Code to Webflow Project Settings
- In your Webflow project, go to Project Settings
- Navigate to Custom Code tab
- Paste the GA4 code into the Head Code section
- Click Save Changes
Step 3: Publish and Test
- Publish your site
- Visit your published site (not Designer preview)
- Verify tracking is working (see Testing section below)
Benefits of Custom Code Installation
- Full GA4 features: Access to all GA4 configuration options
- Custom events: Easily add custom event tracking
- Enhanced measurement: Control automatic event tracking
- Ecommerce tracking: Full ecommerce implementation support
Method 3: Google Tag Manager (Recommended for Advanced Tracking)
For sites with multiple marketing tags or complex tracking requirements, install GA4 through Google Tag Manager.
See our dedicated guide: Installing Google Tag Manager on Webflow
Benefits of GTM Installation
- Centralized tag management: Manage GA4 and other tags in one place
- No code deployments: Add/edit tags without republishing Webflow
- Advanced tracking: Complex event tracking and custom dimensions
- Team collaboration: Multiple team members can manage tags
Method 4: Memberstack Integration (For Membership Sites)
If you use Memberstack for user authentication, you can enhance GA4 tracking with user data.
Prerequisites
- Memberstack installed and configured on your Webflow site
- GA4 installed via Custom Code or GTM (not native integration)
Step 1: Install Base GA4 Tracking
First, install GA4 using Method 2 (Custom Code) or Method 3 (GTM) above.
Step 2: Add Memberstack User ID to GA4
Add this code after your GA4 installation code:
<script>
// Wait for Memberstack to load
window.$memberstackDom.ready.then(function(member) {
if (member.loggedIn) {
// Set User ID in GA4
gtag('config', 'G-XXXXXXXXXX', {
'user_id': member.id
});
// Set custom dimensions for member data
gtag('set', 'user_properties', {
'membership_plan': member.planConnections[0]?.planId || 'none',
'member_status': 'logged_in'
});
}
});
</script>
Replace G-XXXXXXXXXX with your actual Measurement ID.
Step 3: Track Memberstack Events
Track important membership events:
<script>
window.$memberstackDom.ready.then(function(member) {
// Track login
window.$memberstackDom.on('memberLogin', function(member) {
gtag('event', 'login', {
'method': 'memberstack',
'member_id': member.id
});
});
// Track signup
window.$memberstackDom.on('memberSignup', function(member) {
gtag('event', 'sign_up', {
'method': 'memberstack',
'member_id': member.id
});
});
// Track logout
window.$memberstackDom.on('memberLogout', function() {
gtag('event', 'logout', {
'method': 'memberstack'
});
});
});
</script>
Privacy Considerations
- User consent: Ensure you have consent before tracking user IDs
- Privacy policy: Update your privacy policy to reflect user tracking
- Data retention: Configure GA4 data retention settings appropriately
Configuration Options
Enhanced Measurement
Enhanced measurement automatically tracks common interactions. Configure in Google Analytics:
- Go to Admin > Data Streams
- Click your web stream
- Click Enhanced measurement
- Toggle specific events:
- Page views: Automatically tracked
- Scrolls: Track 90% scroll depth
- Outbound clicks: Track external link clicks
- Site search: Track search queries
- Video engagement: Track YouTube videos
- File downloads: Track PDF and file downloads
Custom Configuration Parameters
Customize GA4 behavior by modifying the gtag('config') call:
<script>
gtag('config', 'G-XXXXXXXXXX', {
'cookie_prefix': 'webflow',
'cookie_domain': 'yourdomain.com',
'cookie_expires': 63072000, // 2 years in seconds
'anonymize_ip': true,
'allow_google_signals': true,
'send_page_view': true
});
</script>
Common parameters:
cookie_prefix: Prefix for GA cookies (useful for multi-site tracking)cookie_domain: Domain for cookies (use your root domain)cookie_expires: Cookie expiration in secondsanonymize_ip: Anonymize IP addresses for privacyallow_google_signals: Enable Google signals (remarketing)send_page_view: Control automatic page view tracking
Debug Mode
Enable debug mode to see GA4 events in real-time:
<script>
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});
</script>
Remove debug mode before going to production.
Testing Your Installation
Method 1: Real-time Reports
- Go to Google Analytics
- Select your GA4 property
- Navigate to Reports > Realtime
- In a separate browser tab, visit your published Webflow site
- You should see your visit appear in real-time
Method 2: GA4 DebugView
- Enable debug mode (see above)
- Go to Admin > DebugView in GA4
- Visit your site
- See events fire in real-time with full parameter details
Method 3: Browser Developer Tools
- Open your published site
- Press F12 to open Developer Tools
- Go to Network tab
- Filter by
collectorgoogle-analytics - Reload the page
- You should see GA4 requests being sent
Method 4: Google Tag Assistant (Chrome Extension)
- Install Google Tag Assistant
- Visit your published site
- Click the Tag Assistant icon
- Verify GA4 tag is firing correctly
Troubleshooting
GA4 Not Tracking
Problem: No data appears in GA4 Real-time reports.
Solutions:
- Verify site is published: Tracking only works on published sites, not in Webflow Designer
- Check Measurement ID: Ensure ID format is
G-XXXXXXXXXX(not UA- or GTM-) - Clear cache: Clear browser cache and hard reload (Ctrl+Shift+R)
- Check ad blockers: Disable ad blockers and privacy extensions
- Wait 24-48 hours: Standard reports can take up to 48 hours to populate
Duplicate Page Views
Problem: Seeing double page views in GA4.
Causes:
- GA4 installed both via native integration AND custom code
- Multiple GA4 tags in custom code
- GA4 installed in both Project Settings and GTM
Solutions:
- Remove GA4 from Webflow native integration
- Search custom code for multiple GA4 installations
- Choose ONE method: native, custom code, or GTM
Tracking Works Locally But Not on Custom Domain
Problem: GA4 works on webflow.io subdomain but not custom domain.
Solutions:
- Republish to custom domain: Ensure site is fully published
- Check DNS settings: Verify custom domain DNS is properly configured
- Clear CDN cache: Webflow's CDN may be caching old code
- Update cookie domain: Set
cookie_domainto your root domain
Events Not Appearing
Problem: Custom events not showing in GA4.
Solutions:
- Check event syntax: Ensure proper
gtag('event', 'event_name')format - Wait for processing: Events can take a few minutes to appear
- Use DebugView: Enable debug mode to see events immediately
- Check event name: Event names are case-sensitive and have specific rules
Page-Level Tracking
To add GA4 tracking to specific pages only:
- Go to Pages panel in Webflow Designer
- Click the page you want to track
- Click the gear icon next to the page name
- Go to Custom Code tab
- Add GA4 code to Head Code
- Publish the page
Note: This creates duplicate tracking if you also have site-wide GA4 installed.
Webflow-Specific Tracking Considerations
Webflow Hosting CDN
Webflow uses a global CDN that caches your site. After adding GA4:
- Publish changes: Always publish after adding tracking code
- Hard refresh: Use Ctrl+Shift+R to bypass cache when testing
- Wait for propagation: CDN updates can take a few minutes globally
Webflow Designer vs. Published Site
- Designer preview: GA4 does NOT fire in the Webflow Designer preview
- Editor mode: GA4 does NOT fire in Editor mode
- Staging subdomain: GA4 DOES fire on your webflow.io staging site
- Custom domain: GA4 DOES fire on your published custom domain
Webflow Forms
See Webflow-Specific GA4 Events for detailed form tracking implementation.
Webflow Ecommerce
See Webflow Ecommerce + GA4 Tracking for complete ecommerce implementation.
Webflow CMS
To pass CMS field data to GA4, use custom dimensions and events. See Event Tracking Guide for details.
Privacy and Compliance
Cookie Consent
Implement cookie consent before loading GA4:
<!-- Example consent implementation -->
<script>
// Check if user has consented
if (localStorage.getItem('analytics_consent') === 'granted') {
// Load GA4
(function() {
var script = document.createElement('script');
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX';
script.async = true;
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
})();
}
</script>
GDPR Compliance
For EU visitors:
- Obtain consent before loading GA4
- Anonymize IP addresses: Set
anonymize_ip: true - Respect Do Not Track: Honor browser DNT signals
- Update privacy policy: Clearly disclose GA4 usage
- Configure data retention: Set appropriate retention in GA4 settings
CCPA Compliance
For California visitors:
- Provide opt-out: Allow users to opt out of tracking
- Update privacy policy: Disclose data collection practices
- Honor opt-out requests: Respect user preferences