Speed & performance · Guide
How to Add Google Analytics Without Slowing WordPress
Short answer
Add Google Analytics without slowing WordPress by installing GA4 once, through Site Kit or the manual tag, then delaying the tag until after the first paint. Keep the Tag Manager container lean, use async or defer for extra scripts, and confirm visits still arrive in the Realtime report.
Key takeaways
- The GA4 measurement ID starts with G- and lives in Admin, under Data streams.
- Site Kit is Google's free official plugin and needs WordPress 5.2 or newer.
- The dataLayer queue holds events until gtag.js loads, so a delayed tag loses nothing.
- A GA4 session ends after 30 minutes of inactivity by default.
- Standard GA4 properties keep event data for 2 or 14 months.
Does Google Analytics slow down WordPress?
Yes, the standard Google Analytics tag adds JavaScript that the browser must download, parse and run before the page can finish loading.
The tag itself is small, but it pulls in more code from Google's servers. Web.dev explains that third-party scripts keep the main thread busy, and a busy main thread delays both rendering and interaction.
The cost is real but manageable. The tag is a single third-party script, and the fixes in this guide cut its cost without losing the data it collects.
The worst setup is the default one: the full tag pasted in the header on every page, plus a tag manager container, plus extra pixels. Each addition competes with your own content for the same main thread.
What does the Google tag actually load?
The Google tag is a short snippet that loads the gtag.js library and tells it which property should receive the data.
The snippet starts with a comment line reading Global tag (gtag.js), followed by a script tag that loads gtag.js from googletagmanager.com. Google Analytics Help describes this code as the piece you place on your website when you do not use Tag Manager or a CMS integration.
The snippet carries your measurement ID, which starts with G-. Google Analytics Help states that a Google tag ID is a series of letters and numbers that usually starts with G-, and that you need it to set up a GA4 property.
The library loads with the async attribute, so the browser keeps parsing the page while it downloads. That helps, but it does not remove the cost, because the script still runs on the main thread once it arrives.
Once loaded, the tag sends a page view and then any events you configured. GA4 counts everything as an event, including page views, scrolls, outbound clicks and file downloads when enhanced measurement is on.
What do you need before you install GA4?
You need a Google account, a GA4 property with a web data stream, and the measurement ID from that stream.
Create the property at analytics.google.com, then add a web data stream with your site URL. Google shows the measurement ID on the stream details page, and it starts with G-.
Pick one install method and use only that one. Installing the same measurement ID twice, such as once through a plugin and once by hand, double-counts your traffic.
| Install method | Setup effort | Best for |
|---|---|---|
| Site Kit plugin | Low, no code to paste | Most sites that want the simplest route |
| Manual tag | Medium, paste one snippet | Full control over where the code loads |
| Tag Manager | Higher, container setup | Sites that already manage many tags |
Decide how you will handle consent before you install anything. GA4 sets cookies, and many sites need visitor consent first, so check the rules that apply to your audience and set up a consent banner if needed.
Note your current speed baseline before you change anything. Run PageSpeed Insights on the home page and a popular post, and save the scores, so you can tell whether the tag changed them.
How do you add GA4 with Site Kit?
Site Kit is Google's official WordPress plugin, and it is the simplest install route for most sites.
- Go to Plugins, then Add New, and search for Site Kit by Google.
- Install and activate the plugin, then open the new Site Kit menu.
- Connect Site Kit to your Google account and grant the access it asks for.
- Connect the Analytics module and pick the GA4 property you created.
- Save, then visit the site in a private browser window to generate a visit.
WordPress.org describes Site Kit as the official WordPress plugin from Google, and states that it is free. The same page lists the minimum requirements as WordPress 5.2 or newer and PHP 7.4 or newer.
Site Kit adds the tag for you, so you never paste code by hand. It also keeps the tag updated when Google changes it, which a manual paste cannot do.
Site Kit needs a live, publicly reachable site. WordPress.org notes that the site must be publicly accessible and the REST API must be available, so the plugin cannot show data for a site behind maintenance mode.
If Site Kit shows “gathering data” for a few days, that is normal. New properties need time before reports fill in, and the Realtime report is the fastest way to confirm that visits are arriving.
How do you add GA4 with the manual tag?
The manual tag gives you full control over where and when the code loads, and it suits sites that already manage code snippets.
- In GA4, open Admin, then Data streams, and click your web stream.
- Scroll to the Google tag section and click View tag instructions.
- Click Install manually and copy the whole snippet, from the opening comment line to the closing script tag.
- Paste the snippet just after the opening head tag on every page, using your theme's header hook or a code snippet plugin.
- Save, clear the cache, and check the page source for your
G-ID.
Google Analytics Help lists these exact steps: Admin, then Data streams, then View tag instructions, then Install manually.
Paste the snippet once, in one place. A snippet in both the theme and a plugin loads the tag twice, which double-counts page views and doubles the cost.
Do not paste the tag into the footer to “save speed”. The tag is built to load early, and a footer install can miss visitors who leave before the page finishes.
How do you delay the tag until after the page loads?
Delaying the tag moves its work out of the first paint, so visitors see content sooner and the tag still records the visit.
The tag uses the dataLayer array as a queue. Events pushed into the array wait there until gtag.js loads, so nothing is lost when the library arrives late.
One simple method is a small loader script that waits for the first visitor interaction or a short idle pause. The loader creates the gtag.js script tag only after the visitor scrolls, moves the mouse, taps, or after a few seconds of idle time.
Many performance plugins offer a delay switch for scripts. Open the plugin's delay or script settings, add googletagmanager.com/gtag/js to the delayed list, and test the site after saving.
Check the Realtime report after any delay change. Open Reports, then Realtime, visit the site in another tab, and confirm that you appear as an active user.
A delay is safe for page views, but it can miss very short visits. A visitor who leaves within two seconds may never trigger the tag, so weigh the speed gain against a small loss of short-visit data.
How do you cut the tag's cost with Tag Manager?
Google Tag Manager adds a second layer, so use it only when you need its features, and keep the container lean.
Tag Manager loads its own container script, then loads the tags inside it. A container with GA4 plus a chat widget, a heatmap and three pixels costs far more than GA4 alone.
Audit the container every few months. Open Tag Manager, list every tag, and remove the ones no one uses. Old campaign tags and retired tools are the most common waste.
Use async or defer for any extra scripts you add by hand. Web.dev explains that async downloads a script in the background and runs it at the first chance, while defer waits until parsing is done, and it recommends one of the two for every third-party script.
Add a preconnect hint for the tag domain when the tag must load early. A preconnect hint tells the browser to set up the connection to googletagmanager.com before the script is found, which removes the connection delay from the tag load.
Consider a lighter analytics tool when the data you need is simple. Our guide to Google Analytics versus privacy-friendly analytics for WordPress compares the options, including tools that load far less JavaScript.
How do you check that GA4 still records data?
Check the Realtime report first, because it shows visits within seconds, while standard reports lag behind.
Open GA4, go to Reports, then Realtime, and visit your site in a private window. You should appear as an active user, and your page view should show in the report.
Next, open the browser console and look for failed requests to googletagmanager.com. A blocked request usually means an ad blocker or a consent banner is holding the tag back.
Then check the data settings you may have missed. GA4 keeps event-level data for 2 months by default, and standard properties can choose 14 months instead. Google for Developers lists both values, plus 26, 38 and 50 months for Analytics 360 properties.
Also confirm the session settings. Google Analytics Help states that a session ends after 30 minutes of inactivity by default, and that an engaged session lasts longer than 10 seconds, has a key event, or has at least 2 page views.
Finally, compare the numbers with another source, such as your host's traffic stats. A large gap between GA4 and the server logs usually means the tag is missing from some pages or blocked for some visitors.
What mistakes make Analytics slower than it needs to be?
Installing the tag twice is the most common mistake, and it double-counts traffic as well as doubling the cost.
Loading extra pixels through the same container is the second mistake. Each pixel adds its own download and main-thread work, and most of them can be removed or delayed.
Forgetting the consent banner is the third mistake. A banner that blocks the tag until consent still loads the tag code in some setups, so check that a declined visitor truly loads nothing.
Ignoring the audit warnings is the fourth mistake. Web.dev recommends measuring load time at least three times when you compare setups, because third-party scripts fetch different resources on each load.
A single change can look like a win or a loss by chance. Run PageSpeed Insights three times before and after each change, then compare the middle result rather than the best one.
Pair this work with the rest of your speed routine. Our guide to pass Core Web Vitals in WordPress covers the checks that matter.
It also helps to know why the effort pays off. Our guide on whether page speed affects SEO explains the link between speed and search results.
Track the events that matter once the tag is lean. Our guide to track ChatGPT traffic in Google Analytics shows how to set up one useful event without adding another script.
Frequently asked questions
Does Google Analytics always slow down a site?
Yes, the standard install adds JavaScript that must download, parse and run on the main thread. The tag is small, but the cost is real, so delay it until after the first paint and keep extra pixels out of the container.
Why is my traffic double-counted in GA4?
Install the tag once, through one method only. If you use both Site Kit and a manual paste, or both a plugin and Tag Manager, the same measurement ID loads twice and your traffic is double-counted.
How do I check that GA4 is actually recording visits?
Open Reports, then Realtime, and visit the site in a private window. You should appear as an active user within seconds. If nothing appears, check for a consent banner, an ad blocker or a tag installed on the wrong pages.
Will delaying the tag lose all my data?
No, unless the delayed tag never gets a chance to load. A visitor who leaves within two seconds may not trigger it, so you trade a small loss of short-visit data for a faster first paint.
How long does GA4 keep my data?
GA4 keeps event-level data for 2 months by default, and standard properties can choose 14 months instead. Change it in Admin, under Data settings, then Data retention, as soon as you set up the property.
Should I switch to a privacy-friendly analytics tool instead?
Yes, if your audience needs consent and the tool stores no cookies or personal data. Lighter tools load far less JavaScript, so they cost less speed, but they record fewer details than GA4.
Sources
- Find your Google tag ID Google Analytics Help
- Site Kit by Google WordPress.org
- Load third-party JavaScript web.dev
- Session Google Analytics Help
- DataRetentionSettings Google for Developers
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
