How to track website analytics in WordPress
WordPress does not include visitor analytics by default. You can add a Google Analytics 4 tag manually through a child theme or custom plugin, but consent controls, event tracking and troubleshooting make a dedicated analytics plugin the faster option for most sites.
- 01Choose what to measure
- 02Create your analytics property
- 03Add tracking manually
- 04Connect a WordPress dashboard
- 05Configure privacy and exclusions
- 06Verify data before relying on it
- 07Take the faster route
What you need
- Administrator access to the WordPress dashboard
- A live WordPress website
- A Google Analytics 4 property and web data stream, or a privacy-focused analytics plan
- A consent-management setup if your visitors must opt in before analytics loads
Choose what to measure
Decide which questions your reports must answer before adding tracking. Start with page views, users, sessions, traffic sources, popular content and key actions such as contact submissions, downloads or purchases.
Choose between a cloud service such as Google Analytics 4 and locally hosted analytics. A local option keeps reports closer to your WordPress installation, while Google Analytics offers a wider reporting and marketing ecosystem.
Create your analytics property
For Google Analytics, create or select a GA4 property, add a web data stream for the exact site domain, and copy its Measurement ID. Google says the ID is found under Admin, Data streams and Stream details; it normally starts with G-.
Keep one tracking method per property. Adding the same tag through a plugin, the theme and Google Tag Manager can double-count page views.
Add tracking manually
The manual route works without an analytics dashboard plugin: place the provider's tracking snippet in the front-end HTML of every page, normally in the document head. In WordPress, a custom plugin or child theme can output code through the wp_head action, provided the active theme calls wp_head().
Do not edit the parent theme, because an update can overwrite your change. This route is fine for basic page-view reporting, but you must handle consent blocking, logged-in-user exclusions, custom events and future code changes yourself.
Connect a WordPress dashboard
If you want reports inside WordPress, install an established analytics integration and connect it to the property or local data store. Google's Site Kit can connect Analytics, place the tag across the site and show key reports in the WordPress dashboard. It also warns when another Analytics snippet is already present.
For event tracking beyond standard measurements, configure events in Google Analytics 4 or through Google Tag Manager; Site Kit alone does not configure every custom event.
Configure privacy and exclusions
Decide whether analytics should wait for consent, and classify the scripts correctly in your consent tool. If tracking is blocked until consent, visitors who reject analytics will not appear in the reports. Site Kit includes consent-mode settings for certain regions, but your banner and analytics configuration still need to agree.
Exclude administrators and other internal users where possible. Also check that caching, script delay, minification or a security rule is not moving, combining or blocking the tracking code. These changes commonly leave the site looking normal while reports stop receiving data.
Verify data before relying on it
Open the site in a private browser window, visit several pages and trigger any actions you configured. Then check the provider's real-time or debug report. Confirm that the correct property receives the visit, the tag appears once in the page source, and consent changes actually stop or allow tracking.
Do not expect historical data to appear after installation. New properties can take a day or two to populate, and Google notes that missing data can result from an absent tag, an incorrect tag, no traffic or processing delay.
Take the faster route
For a quicker setup with reports inside WordPress, use Burst Statistics Pro. It is suited to sites where data ownership matters because it provides privacy-focused, locally hosted analytics and real-time reports, with configurable reporting and export options.
Install the plugin from Plugins in the WordPress dashboard, activate it, complete its setup prompts and confirm that visits appear in its dashboard. If you also connect Google Analytics, use one clear source for each metric and test for duplicate tracking.
Let Burst Statistics Pro do it
Privacy-focused, locally hosted analytics with real-time reports; choose it over cloud tools when data ownership matters.
Sources
- support.google.com /analytics/answer/14183469?hl=en&utm_source=openai
- developer.wordpress.org /reference/hooks/wp_head/?utm_source=openai
- sitekit.withgoogle.com /documentation/getting-started/install/?utm_source=openai
- sitekit.withgoogle.com /documentation/using-site-kit/event-tracking/?utm_source=ope…
- sitekit.withgoogle.com /documentation/supported-services/analytics/?utm_source=open…
- wordpress.org /support/topic/no-analytics-data-3/?utm_source=openai
- support.google.com /analytics/answer/9311124?hl=en&utm_source=openai
Questions
- Can WordPress track visitors without a plugin?
- Yes, WordPress can send page-view data without an analytics plugin if you add the provider's tracking code through a child theme or custom plugin. The drawback is that you must manage consent blocking, event tracking, user exclusions, updates and testing yourself. For basic traffic reporting this can be sufficient; for ongoing reporting, a dedicated analytics tool is usually easier to maintain.
- Where should Google Analytics code go in WordPress?
- Google Analytics code should load on every page, normally in the document head. You can add it through a supported integration, a child theme or a custom plugin using WordPress's head action. Avoid editing the parent theme, and do not add the same Measurement ID in several places because duplicate tags can inflate page views.
- Why is Google Analytics showing no data from WordPress?
- Google Analytics may show no data because the tag is missing, the Measurement ID is wrong, consent has blocked it, the site has no qualifying traffic yet, or caching and optimisation have altered the script. Check the live page source, test in real-time reports, temporarily disable script delay, and confirm that the correct property and stream are connected.
- Do I need a cookie banner for website analytics?
- You may need a consent mechanism before analytics loads, depending on where your visitors are located, what data the service collects and the laws that apply to your site. Configure the banner to block analytics until the relevant choice is made, and test both acceptance and rejection. A banner that only displays a message but still fires the tag does not implement blocking by itself.
- Should I use Google Analytics or locally hosted analytics?
- Use Google Analytics when you need Google's wider reporting, advertising and Search Console ecosystem. Use locally hosted analytics when keeping data closer to your WordPress site and reducing reliance on a cloud reporting service are more important. Compare the privacy controls, event features, maintenance and reporting needs before choosing, then avoid running both systems unless you have a clear reason.