WordPress GA4 Setup: Fix Your Analytics After Universal Analytics Shutdown
If your WordPress Blog Stopped Tracking Visitors When Universal Analytics Died… (How to Fix It in 15 Minutes)
If you’ve been running a WordPress blog for a while and you set up Google Analytics back in the Universal Analytics days, there’s a good chance your site has been flying blind since Google shut down UA. If you never installed the GA4 replacement tag, your analytics dashboard has been showing zeroes the entire time.
I just discovered this on my own site. I had a GA4 property created (Google nudged everyone to do that during the transition), but the actual tracking tag was never installed on WordPress. The GA4 dashboard literally said “No data received from your website yet.” For a long time.
If you are a hobby blogger like me these things can be easily missed when dealing with real work and life. So here’s how I finally fixed it in about 15 minutes, plus a few bonus cleanups I found along the way.
Step 1: Install the GA4 Tag (The Right Way for WordPress)
There are several ways to get your GA4 measurement tag onto a WordPress site. Here’s what I evaluated:
Site Kit by Google is the official plugin. It handles GA4, Search Console, and other Google services in one dashboard inside WordPress. Reviews are mixed. The main complaints: it slows down the WordPress admin panel because it fetches data from multiple Google services on every page load, and there are reports of it injecting the wrong measurement ID on some sites. The in-WordPress dashboard is its main selling point, but you can just use analytics.google.com directly.
Google Tag Manager is powerful but overkill if all you need is GA4 on a blog. GTM is designed for sites running multiple ad platforms and complex tag sequences.
MonsterInsights, ExactMetrics, Analytify are premium analytics dashboard plugins. If you can read GA4 directly (and you can), you don’t need these.
WPCode (Insert Headers and Footers) is what I went with. It does exactly one thing: lets you paste code into your site’s header, body, or footer. It survives theme updates, adds zero frontend overhead, and has millions of installs. No dashboard analytics, no Google API calls on admin page load, no bloat.
The actual install:
- In WordPress admin: Plugins > Add New > search “WPCode” > Install and Activate
- Go to Code Snippets > Header & Footer
- Paste your GA4 gtag.js snippet into the Header box (you get this from your GA4 property under Admin > Data Streams > your stream > “View tag instructions” > “Install manually”)
- Save
The snippet is just two script tags: one loads the gtag library from Google, the other configures it with your measurement ID. If you’ve ever pasted an analytics snippet before, this is the same drill.
Verify it: View your page source (Ctrl+U in most browsers), search for your measurement ID. If it’s in the <head> section, you’re good. Then check GA4’s Realtime report. You should see your own visit within seconds.
Step 2: While You’re in There, Kill the WordPress Emoji Scripts
While I was viewing the page source to verify the GA4 tag, I noticed something else: a giant block of JavaScript that WordPress injects on every single page to detect whether the browser supports emoji, and if not, loads an external library to render them as images.
Every modern browser has handled emoji natively for years. This is dead weight: extra JavaScript parsing and an external network request on every page load for zero benefit.
Since WPCode was already installed, the fix was easy. Add a new PHP snippet:
In WordPress admin: Code Snippets > Add Snippet > Add Your Custom Code > PHP Snippet
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
add_filter( 'emoji_svg_url', '__return_false' );
Set the Insert Method to “Auto Insert”, Location to “Run Everywhere”, toggle it Active, give it a name like “Disable WP Emoji Scripts”, and save. View source again to confirm the emoji detection block is gone.
This is one of those micro-optimizations that individually doesn’t matter much, but it’s indicative of the kind of cruft that accumulates on a WordPress install over the years. Every unnecessary script adds up. (This is just what I did and it seems to have worked well for me, but always make sure to verify before changing anything you aren’t sure of!)
Step 3: Configure GA4 Enhanced Measurement
Once the tag is firing, go into your GA4 property: Admin > Data Streams > select your web stream.
First, check your Stream URL. If your site was set up a while back, it might still show http:// when your site actually runs on https://. Fix it if so. It won’t break data collection, but it affects how GA4 identifies your site internally.
Then click the gear icon next to “Enhanced measurement.” Make sure all of these are toggled on:
- Page views
- Scrolls
- Outbound clicks
- Site search
- Form interactions
- Video engagement
- File downloads
Outbound clicks is the big one for anyone running affiliate links. GA4 automatically tracks clicks on links that leave your domain. Since affiliate links (Amazon, ShareASale, whatever) point to external domains, they’re captured as outbound clicks by default. No extra plugins or code required.
Step 4: Set Up an Affiliate Click Custom Event
If you want to isolate affiliate clicks specifically (rather than lumping them in with all outbound clicks), GA4 lets you create a custom event from the existing click data. No code changes needed.
In GA4: Admin > Events > Create Event
- Custom event name: something descriptive like
affiliate_click_amazon - Matching conditions:
event_nameequalsclicklink_urlcontainsamazon.com(or whatever your affiliate domain is)
- Check “Copy parameters from the source event”
- Mark it as a key event
This creates a new event that fires every time someone clicks an Amazon link on your site. The copied parameters carry the link URL and page location, so you can later build an Exploration report showing which pages on your site drive the most affiliate clicks. That’s directly actionable for content strategy: write more of what converts, optimize what doesn’t.
Step 5: Verify Google Search Console
This one surprised me. I went to check whether Google Search Console was set up, and it turned out it was already verified and collecting data. If you’ve had a WordPress site for a while, it’s worth checking before assuming you need to set it up from scratch.
Go to search.google.com/search-console while logged into the Google account associated with your site. If a property already exists, you’ll see it.
If you do need to set it up, choose the Domain property type (not URL prefix). A domain property covers all variations of your site: www and non-www, http and https, all subdomains. It requires adding a DNS TXT record at your domain registrar, but it’s a one-time setup.
GSC is more valuable than GA4 for understanding your search traffic. It shows the actual queries people used to find your site, your average position for each query, impressions, clicks, and click-through rate. GA4 tells you what visitors do on your site. GSC tells you how they found it.
The Payoff
Once I had everything wired up and could see real data, the difference was immediate. I could see a clear traffic trend showing growth that lined up with when I started publishing more frequently and targeting specific search queries with practical how-to content.
Without analytics, I was guessing. With analytics, I can see which posts are actually driving traffic, which queries I’m ranking for, and where affiliate clicks are happening. That feedback loop is the difference between blogging into the void and blogging with intent.
The 15-Minute Checklist
For anyone else who lost tracking when Universal Analytics went away:
- Install GA4 tag via WPCode (or any lightweight header/footer plugin). Takes 3 minutes.
- Verify the tag by checking page source and GA4 Realtime. Takes 1 minute.
- Fix your Stream URL if it still says http. Takes 30 seconds.
- Enable all Enhanced Measurement events, especially Outbound clicks. Takes 1 minute.
- Create a custom affiliate click event if you run affiliate links. Takes 5 minutes.
- Verify Google Search Console is set up and collecting. Takes 2 minutes (or 10-15 if you need DNS verification).
Bonus: Remove the WordPress emoji detection scripts while you’re in WPCode. Another 2 minutes.
Total cost: $0. Total time: 15-20 minutes. Total plugins added: 1 (WPCode).