For general GA4 concepts and features, see the Google Analytics 4 overview.
Prerequisites
- Google Analytics 4 property created
- GA4 Measurement ID (G-XXXXXXXXXX)
- Duda site editing access
Installation Methods
Method 1: Native Duda Integration (Recommended)
Duda has built-in Google Analytics support:
- Open your site in Duda editor
- Go to Site Settings (gear icon)
- Navigate to Site Settings > Google Analytics
- Enter your GA4 Measurement ID (G-XXXXXXXXXX)
- Click Save
- Publish your site
Benefits of native integration:
- Automatic setup
- Duda-optimized loading
- No code to maintain
- Works with ecommerce
Method 2: Head HTML Injection
For more control or custom configurations:
- Go to Site Settings > Head HTML
- Paste the GA4 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>
- Replace
G-XXXXXXXXXXwith your Measurement ID - Click Save
- Publish your site
Method 3: Via Google Tag Manager
If using GTM for tag management:
- Install GTM first: GTM Setup for Duda
- Add GA4 Configuration tag in GTM
- No additional Duda configuration needed
Configuration
Enhanced Measurement
GA4's Enhanced Measurement automatically tracks:
Enable/disable in GA4 Admin > Data Streams > Enhanced Measurement.
Ecommerce Tracking
Duda's ecommerce provides automatic data layer events:
// Duda's dmAPI provides product data
window.dmAPI.getProductInfo(); // Current product
window.dmAPI.getCartInfo(); // Cart contents
For GA4 ecommerce, use GTM with triggers based on Duda's data layer.
Custom Dimensions
Track Duda-specific data:
// Example: Track page template type
gtag('config', 'G-XXXXXXXXXX', {
'custom_map': {
'dimension1': 'page_template'
},
'page_template': 'product_page'
});
Verification
Check Installation
- View Page Source: Search for "gtag.js" or your Measurement ID
- GA4 Realtime: Check Admin > Reports > Realtime
- Google Tag Assistant: Use browser extension
Common Issues
No data in GA4:
- Verify Measurement ID is correct
- Check site is published (not just saved)
- Clear Duda's CDN cache
- Test in incognito mode
Duplicate pageviews:
- Check for multiple GA4 implementations
- Remove manual code if using native integration
- Verify GTM isn't firing duplicate tags
Multi-Language Sites
For Duda sites with multiple languages:
// Track language as custom parameter
gtag('config', 'G-XXXXXXXXXX', {
'custom_map': {
'dimension2': 'content_language'
},
'content_language': document.documentElement.lang
});
Cross-Domain Tracking
If using multiple domains:
gtag('config', 'G-XXXXXXXXXX', {
'linker': {
'domains': ['site1.com', 'site2.com']
}
});