How to install Google Analytics 4 on your Indian website (WordPress and custom sites)
10 min read · 25-Jul-2024
villagehosting.in team
25 July 2024
GA4 replaced Universal Analytics in 2023. The interface is completely different, the measurement model changed, and many Indian website owners are still using workarounds or have no analytics at all. Here is how to install it correctly, configure the important events, and start reading useful data.
India's DPDP Act requires consent before tracking
India's Digital Personal Data Protection Act (2023) requires user consent before collecting personal data — including IP addresses and behavioral data that GA4 collects. At minimum, implement a cookie consent notice that gives users the ability to decline analytics tracking before you activate GA4 on page load. Failure to do so is a legal risk, not just a privacy concern.
What is GA4 and why it's different
Google Analytics 4 is the current version of Google Analytics. It replaced Universal Analytics (UA) in July 2023 — all UA properties stopped processing data.
Key differences from UA:
- Event-based model instead of session-based (every interaction is an "event")
- No "bounce rate" — replaced by "engagement rate"
- Different interface, different report structure
- Built-in cross-device tracking
- Machine learning predictions (audience predictions, anomaly detection)
If you're still running analytics.js (the UA tag), you have no data. Install GA4 now.
Step 1: Create a GA4 property
- Go to analytics.google.com
- Admin (gear icon) → Create → Property
- Enter your property name and select India as your country, IST as your time zone, Indian Rupee as your currency
- Select your business type and size
- Select your primary purpose (website traffic measurement)
- Choose Web as your platform
- Enter your website URL and stream name → Create stream
You now have a Measurement ID that looks like G-XXXXXXXXXX. You'll need this for installation.
Step 2: Install on WordPress
Option A: Google Site Kit plugin (easiest)
- Plugins → Add New → "Site Kit by Google" → Install and Activate
- Start Setup → Connect with your Google account
- Authorise the permissions
- Site Kit automatically installs GA4, Google Search Console, and optionally PageSpeed Insights
- Data starts flowing immediately
Downside: Site Kit is heavy. It adds Google's dashboard inside WordPress admin and runs periodic API calls. On slow hosts, this adds page weight and admin sluggishness.
Option B: MonsterInsights plugin (popular)
MonsterInsights is the most-used GA plugin in India. The free version handles basic GA4 installation and shows a simplified dashboard inside WordPress.
- Install MonsterInsights (free) from the plugin directory
- Go through the setup wizard → connect your Google account → select your GA4 property
- The plugin adds the GA4 tag automatically
The paid version (₹4,000–8,000/year) adds e-commerce tracking, form tracking, and author/category reports.
Option C: Manual installation (most reliable, no plugin)
Copy the GA4 tag from Analytics → Data streams → select your stream → View tag instructions.
Add to your child theme's functions.php:
function add_google_analytics() {
if ( is_admin() ) return; // Don't load in admin
?>
<!-- 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>
<?php
}
add_action( 'wp_head', 'add_google_analytics' );
Replace G-XXXXXXXXXX with your actual Measurement ID.
Option D: Google Tag Manager (for advanced tracking)
Install GTM first, then add GA4 through Tag Manager. This approach lets you manage all tracking tags from one interface without touching code for each new tag.
Install GTM on WordPress using the GTM4WP plugin, then configure GA4 as a tag within GTM.
Step 3: Verify installation
- Open your website in a browser
- In another tab, go to GA4 → Reports → Realtime
- You should see your visit appear within 30 seconds
If no data appears after 5 minutes:
- Ensure you're not blocking yourself with an ad blocker
- Check browser console for JavaScript errors
- Verify the Measurement ID matches exactly
Step 4: Key events to configure
GA4 auto-tracks these events automatically:
page_viewfirst_visitsession_startuser_engagementscroll(90% scroll depth)click(outbound links)video_start,video_progress,video_complete(YouTube embeds)file_download(PDF, Excel, etc.)
Configure manually for Indian websites:
Contact form submissions (Gravity Forms, WPForms, Contact Form 7):
For Contact Form 7 (most popular in India), add to your theme:
document.addEventListener('wpcf7mailsent', function(event) {
gtag('event', 'generate_lead', {
'form_id': event.detail.contactFormId
});
}, false);
WhatsApp click tracking (critical for Indian businesses):
// Track WhatsApp button clicks
document.querySelectorAll('a[href*="wa.me"], a[href*="whatsapp"]').forEach(function(link) {
link.addEventListener('click', function() {
gtag('event', 'whatsapp_click', {
'phone_number': this.href
});
});
});
Phone call clicks:
document.querySelectorAll('a[href^="tel:"]').forEach(function(link) {
link.addEventListener('click', function() {
gtag('event', 'phone_call', {
'phone_number': this.href.replace('tel:', '')
});
});
});
Step 5: WooCommerce e-commerce tracking
Install WooCommerce Google Analytics Integration (free official plugin) or use MonsterInsights Pro for enhanced e-commerce tracking.
Events tracked:
view_item— product page viewsadd_to_cartremove_from_cartbegin_checkoutpurchase— with transaction ID, value, and items
Configure your currency as INR in both GA4 property settings (Admin → Property Settings) and the plugin settings.
DPDP Act compliance for Indian analytics
India's Digital Personal Data Protection Act 2023 requires consent before collecting personal data. Analytics data (IP addresses, user identifiers) is personal data.
Minimum compliance steps:
- Add a cookie consent notice before GA4 loads
- Only load GA4 after the user consents
Implement with a consent management plugin:
- CookieYes (free tier available) — shows a consent banner, integrates with GA4 consent mode
- Complianz — more comprehensive, GDPR + DPDP ready
GA4 Consent Mode V2 lets GA4 load in a limited mode (no cookie setting, aggregate measurement only) before consent, and full mode after consent:
// Before the GA4 tag
gtag('consent', 'default', {
'analytics_storage': 'denied'
});
// After user gives consent
gtag('consent', 'update', {
'analytics_storage': 'granted'
});
Reading your first reports
GA4 → Reports → Acquisition → Traffic Acquisition: where do visitors come from? In India, organic search and direct traffic typically dominate for small businesses. WhatsApp referrals appear under "referral" or "direct".
Reports → Engagement → Pages and Screens: which pages get the most views? Low-engagement pages with high traffic are candidates for content improvements.
Reports → Monetisation → Overview: if you have e-commerce tracking, shows revenue, transactions, and conversion rate.
Reports → Retention: shows new vs returning visitors. A healthy site has 20–40% returning visitors.
Give GA4 30 days of data before drawing conclusions. Early data is noisy.