Free auditStart free
GuideWordPress · Analytics

Google Analytics on WordPress

Two documented ways to add GA4 to WordPress, the Site Kit plugin or the gtag.js snippet, with the Measurement ID path and a check that data arrives.

4 min
read
4
sources
Oct 31, 2026
updated
Scaplet Editorial Team
author
In one line

Add GA4 to WordPress with Google's Site Kit plugin, or paste the Google tag into your site's head yourself. Either way you need the Measurement ID from your web data stream, which starts with "G-". Pick one method, not both, then confirm with Tag Assistant or the Realtime report.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Your call

Pick a method first

If this fits

Use Site Kit if

  • You want setup without editing your site's source code
  • You also want Search Console numbers on the WordPress dashboard
  • Several people manage the site and each can connect their own Google account
Or

Paste the tag yourself if

  • You already manage theme code or a code-snippet plugin
  • You want one small script and no dashboard plugin
  • Another tool already holds your Measurement ID and you only need the snippet in the head

Google's own tag guide says it recommends Google Tag Manager for deploying tags. Site Kit also lists Tag Manager among the tools it can set up, so that route exists on WordPress too. This page covers the two direct routes.

02How it works

Find the Measurement ID

  1. 1

    Open the data stream

    In Google Analytics, go to Admin. Under Data collection and modification, click Data streams, then click the web stream for your site.

  2. 2

    Copy the ID

    Under Stream Details, copy the Measurement ID. Google's help page says it starts with "G-" or "AW-".

  3. 3

    No stream yet

    Click Add stream, choose Web, enter your site URL and a stream name, then click Create stream. Google recommends leaving enhanced measurement on, and says you can switch individual events off later.

Google's setup page says you must be an Editor or above on the Google Analytics account at the property level to add a data stream.

03How it works

Method 1: Site Kit

Site Kit requirements on the plugin listing
RequirementWhat the listing says
WordPress and PHPWordPress version 5.2+ and PHP version 7.4+
Public siteNot in maintenance mode, accessible only via password, or otherwise blocked
REST APIMust be available. Check under Tools > Site Health
CostThe plugin is free and open source
  1. 01

    Install

    In WordPress go to Plugins > Add New, search for Site Kit by Google, then install and activate it.

  2. 02

    Connect your Google account

    Follow the setup flow in the new Site Kit menu. The plugin listing says that with multiple WordPress admins, each admin must connect their own Google account.

  3. 03

    Add Analytics

    The plugin listing says to connect additional Google tools under Site Kit > Settings. Analytics is one of the tools it supports.

04Check it

Method 2: paste the Google tag

Google's help page says to open Admin > Data streams > your web stream > View tag instructions under Google tag, then choose Install manually. Google's gtag.js guide gives this snippet and says to place it immediately after the opening <head> tag on every page you want to measure.

On WordPress the head is printed by the theme's header.php through the wp_head() function, which fires the wp_head action. WordPress's hook reference says that although this is theme-dependent, it is one of the most essential theme hooks and is widely supported. Add your snippet through that hook, in a child theme or a code-snippet plugin, so a theme update does not erase it. Replace TAG_ID with your Measurement ID.

Google tag, from Google's gtag.js guide
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'TAG_ID');
</script>
05How it works

Check it worked

Google says Analytics sends a page_view event automatically when the config command is called, unless you set send_page_view to false. If you see the library load but no hits, check the Console for errors. Site Kit's listing adds that a "gathering data" message can last a few days after connecting a new Google service.

  1. 01

    Network tab

    Open the live site in Chrome, open Developer Tools, go to the Network tab and refresh. Requests to googletagmanager.com mean the tag is firing. For Analytics, Google says to filter for google-analytics.com or analytics.google.com.

  2. 02

    Tag Assistant

    Go to tagassistant.google.com, click Add domain, enter your URL starting with "https://" or "http://", and click Connect. Your tag ID should appear under Google tags found.

  3. 03

    Realtime report

    Google says data collection may take up to 30 minutes to begin, after which the Realtime report should show your own visit.

Sources · 4

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • wordpress.org
  • google.com
  1. 01Site Kit by Google | WordPress.org plugin directorywordpress.org · checked 2026-11-01
  2. 02Set up Analytics for a website and/or app | Analytics Helpsupport.google.com · checked 2026-11-01
  3. 03Set up the Google tag with gtag.js | Google for Developersdevelopers.google.com · checked 2026-11-01
  4. 04wp_head | WordPress Developer Resourcesdeveloper.wordpress.org · checked 2026-11-01
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Where do I find my GA4 Measurement ID?

In Admin, under Data collection and modification, open Data streams and click your web stream. Copy the Measurement ID under Stream Details. Google's help page says it starts with "G-" or "AW-".

02Do I need a plugin to add Google Analytics to WordPress?

No. Google documents pasting the Google tag immediately after the opening head tag on each page. A plugin such as Site Kit does that for you without editing code.

03How long until GA4 shows data?

Google says data collection may take up to 30 minutes to begin, and the Realtime report can then confirm it. Site Kit's own dashboard can show a gathering data message for a few days after you connect a new service.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane