Most WordPress sites have analytics installed and still cannot answer the only question that matters: where do enquiries come from? You can see that 114 people visited. You cannot see that two of them opened the chat, one downloaded your CV, and none of them came from Google.
This is how to fix that without Google Tag Manager and without an analytics plugin. It is roughly fifty lines of code in two files. I did it on this site in an afternoon, and I hit two traps on the way that are worth more than the code itself.
Pageviews are not leads
GA4 out of the box tells you pages, sessions and traffic sources. That is useful for a publisher. For a business site with one conversion path, it tells you almost nothing, because the thing you care about — someone deciding to contact you — leaves no trace in a pageview report.
What you actually want is a short list of named actions, each tied to the page it happened on and the channel the visitor arrived from. Then "organic search sent 0 sessions" becomes an answerable problem instead of a vague worry.
Pick four key events, not fourteen
GA4 lets you mark events as key events (formerly conversions). The temptation is to mark everything. Do not — if everything is a conversion, nothing is, and your reports become unreadable.
Pick the four that represent a real person taking a real step. On this site those are:
generate_lead— a chat message actually sentemail_click— someone chose email over chatcv_download— an employer or recruiter took the next stepupwork_click— someone went looking for a hiring route
Everything else — opening the chat, picking a topic, clicking a project — is still tracked, but as a normal event. Those tell you why the key events did or did not happen.
Custom events without Tag Manager
If GA4 is already hand-coded in your theme or a small plugin, adding Tag Manager means maintaining a second system for no benefit. Plugins like Site Kit or MonsterInsights add weight and still will not see a custom chat widget.
Define one safe wrapper next to the gtag snippet:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
window.ibgTrack = function (name, params) {
try { gtag('event', name, params || {}); } catch (e) {}
};
</script>
The try/catch matters. If an ad blocker kills gtag, every call becomes a no-op instead of a JavaScript error that breaks the rest of your page.
Then one delegated listener covers every outbound and CTA click on the site:
document.addEventListener('click', function (e) {
var a = e.target.closest && e.target.closest('a');
if (!a || !window.ibgTrack) return;
var href = a.getAttribute('href') || '';
if (href.indexOf('mailto:') === 0) {
ibgTrack('email_click', { link_text: a.textContent.trim() });
}
// ...and so on per link type
}, true);
Two details people get wrong here. Use the capture phase (the true argument) so the event still records on a click that navigates away. And attach one listener to the document rather than a listener per link, so links added later still work.
Stop counting your own visits
If you build and edit the site, you are in your own data. On a site with low traffic this is not a rounding error — it can be most of it. GA4's IP filter does not help much if your home IP changes, which on many consumer connections it does.
The reliable fix is server-side. Load gtag only for people who are not logged in as an editor:
$load_ga = !current_user_can('edit_posts');
Define the tracking wrapper for everyone, but only load gtag.js when that is true. Your own sessions then stop existing as far as GA4 is concerned, regardless of IP.
The duplicate-tag trap
This one cost me an hour, so it is worth stating plainly.
If you hand-code gtag and install Google Site Kit, Site Kit will inject its own tag as soon as you connect Analytics. It does not necessarily use the same ID string you did — it may emit a Google Tag container (GT-XXXXXXXX) that resolves to the same GA4 property. Two loaders, two config calls, one destination. Every pageview counted twice.
The symptom is subtle: sessions look healthy, bounce rate looks suspiciously good, engagement time looks halved. Nothing errors.
Check your page source for more than one googletagmanager.com/gtag/js script. If you find two, pick one owner. Keeping the hand-coded tag and switching off Site Kit's snippet (Site Kit → Analytics → Settings → uncheck "Place Google Analytics code") keeps your custom events working and keeps Site Kit's dashboard.
How to actually verify events are sending
This is the part almost every tutorial gets wrong, and it nearly made me report a working setup as broken.
I fired a test event and checked the browser's Resource Timing API for a request to Google's collect endpoint. Nothing. I checked again with a different tool. Still nothing. On that evidence the events were silently failing.
They were not. GA4's collect request does not reliably appear in Resource Timing, so an absence there proves nothing at all.
Three checks that do work, in increasing order of certainty:
- Cookies. GA4 sets a property-specific cookie named
_ga_<YOUR-ID>. If that exists, gtag initialised against that exact property. If it is missing, your tag is not working. - DevTools → Network, filtered to
collect. Fire an action and watch for the request. Check thetidparameter matches your measurement ID andenmatches your event name. - Patch the transport. Temporarily wrap
window.fetchin the console and log any URL containingcollect. This is the only method that cannot lie to you.
Use GA4's DebugView as well, but remember it can lag, and an empty DebugView is not proof of a broken tag either.
Then actually read it
Tracking you never look at is just overhead. Once a month, one report: key events split by session source and by landing page. That answers two questions — which channel produces enquiries, and which page they were on when they decided.
Give it four to eight weeks before drawing conclusions. Below a few hundred sessions a month, a single week tells you nothing.
The short version
- Track actions, not pageviews. Four key events, no more.
- A wrapper plus one delegated listener beats a tag manager for a site this size.
- Exclude yourself server-side, not by IP.
- Check for a second gtag script before you trust any number.
- Verify with cookies and the network tab — never conclude from Resource Timing.
