21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

How to Add Google Analytics to WordPress

Quick answer

Create a GA4 web data stream and copy its Measurement ID, which starts with G-. On self-hosted WordPress, install Site Kit by Google and connect that property, or paste the Google tag through a child theme. Then open the Realtime report and visit the site: one active user confirms the tag works.

A step-by-step setup for WordPress site owners who want accurate GA4 data from day one, without double counting or a tag lost to a theme update.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
4 min
Sections
6
Updated
14 Nov 2026
Written by
WebJi® team

What do you need from Google Analytics before touching WordPress?

You need one thing: the Measurement ID of a GA4 web data stream, which starts with G- followed by letters and numbers. An ID that starts with UA- belongs to Universal Analytics, which Google has retired, and it will not fill any GA4 report.

  1. Sign in at analytics.google.com with the Google account that should own the data, ideally a business account rather than a developer's personal one.
  2. Create an account, then a property. Set the reporting time zone to India (GMT+05:30) and the currency to Indian Rupee if you sell in INR.
  3. Choose Web as the platform, enter the site URL (for example https://yourdomain.in) and a stream name.
  4. Leave Enhanced measurement on. It records page views, scrolls, outbound clicks, site search, video engagement and file downloads without extra code.
  5. Copy the Measurement ID shown on the stream details screen.

If the site runs on WordPress.com rather than your own hosting, a paid plan lets you paste that ID into the site's Traffic settings instead. Everything below is for self-hosted WordPress, the kind that runs on WordPress hosting.

Which way should you add Google Analytics to WordPress?

Use Site Kit by Google for a normal site where you can install plugins, a manual Google tag when plugins are not an option, and Google Tag Manager when the site already fires ad or other marketing tags. Pick exactly one. Two installs on the same page count every visit twice.

Three ways to install GA4 on self-hosted WordPress
MethodBest whenMain risk
Site Kit by GoogleOne site, plugins allowed, you want reports in wp-adminSomeone also pastes the tag by hand
Manual Google tagPlugin count is restricted, or you keep a child themeEditing the parent theme, which an update overwrites
Google Tag ManagerGoogle Ads, Meta pixel or other tags share one containerForgetting to publish the container

How do you connect GA4 with Site Kit by Google?

Install and activate Site Kit, sign in with the Google account that owns the GA4 property, and select that property; the plugin then places the tag on every page. Do this on the live domain, because Google has to reach the site to verify it.

  1. In wp-admin open Plugins → Add New, search "Site Kit by Google", then click Install Now and Activate.
  2. Open Site Kit in the left menu and click Start setup. Sign in and grant the permissions it requests.
  3. Let Site Kit verify ownership. A coming-soon plugin, maintenance mode or password protection makes this step fail, so switch them off first.
  4. Accept the Search Console connection if offered. It confirms you control the domain; it does not change rankings.
  5. Choose Set up Google Analytics, pick the property and web stream for this domain, and confirm the ID matches the G- code you copied.

Site Kit also shows a traffic summary in the WordPress dashboard. The Google Search Console guide explains the search data it pulls in alongside Analytics.

How do you add the Google tag to WordPress without a plugin?

Paste the Google tag into the <head> of every page through a child theme's functions.php, never by editing the parent theme's header.php. A theme update replaces parent files, and the tag disappears without warning.

In GA4 open Admin → Data streams, select the stream and choose View tag instructions → Install manually. The snippet looks like this; replace both G-XXXXXXXXXX values with your ID. In a child theme, add it to functions.php:

add_action( 'wp_head', function () { ?>
<!-- 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>
<?php }, 1 );

The priority 1 places the tag near the top of the head. Save, open the homepage source (Ctrl+U) and search for your G- ID. If it is missing, a page cache is still serving old HTML: clear the WordPress cache and check again.

When does Google Tag Manager make more sense for GA4?

Tag Manager makes sense when the site needs several tracking tags — Google Ads conversions, a Meta pixel, call tracking — managed from one place without editing code each time. It is a container that loads other tags, not an analytics report.

Install the container snippet once (Site Kit can place it, or use the same child-theme method). Inside Tag Manager create a Google tag with your G- ID, set it to fire on all pages, then click Submit → Publish. An unpublished container sends nothing. If GA4 is the only tag you need, Site Kit is the shorter route.

How do you check that Google Analytics is recording visits?

Open Reports → Realtime in GA4, visit your site in a private browser window, and you should appear as one active user within about a minute. Standard reports take longer and can stay empty for 24 to 48 hours after the first hit.

  • One ID only: the page source contains a single G- ID and no old UA- code.
  • No doubled page views: if Realtime shows two page views per load, two installs are active.
  • DebugView: with the Google Tag Assistant open, Admin → Data display → DebugView shows each event as it fires.
  • Ad blockers: test with blockers off; they stop the tag in your own browser.

Which GA4 settings should you change after installing it?

Change two defaults in the first week: extend data retention to 14 months and filter out your own office traffic. Both apply only from the day you change them, so earlier data cannot be fixed later.

  1. Data retention: Admin → Data collection and modification → Data retention. The default keeps event-level data for 2 months; switch it to 14 months.
  2. Internal traffic: Admin → Data streams → your stream → Configure tag settings → Define internal traffic, and add your office's public IP address.
  3. Activate the filter: Admin → Data filters, open "Internal Traffic" and change it from Testing to Active.
  4. Key events: mark actions that matter, such as a form submission or a purchase, so later reports show which pages lead to them.

Analytics collects visitor data, so mention it in your privacy notice; the DPDP compliance page covers India's consent and notice duties. Turning the reports into a content plan is separate work that WordPress SEO handles.

FAQ

Frequently asked questions

Is Google Analytics free for a WordPress site?

Yes. A standard GA4 property has no fee, and Site Kit by Google is a free plugin. Only Google's enterprise product, Analytics 360, is paid, and small and medium sites do not need it.

Why are my GA4 reports empty a day after installing the tag?

Standard reports can take 24 to 48 hours to populate. If Realtime also shows nothing, the tag is not firing: check the page source for your G- ID, clear the page cache, and switch off maintenance mode or a coming-soon plugin.

Can I move from a manual tag to Site Kit later?

Yes. Remove the manual snippet from the child theme first, then connect Site Kit to the same GA4 property. Your historical data stays in the property because it is stored by Google, not on your WordPress site.

Does adding Google Analytics slow down WordPress?

Very little. The gtag.js script loads asynchronously, so it does not block the page from rendering. A heavy analytics plugin with its own dashboards adds more load to wp-admin than the tag adds to the public site.

Last editorial update: 14 November 2026.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.