How to Add Google Analytics to WordPress
Adding Google Analytics to your WordPress site is one of the most important first steps you can take to understand your audience and grow your traffic. Getting it set up only takes a few minutes, even if you’re not a technical person. This article will walk you through setting up your Google Analytics 4 property and guide you through a few different methods to connect it to your WordPress website.
First Things First: Create Your Google Analytics 4 Property
You can't add Google Analytics to WordPress until you have an Analytics account and property ready to go. A "property" is what Google calls your website or app within their system. If you already have a Google Analytics 4 property set up, you can skip to the next section. If not, follow these quick steps.
Your goal here is to get your "Measurement ID," which is a unique tracking code that looks something like G-XXXXXXXXXX.
- Visit the Google Analytics homepage and log in with your Google account.
- Click "Start measuring" to begin setup.
- Account setup: Give your account a name. This is for your overall business, which might contain multiple websites. For example, "My Company Inc."
- Property setup: Name your property. This should be your website's name, like "My Awesome Blog." Set your reporting timezone and currency.
- Business details: Answer a few brief questions about your industry and business size. This helps Google tailor your reports.
- Data collection: Now you need to create a "data stream," which is just a source of data for your property. For a website, choose the "Web" platform.
- Enter your website URL (e.g., https://www.yourdomain.com) and create a stream name.
- Once your data stream is created, you'll see a screen with your stream details. At the top right, you'll find your Measurement ID. Copy this and keep it handy!
That’s it. Your GA4 property is now ready to receive data from your WordPress site.
3 Simple Ways to Add Google Analytics to WordPress
Now that you have your Measurement ID, it's time to connect Google Analytics to your website. We'll cover three popular methods, ranging from an all-in-one plugin to manually adding a code snippet.
Method 1: Use 'Site Kit by Google' (The Easiest Route)
For most WordPress users, using a plugin is the simplest and safest way to add Google Analytics. There's no code to handle, and everything is managed from your WordPress dashboard. Our top recommendation is Google's own free plugin, Site Kit.
Why use Site Kit?
- It's the official Google plugin, so you know it's secure, well-maintained, and perfectly integrated.
- Setup is almost entirely automatic. You just log into your Google account.
- It pulls data from Google Analytics, Google Search Console, and more, displaying simple reports directly in your WordPress admin area.
Step-by-Step Instructions for Site Kit:
- In your WordPress dashboard, navigate to Plugins > Add New.
- In the search box, type "Site Kit by Google" and press Enter.
- Click "Install Now," then "Activate" on the official Site Kit plugin.
- Once activated, you'll see a large banner prompting you to start the setup. Click the setup button to begin.
- Site Kit will walk you through a simple authorization process. You'll sign in with the same Google account you used to create your Analytics property.
- It will confirm you're the site owner through Google Search Console (another essential tool it sets up for you).
- Next, it will prompt you to connect more services. Find Google Analytics and click "Connect Service."
- Select your Analytics account and the property you created earlier from the dropdown menus.
- Click "Configure Analytics," and you're all done!
Site Kit will automatically add the necessary GA4 tracking code to every page of your site. You can now view basic traffic stats right from your WordPress dashboard.
Method 2: Use an 'Insert Headers and Footers' Plugin for Tracking Code
If you have other custom scripts that you manage and don't require an all-in-one suite, this method is useful for keeping all third-party code organized. This method still saves you from directly editing theme files, which is great for maintaining control while keeping the number of different plugins at a minimum.
You will need more than the "Measurement ID" — you'll have to grab the Global Site Tag. Here is a sample snippet of what you can expect:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
Step-by-Step Instructions:
- In WordPress, navigate to Plugins > Add New.
- Search for "WP Insert Headers and Footers" and click "Install," then "Activate."
- In Analytics, get your Global Site Tag by clicking the gear cog in the Account > Admin section > Data Streams.
- Copy all the text in the "Global Site Tag" popup menu.
- Back in WordPress, hover over Settings on the left sidebar. A "Code Snippet" should appear, or go to the WP Insert Headers and Footers plugin installed page. From there, access the headers and footers script menu. You will see a space to paste your code under the "Header" section. Paste your code there and click "Save."
That's all that's needed. The plugin will inject the code across your site.
Method 3: Manually Adding the Tracking Code to Your Theme Files
This method is for users comfortable with editing files and who want to avoid any plugins. Although this approach requires adding a code snippet to your theme’s header.php, it is a straightforward process. Important: Before you proceed, always use a child theme. Directly editing the theme files can be overwritten when an update is issued.
How to Add the Code to Your Child Theme
- Step 1: Get your Global Site Tag Follow the steps in the previous method to copy the full Global Site Tag script from your Google Analytics property.
- Step 2: Navigate to Your Theme Editor
In your WordPress dashboard, go to Appearance > Theme Editor. Select your child theme from the dropdown menu. You should look for a file named header.php. Paste the script you have before the closing
</head>tag. Click "Update File." - Step 3: Verify That It's Working Once you have added the code, it's crucial to check that it's working. The best way to ensure your script is on the page is by using Google Analytics. Visit your site and right-click to "View Page Source" of the HTML. Use the search function to look for a portion of the code that you added. If found, you know that your code was added successfully.
Final Thoughts
Adding Google Analytics to WordPress is a few-minute process that enhances the way you understand your visitors' behavior on your site. Using any of the methods discussed, you'll be able to see the data flow into Analytics and make informed decisions to improve your site's performance. Graphed offers further insights into web traffic and helps integrate it into overall marketing strategies. Don't forget to explore Graphed to leverage more features and analytics capabilities.
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?