Google Analytics 4

How to Install Google Analytics 4 on Your Website

Step-by-step instructions to install GA4 on WordPress, Shopify, Squarespace, and custom websites. Takes about 15 minutes.

8 min read
Quick answer

Install GA4 by creating a property in Google Analytics, copying your G- Measurement ID, and adding it to your site through a plugin, your CMS, or Google Tag Manager. The whole process takes about 15 minutes and needs no code.

By the end of this tutorial, you’ll have Google Analytics 4 installed on your website and collecting real visitor data. The whole process takes about 15 minutes.

Before you start

You’ll need:

  • A Google account (Gmail works fine)
  • Access to your website’s admin panel or code
  • About 15 minutes

If you don’t have a GA4 property yet, start with our GA4 beginner’s guide, which walks through creating your account and property.

If you already have your Measurement ID (starts with G- followed by 10 characters), you’re ready to go.

Step 1: Get your Measurement ID

Sign in to analytics.google.com.

Click the gear icon (Admin) in the bottom left corner.

Under your property, click Data Streams, then click your web stream.

Your Measurement ID is at the top of the panel. It looks like G-AB12CD34EF. If you get stuck, our guide to finding your Measurement ID walks through it with a screenshot.

You should see: A code starting with “G-” followed by 10 characters. Copy it. You’ll paste it in the next step.

If you see a code starting with “UA-” instead, you’re looking at a Universal Analytics property. You need to create a new GA4 property first.

Step 2: Install on your platform

Pick your platform below and follow the steps.

WordPress

Option A: Use a plugin (recommended for most people)

  1. Install the Site Kit by Google plugin. Go to Plugins > Add New, search for “Site Kit by Google,” and install it.
  2. Activate the plugin and click Start Setup.
  3. Sign in with your Google account and grant the permissions it asks for.
  4. Site Kit will detect your GA4 property or let you select one. Choose the one with your Measurement ID.
  5. Click Complete Setup.

That’s it. Site Kit handles the tracking code automatically.

Option B: Paste the code manually

If you prefer not to use a plugin:

  1. Go to GA4 > Admin > Data Streams > your stream > View tag instructions.
  2. Click the Install manually tab. Copy the entire code block.
  3. In WordPress, go to Appearance > Theme File Editor (or use a header/footer plugin like Insert Headers and Footers).
  4. Paste the code right before the closing </head> tag.
  5. Save.

For a deeper walkthrough of all the WordPress methods, including MonsterInsights, see our full guide to installing GA4 on WordPress.

Shopify

Shopify’s supported method is the official Google & YouTube app. (The old Google Analytics field under Online Store > Preferences has been retired.)

  1. In your Shopify admin, go to Settings > Apps and sales channels and install the Google & YouTube app.
  2. Open the app and connect your Google account.
  3. Select your GA4 property and confirm.

The app adds the tracking code to every page and also sends Shopify’s e-commerce events (like add_to_cart and purchase) to GA4 automatically. The full walkthrough, including how to verify purchases are tracking, is in our guide to installing GA4 on Shopify.

Squarespace

  1. In Squarespace, go to Settings > Developer Tools > External API Keys.
  2. Find the Google Analytics field.
  3. Paste your Measurement ID.
  4. Click Save.

Custom HTML site

If you built your site from scratch or use a CMS not listed above:

  1. Go to GA4 > Admin > Data Streams > your stream > View tag instructions.
  2. Click the Install manually tab.
  3. Copy the code block. It looks something like this:
<!-- 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>
  1. Paste this code into the <head> section of every page on your site. If your site uses a template or layout file, paste it there once and it’ll apply everywhere.

Prefer Tag Manager? If you plan to add more tracking later (ad pixels, click tracking), consider installing GA4 through Google Tag Manager instead. You’ll need GTM installed first.

Step 3: Verify the installation

This is the part people skip. Don’t skip it.

  1. Open your website in a new browser tab.
  2. Click around a few pages.
  3. Go back to GA4 and click Reports > Realtime.

You should see: Your visit showing up. There should be a “1” under “Users in last 30 minutes,” and you should see the pages you visited listed below.

If you see your activity, the installation is working.

If you don’t see any data

Here are the most common reasons:

  • Ad blocker. If you have an ad blocker or privacy extension, it might be blocking GA4. Try in an incognito window with extensions disabled.
  • Caching. If your site uses caching (common on WordPress), the old cached version of your pages might not have the tracking code yet. Clear your site cache and try again.
  • Wrong Measurement ID. Double-check that the ID you pasted matches what’s in your GA4 property.
  • Code placement. The tracking code needs to be in the <head> section, not the <body>. Some themes put custom code in the wrong place.

Step 4: Configure the basics

Now that GA4 is installed, do these three things before you forget:

Set data retention to 14 months

By default, GA4 only keeps your detailed data for 2 months. That’s not enough for year-over-year comparisons.

Go to Admin > Data collection and modification > Data retention. Change “Event data retention” to 14 months. Click Save.

Turn on Enhanced Measurement

This should be on by default, but check.

Go to Admin > Data Streams > your stream. Click the Enhanced Measurement toggle area. Make sure these are enabled:

  • Page views
  • Scrolls
  • Outbound clicks
  • Site search
  • File downloads
  • Video engagement (if you embed YouTube videos)

Enable Google Signals

This helps GA4 better understand your users across devices.

Go to Admin > Data collection and modification > Data collection. Turn on Google Signals data collection.

What happens next

GA4 is now collecting data on your website. A few things to know:

  • Realtime data shows up within seconds. You can use this to verify things are working anytime.
  • Standard reports take 24 to 48 hours to populate. Don’t worry if the main reports look empty right now.
  • The data builds over time. GA4 gets more useful the longer it runs. Give it a week or two before drawing conclusions.

Your next step: once you have a few days of data, check out your Reports > Acquisition > Traffic Acquisition report. It shows you where your visitors are coming from: organic search, social media, direct, referral, paid ads. That single report answers the question most marketers ask first: “Where is my traffic coming from?”

Frequently asked questions

Can I install GA4 on multiple websites with the same account?
Yes. One Google Analytics account can have multiple properties. Create a separate property for each website, and each gets its own Measurement ID and tracking code.
Will GA4 slow down my website?
The impact is minimal. The GA4 tracking script loads asynchronously, meaning it doesn't block your page from rendering. If you're concerned, install GA4 through Google Tag Manager, which gives you more control over when scripts load.
I installed GA4 but don't see any data. What's wrong?
Check these things in order: 1) Make sure your ad blocker is off or test in incognito. 2) Clear your site cache if you're on WordPress. 3) Verify the Measurement ID matches your GA4 property. 4) Check that the code is in the head section, not the body. 5) Wait 24 to 48 hours for standard reports. Only Realtime shows data immediately.
Do I need to install GA4 on every page of my website?
The tracking code needs to be on every page, but most installation methods handle this automatically. WordPress plugins, Shopify's built-in integration, and Google Tag Manager all add the code site-wide. If you're pasting code manually, put it in your site's shared header template so it applies everywhere.

Keep learning