How to Install Google Analytics 4 on Website
Getting Google Analytics 4 set up on your website is the very first step to understanding what your visitors are doing. This guide will walk you through the entire process, including creating your GA4 property and showing you the three most common ways to install the tracking code. We'll cover the best-practice method using Google Tag Manager, the direct code snippet approach, and the easiest options for CMS platforms like WordPress.
First, Create Your Google Analytics 4 Property
Before you can install anything, you need a GA4 "property" to send data to. Think of this property as a dedicated folder within your Google Analytics account for your website's data. If you already have an older Universal Analytics property, you’ll still need to create a new one for GA4.
The process is straightforward:
- Log in to your Google Analytics account. If you don't have one, you can sign up with your existing Google account.
- Go to the Admin section by clicking the gear icon in the bottom-left corner.
- In the "Property" column, click the blue + Create Property button.
- Give a name to your property (e.g., "My Business Website"), select your reporting time zone, and choose your currency. Click Next.
- Provide some basic business information. This is optional and helps Google provide you with more relevant benchmark data.
- Now comes the important part: setting up a "data stream." A data stream is simply your source of data. Since you're tracking a website, click the Web option.
After clicking "Web," you'll be asked for your website's URL (make sure you select http:// or https:// correctly) and a name for your stream (like "Website Stream").
Once you click "Create stream," a page will appear with all your stream details. Look for the Measurement ID in the top right, which starts with "G-". This is the unique identifier for your website's data stream. Copy it down - you'll need it for every installation method.
Choose Your Installation Method
Now that you have your Measurement ID, you need to add the GA4 tracking code to your website. There are a few ways to do this, ranging from very simple to slightly technical. We'll cover the three main paths you can take.
Method 1: Use Google Tag Manager (The Recommended Way)
Google Tag Manager (GTM) is a free tool that acts as a "container" for all the marketing and analytics tags on your website. Instead of adding a dozen different code snippets directly to your site, you add them all through GTM's interface. This is the preferred method because it’s flexible, powerful, and means you rarely have to bother a developer to add new tracking scripts.
If you don't have a GTM account yet, head to tagmanager.google.com to create one. It will give you one code snippet to install on your website to get started.
Here's how to add the GA4 tag in GTM:
- Create a New Tag: From your GTM workspace, click on "Tags" in the left-hand menu and then click the "New" button.
- Configure the Tag:
- Enter Your Measurement ID: In the field that appears, paste the "G-" Measurement ID you copied earlier. No other settings are needed here for an initial setup, leave "Send a page view event when this configuration loads" checked.
- Set Up the Trigger: Next, click inside the "Triggering" box. A trigger tells GTM when to fire your tag. For a basic setup, you want it to fire on every page.
- Save and Publish: Save your tag. Now for the most important step: click the blue "Submit" button in the top right of your GTM workspace. Give your new version a name (e.g., "Added GA4 Tag") and click "Publish." If you forget to publish, your tag won't go live.
That's it! GTM is now loading the GA4 script on every page of your website.
Method 2: Directly Add the ‘gtag.js’ Code Snippet (Manual)
If you prefer not to use Google Tag Manager, you can add Google's global site tag (gtag.js) directly to your website’s code. This is a good option if you’re comfortable editing HTML files or have a simple website with very few marketing tags.
Warning: Be careful when editing your website’s core files. A single mistake could break your site. If you're not comfortable, it's best to use a plugin or ask for help.
You can find the code snippet back in the Google Analytics interface, on the same "Web stream details" page where you found your Measurement ID. Click on "View tag instructions" and navigate to the "Install manually" tab.
Here’s the step-by-step process:
- Copy the full code snippet. It will look something like this:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YOUR_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [],
function gtag(){dataLayer.push(arguments),}
gtag('js', new Date()),
gtag('config', 'G-YOUR_MEASUREMENT_ID'),
</script>- Paste the snippet into your website's code. This code needs to go immediately after the opening
<head>tag on every single page of your site. If you have a file that controls your site's header (likeheader.phpin a WordPress theme), this is the ideal place to add it so it loads everywhere. - Save and upload your file. Once the file is saved and live, GA4 will start collecting data.
Method 3: Use a CMS Plugin or Integration (The Easiest Way)
Most modern website builders and Content Management Systems (CMS) like WordPress, Shopify, and Squarespace have built-in integrations or easy-to-use plugins for Google Analytics. This is by far the simplest method for non-technical users, as there's no code involved.
For WordPress
Millions of sites run on WordPress, and there are many plugins that make installing GA4 incredibly simple. Two great options are:
- Site Kit by Google: Google's official plugin. You just install the plugin from your WordPress dashboard, follow the setup prompts to connect your Google account, and it handles everything automatically. It also pulls in data from Search Console, PageSpeed Insights, and Adsense, giving you a mini-dashboard inside WordPress.
- MonsterInsights: A hugely popular third-party plugin. The setup is similar to Site Kit: install the plugin, authorize it with your Google Account, and select your GA4 property from a dropdown. The free version is great for basic tracking, and the pro versions unlock more advanced reporting and e-commerce tracking features.
Using one of these plugins is often just a matter of clicking a few buttons and pasting your "G-" Measurement ID into a dedicated field.
For Shopify or Squarespace
Platforms like Shopify and Squarespace make this even easier. They have a specific section in their settings dedicated to third-party integrations.
- In Shopify, go to Online Store > Preferences, and you’ll find a "Google Analytics" section where you can simply paste your "G-" ID.
- In Squarespace, navigate to Settings > External API Keys, where you'll find a box to paste your Google Analytics Measurement ID.
How to Check if Your GA4 Installation is Working
After you’ve installed the tag, you'll want to confirm that it's actually working and sending data. Don't just assume it works - test it!
1. Use the Real-Time Report
The quickest way to check is with GA4's own "Real-time" report. With your website open in another tab, log into your GA4 property and navigate to Reports > Real-time. If everything is set up correctly, you should see yourself as "1 User" on the map and in the data cards within a minute or two. Try clicking to another page on your website, you should see website traffic change in the report.
2. Use Tag Assistant
If you used Google Tag Manager, you have access to a powerful testing tool called Preview Mode.
- In GTM, click the "Preview" button.
- Enter your website URL and click "Connect."
- A new tab will open with your website and a small "Tag Assistant" box in the corner.
- Navigate around your site, and in the "Tag Assistant" pop-up window, you should see your "GA4 Configuration" tag under the "Tags Fired" section. This confirms that your trigger is working correctly and the tag is live.
Getting the basic installation correct sets you up for collecting reliable data, which is the foundation of any intelligent marketing decision.
Final Thoughts
In this post, we've covered the complete process for setting up a new GA4 property and installing its tracking code using Tag Manager, a direct code snippet, or an easy CMS plugin. Most importantly, you also learned how to verify traffic is flowing into the Real-time report, so you can be confident your data collection is up and running.
Getting GA4 set up is the critical first step, but deciphering the data inside its complex reports is a challenge all on its own. Often, the process of finding simple answers involves manually exporting data and spending hours in spreadsheets. We built Graphed to solve this by connecting directly to your marketing and sales data sources (including GA4). You can instantly create real-time reports and dashboards just by describing what you need in plain English - no wrestling with report builders required.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?