Google Analytics 4 Setup Guide: Track What Actually Matters
Google Analytics 4 has been around for a while now, but I still talk to site owners who either haven't set it up or are completely lost in the new interface. If that's you, don't worry. This guide will get you up and running, and I'll share a trick that most guides don't mention: how to serve your tracking scripts from your own domain to avoid ad blockers.
Why GA4 Matters for SEO
Before we dive in, let's address the elephant in the room: why should you care about analytics for SEO?
Simple. You need to know:
- Which pages are actually getting traffic
- How people behave once they land on your site
- Where your visitors come from
- What content keeps people engaged vs. what makes them bounce
Google Search Console tells you how people find you. Google Analytics tells you what they do after they arrive. You need both.
Setting Up GA4 From Scratch
Step 1: Create Your GA4 Property
- Go to analytics.google.com
- Click Admin (gear icon at the bottom left)
- Click "Create Property"
- Enter your property name and set your timezone/currency
- Answer the business questions (these don't affect functionality)
- Choose "Web" as your platform
- Enter your website URL and stream name
You'll get a Measurement ID that looks like G-XXXXXXXXXX. Save this.
Step 2: Add the Tracking Code
Google gives you a script that 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>
Add this to the <head> section of every page on your site. If you're using a CMS like WordPress, there are plugins that make this easy. For custom sites, add it to your main template.
Step 3: Verify It's Working
After adding the code:
- Go to your website in a new browser tab
- In GA4, click "Reports" then "Realtime"
- You should see yourself as an active user
If you don't see anything, wait a few minutes and make sure you don't have an ad blocker enabled.
The Ad Blocker Problem (And How to Fix It)
Here's something most GA4 guides won't tell you: up to 30-40% of your visitors might be using ad blockers, and most ad blockers also block Google Analytics.
That means your traffic numbers could be significantly underreported. Not great when you're trying to make data-driven decisions.
The Solution: Self-Host Your Tracking Script
Instead of loading the tracking script from Google's servers, you can serve it from your own domain. Ad blockers typically work by blocking requests to known tracking domains like googletagmanager.com. If the script comes from yourdomain.com/js/analytics.js, it usually gets through.
Here's how to do it:
Option 1: Simple Proxy Approach
Create a route on your server that proxies the Google Analytics script:
// For Laravel/PHP
Route::get('/js/g.js', function () {
$script = file_get_contents('https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX');
return response($script)->header('Content-Type', 'application/javascript');
});
Then update your tracking code:
<script async src="/js/g.js"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Option 2: Download and Host Locally
For better performance, download the script and host it as a static file:
- Download the script:
curl https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX > public/js/gtag.js - Update your HTML to reference
/js/gtag.js - Set up a cron job to re-download it weekly (Google occasionally updates it)
Option 3: Use a Server-Side Proxy for All Requests
The most robust solution proxies both the script AND the data collection endpoint. This requires more setup but catches nearly all ad blocker scenarios.
You'd set up routes like:
/js/g.js- serves the gtag script/collect- proxies data to Google's collection endpoint
Then modify the gtag config to use your proxy endpoint:
gtag('config', 'G-XXXXXXXXXX', {
'transport_url': 'https://yourdomain.com/collect',
'first_party_collection': true
});
Important Considerations
- Respect user privacy: Some users intentionally block tracking. Consider whether you want to circumvent that choice.
- Performance: Self-hosting can actually improve load times since you eliminate an external request.
- Maintenance: You'll need to occasionally update the local copy of the script.
- Legal compliance: Make sure your privacy policy discloses the use of analytics.
Understanding the GA4 Interface
GA4's interface is different from Universal Analytics. Here's what matters:
Reports Overview
The main sections you'll use:
Realtime: See what's happening right now. Great for testing.
Acquisition: Where your traffic comes from (organic search, social, direct, etc.)
Engagement: What people do on your site. Look at:
- Pages and screens (which pages get views)
- Events (what actions people take)
- Conversions (goals you've set up)
Retention: How many people come back. Important for blogs and recurring content.
Key Metrics to Watch
Engaged Sessions: Sessions where someone stayed at least 10 seconds, had a conversion, or viewed 2+ pages. Much more useful than raw session count.
Engagement Rate: Percentage of sessions that were engaged. Better than bounce rate.
Average Engagement Time: How long people actually spend interacting with your content.
Views per User: How many pages each visitor sees on average.
Setting Up Conversions
In GA4, conversions are based on events. To set one up:
- Go to Admin > Events
- Find an existing event or create a new one
- Toggle "Mark as conversion"
Common conversions to track:
- Form submissions
- Newsletter signups
- Contact page visits
- Time on site thresholds
Connecting GA4 with Search Console
This is where things get powerful. Connect your GA4 to Google Search Console to see search data alongside behavior data.
- In GA4, go to Admin > Product Links > Search Console Links
- Click "Link"
- Select your Search Console property
- Choose your web stream
- Submit
Now you'll see a Search Console report in GA4 showing:
- Which queries bring traffic
- Landing page performance
- Click-through rates
Combined with the behavior data already in GA4, you get the complete picture.
Quick Wins for Better Data
1. Filter Out Your Own Traffic
Don't pollute your data with your own visits:
- Go to Admin > Data Streams > your stream > Configure tag settings
- Define internal traffic
- Add your IP address
2. Enable Enhanced Measurement
GA4 can automatically track:
- Scroll depth
- Outbound link clicks
- Site search
- Video engagement
- File downloads
Go to Admin > Data Streams > your stream and make sure Enhanced Measurement is on.
3. Set Up Custom Events
Track what matters to your business. For an SEO blog, you might track:
- Tool usage
- PDF downloads
- Time reading articles
- Social shares
4. Create Custom Reports
The Explore feature lets you build exactly the reports you need. Start with templates and customize from there.
Integrating with SEO Rank Tracker
While GA4 is great for understanding user behavior, SEO Rank Tracker helps you act on that data. And the best part? The core features are completely free:
Free features:
- Performance tracking: Monitor your search traffic, impressions, and rankings over time
- Automatic indexing: We scan your sitemap daily and automatically submit new pages to Google. No more manual work!
- Historical data: Keep your data longer than Google's 16-month limit
Paid features for power users:
- Correlate rankings with traffic: See how position changes affect visits
- AI-powered recommendations: Get specific suggestions for each page
- Priority scoring: Know which pages to optimize first
The best SEO strategy combines Google Search Console (how people find you), Google Analytics (what they do), and SEO Rank Tracker (automate indexing and track progress).
Final Thoughts
Setting up GA4 isn't hard. The hard part is actually using the data to make better decisions. Here's my advice:
- Start simple: Focus on traffic sources and top pages first
- Check weekly: Build a habit of reviewing your data
- Act on insights: Data is useless unless you do something with it
- Consider the ad blocker issue: If accurate numbers matter, self-host your scripts
Your website is generating data every day. Make sure you're capturing it, understanding it, and using it to grow.