How to Install Google Analytics on WordPress Site

Hesam Seyedi ● January 17, 2025

Introduction

Imagine running a store without knowing who walks in, what they browse, or what makes them leave.

That’s what managing a website without Google Analytics feels like.

You’re guessing instead of making informed decisions.

Whether you’re a blogger, business owner, or eCommerce seller, understanding your visitors is the key to growing your website.

Google Analytics helps track where your traffic comes from, which pages perform best, and how users interact with your content—all for free.

In this guide, I’ll walk you through how to install Google Analytics on your WordPress site, step by step.

You’ll be able to track visitor data effortlessly, even if you have zero technical experience. 

Why Google Analytics Matters

Google Analytics helps track traffic, user behavior, and conversions, giving you insights to improve your site.

Whether you run a blog, eCommerce store, or business website, understanding your visitors helps you optimize your content and marketing strategies.

What You'll Learn

This guide will show you how to install Google Analytics on a WordPress site using:

  1. A WordPress plugin (recommended for beginners).
  2. Manual installation (for advanced users).
  3. Google Tag Manager (for enhanced tracking).

What You Need

Before getting started, make sure you have:

  • A Google Analytics account – Sign up for free here
  • A WordPress website with admin access
  • A Google Tag (Measurement ID) (we’ll cover how to get it)

Step 1: Create a Google Analytics Account

To track your website, you first need to create a Google Analytics account and get a Measurement ID.

1. Sign Up for Google Analytics

  1. Go to Google Analytics.
  2. Click “Get Started” and sign in with your Google account.
  3. Click “Start Measuring.”

2. Set Up an Account

  1. Enter your Account Name (e.g., “MyWebsite Analytics”).
  2. Enable or disable data sharing settings as needed.

📌 Official Google Support: Set up Google Analytics

3. Create a Property (Your Website)

  1. Enter a Property Name (e.g., your website name)
  2. Select your Reporting Time Zone and Currency.
  3. Click Next.

📌 Guide on Creating a Property

4. Set Up Business Details

  1. Choose an Industry Category (e.g., Retail, Tech, Finance).
  2. Select Business Size (Small, Medium, Large).
  3. Choose Objectives (Tracking engagement, sales, etc.).
  4. Click Create and Accept Terms & Conditions.

5. Get Your Google Analytics Measurement ID

  1. Go to Admin → Data Streams.
  2. Select Web as your platform.
  3. Enter your Website URL.
  4. Click Create Stream.
  5. Copy your Measurement ID (looks like G-XXXXXXXXXX).

Step 2: Get Your Google Analytics Tracking Code

Now that your Google Analytics account is set up, the next step is to get your Measurement ID—this is the unique tracking code that links your website to Google Analytics.

1. Access Your Google Analytics Dashboard

  1. Go to Google Analytics.
  2. Click Admin (⚙️ icon in the bottom-left corner).
  3. Under Property, click Data Streams.

📌 Google’s Official Guide on Data Streams

2. Create a Data Stream for Your Website

  1. Click Add Stream → Web.
  2. Enter your Website URL (e.g., https://yourwebsite.com).
  3. Name your stream (e.g., “MyWebsite Analytics”).
  4. Keep Enhanced Measurement enabled (tracks scrolls, outbound clicks, and file downloads automatically).
  5. Click Create Stream.

📌 How to Set Up a Web Data Stream 

3. Find & Copy Your Google Measurement ID

    1. After creating the stream, you’ll see a Measurement ID (e.g., G-XXXXXXXXXX).
    2. Click the copy icon next to the ID.
    3. Keep this tab open—you’ll need this ID for the next step.

📌 Where to Find Your Google Analytics Measurement ID

Next Steps:
Now that you have your Google Analytics Measurement ID, it’s time to install it on your WordPress site.

In the next section, I’ll cover three different ways to do it—choose the one that works best for you! 

Step 3: Install Google Analytics on WordPress

Now that you have your Google Analytics Measurement ID, it’s time to install it on your WordPress site.

There are three main methods to do this:

  1. Using a plugin (best for beginners)
  2. Manually adding the tracking code (for advanced users)
  3. Using Google Tag Manager (for enhanced tracking)


Choose the method that works best for you.

Method 1: Install Google Analytics Using a Plugin (Recommended for Beginners)

The easiest way to add Google Analytics to WordPress is by using a plugin.

This method requires no coding and provides access to analytics directly from your WordPress dashboard.

Option 1: Install Google Analytics with MonsterInsights

  1. Go to your WordPress dashboard, navigate to Plugins → Add New.
  2. Search for MonsterInsights, click Install Now, then Activate.
  3. Go to Insights → Settings in the WordPress menu.
  4. Click Connect MonsterInsights and sign in with your Google account.
  5. Select your website from the list and click Complete Connection.
  6. Adjust recommended settings and click Save and Continue.


Once the setup is complete, Google Analytics will start tracking your site.

Monster Insights
MonsterInsights is a WordPress plugin that connects your site to Google Analytics, offering real-time stats, e-commerce tracking, and SEO insights.

Option 2: Install Google Analytics with Site Kit by Google
Google’s official plugin, Site Kit, integrates multiple Google services, including Analytics, Search Console, and AdSense.

  1. In WordPress, go to Plugins → Add New, search for Site Kit, and install it.
  2. Click Activate, then go to Site Kit → Dashboard.
  3. Click Start Setup, sign in with your Google account, and grant permissions.
  4. Select Google Analytics, connect your account, and finish the setup.

Once activated, you can view your analytics data directly from the WordPress dashboard.

Google Site Kit
Site Kit is Google’s official WordPress plugin that helps you track site performance, understand visitor behavior, and optimize monetization.

Method 2: Manually Add Google Analytics Code (For Advanced Users)

If you prefer not to use a plugin, you can manually add the Google Analytics tracking code to your theme.

Option 1: Add the Code to Your Header.php File

  1. Copy your Google Analytics tracking code from the Google Analytics dashboard.
  2. In WordPress, go to Appearance → Theme File Editor.
  3. Select header.php from the right-hand menu.
  4. Paste the tracking code right before the closing </head> tag.
  5. Click Update File and save changes.


Note: If you update your theme, this code may be removed. To prevent this, use a child theme.

Option 2: Use a Custom Code Plugin

Instead of modifying theme files, you can use a plugin like WPCode to add tracking scripts safely.

  1. Install and activate the WPCode plugin.
  2. Go to Code Snippets → Header & Footer.
  3. Paste your Google Analytics tracking code into the Header section.
  4. Click Save Changes.

WPCode
WPCode lets you add code snippets to WordPress without editing theme files, supporting headers, footers, and custom scripts.

Method 3: Install Google Analytics Using Google Tag Manager

Google Tag Manager (GTM) is useful if you need advanced tracking and want to manage multiple tags from one place.

  1. Go to Google Tag Manager and create an account.
  2. Click Create Container and enter your website details.
  3. Select Web as the target platform and click Create.
  4. Copy the GTM code snippets and paste them into your WordPress header.php file or use a plugin like WPCode.
  5. In Google Tag Manager, click Add a New Tag, select Google Analytics GA4 Configuration, and enter your Measurement ID.
  6. Set a Trigger to fire on all pages and click Save.
  7. Click Submit → Publish to activate tracking.

Google Tag Manager
Google Tag Manager makes it easy to add and manage tracking codes for better measurement and ad optimization.

Next Steps
Now that Google Analytics is installed on your WordPress site, the final step is to verify that it’s working.

The next section will cover how to confirm data is being tracked correctly and how to access your analytics reports.

Step 4: Verify Google Analytics is Working

After installing Google Analytics on your WordPress site, you need to confirm that it’s tracking data correctly.

This step ensures everything is set up properly before you start analyzing traffic and user behavior.

1. Use Google Analytics Realtime Report

Google Analytics has a built-in Realtime Report that lets you see live visitors on your site. This is the quickest way to verify if tracking is working.

How to Check Realtime Data

  1. Go to the Google Analytics Dashboard.
  2. Click Reports in the left menu.
  3. Select Realtime under the “Life Cycle” section.
  4. Open your website in a new browser tab.
  5. Click through different pages on your site.

If tracking is set up correctly, you should see at least one active visitor (yourself) in the Realtime report.

If the number stays at zero, analytics isn’t working, and you may need to troubleshoot.

📌 How to Use Realtime Reports

2. Use Google Tag Assistant (For Manual Installations)

If you manually added the Google Analytics tracking code, you can use Google Tag Assistant to verify whether it’s installed correctly.

How to Use Google Tag Assistant

  1. Install the Google Tag Assistant Chrome Extension.
  2. Open your website and click the Tag Assistant extension in your browser toolbar.
  3. Click Enable and refresh the page.
  4. Check if the Google Analytics tag (G-XXXXXXXXXX) appears in the list.


If the tag is detected, Google Analytics is properly installed. If it doesn’t show up, the tracking code might be missing or placed incorrectly.

📌 How to Troubleshoot with Google Tag Assistant 

3. Use Google Analytics Debug Mode (For Advanced Users)

For deeper verification, Google Analytics Debug Mode can show if events and pageviews are firing correctly.

How to Use Debug Mode in Google Analytics

  1. Go to the Google Analytics Dashboard.
  2. Click Admin → DebugView.
  3. Open your website in a new browser tab.
  4. Install the Google Analytics Debugger Chrome Extension and enable it.
  5. Refresh your website and check if events appear in DebugView.


This tool helps diagnose issues with tracking code placement, event triggers, and missing data.

Troubleshooting: Why Isn’t Google Analytics Tracking?

If you don’t see data in Google Analytics, here are some common issues and fixes:

Issue Solution
No data in Realtime Report Wait 24–48 hours as Google Analytics sometimes takes time to update.
Tracking code missing If manually installed, ensure the code is in header.php before </head>.
Using multiple methods If you installed both MonsterInsights and a manual code, it may cause conflicts. Use only one method.
Cache issues Clear your WordPress cache or disable caching plugins, then check again.
Ad blockers Some browser extensions block analytics. Open your site in incognito mode and recheck.

Next Steps
Now that Google Analytics is tracking your site, it’s time to start using reports and insights to improve your website’s performance.

The next section will cover how to read Google Analytics reports and use them to optimize your site.

Step 5: Understanding Google Analytics Reports

Now that Google Analytics is tracking your WordPress site, it’s time to analyze the data.

Google Analytics provides detailed reports to help you understand who visits your site, how they interact with it, and where your traffic comes from.

1. How to Access Google Analytics Reports

  1. Go to Google Analytics Dashboard.
  2. Click Reports in the left-hand menu.
  3. Explore different sections, including Realtime, Audience, Acquisition, Behavior, and Conversions. 

📌 Google’s Guide to Analytics Reports

2. Key Google Analytics Reports to Track

A. Realtime Report (Live Visitor Tracking)
This report shows who is on your website right now, what pages they are visiting, and how they found your site.

  • How to Access: Click Reports → Realtime
  • Use Case: Check if a recent content update or marketing campaign is driving traffic.

📌 How to Use Realtime Reports

B. Audience Report (Who Your Visitors Are)
The Audience Report provides insights into your visitors, including:

  • Demographics: Age, gender, and interests.
  • Geographic Data: Where your visitors are coming from.
  • Device Data: Desktop vs. mobile users.
  • How to Access: Click Reports → Audience
  • Use Case: Adjust your website content based on your audience’s demographics.


📌 Understanding Audience Reports

C. Acquisition Report (How Visitors Find Your Site)
This report shows where your traffic is coming from, categorized into:

  • Organic Search: Traffic from search engines like Google.
  • Direct Traffic: Users who enter your site’s URL manually.
  • Referral Traffic: Clicks from other websites linking to you.
  • Social Media: Visitors from Facebook, Twitter, LinkedIn, etc.
  • How to Access: Click Reports → Acquisition
  • Use Case: Identify the best-performing traffic sources and focus on them.

📌 Guide to Acquisition Reports

D. Behavior Report (What Visitors Do on Your Site)
This report tracks how visitors interact with your site, including:

  • Top Pages: Your most visited content.
  • Bounce Rate: Percentage of users who leave after viewing one page.
  • Average Session Duration: How long visitors stay on your site.
  • How to Access: Click Reports → Behavior
  • Use Case: Improve low-performing pages and optimize for engagement.


📌 How to Use Behavior Reports

E. Conversions Report (Track Goals and Events)
If you have contact forms, eCommerce transactions, or other key actions, this report helps track them.

  • Goals: Set up goals like form submissions, sign-ups, or purchases.
  • Ecommerce Tracking: Monitor sales, revenue, and customer behavior.
  • How to Access: Click Reports → Conversions
  • Use Case: Measure how well your website converts visitors into customers or subscribers.


📌
Guide to Conversion Tracking

3. Setting Up Custom Dashboards for Faster Insights

Instead of navigating multiple reports, you can create custom dashboards to track key metrics at a glance.

How to Create a Custom Dashboard

  1. Go to Google Analytics.
  2. Click Customization → Dashboards.
  3. Click Create → Blank Canvas or use a template.
  4. Add widgets for key metrics (traffic sources, bounce rate, top pages, etc.).
  5. Click Save Dashboard.


📌
Google’s Guide to Custom Dashboards

Next Steps
Now that you know how to read Google Analytics reports, you can start using the data to optimize your content, improve user experience, and grow your site traffic.

The final section will cover advanced tracking techniques to help you get even more insights from Google Analytics.

Step 6: Advanced Tracking and Custom Events

Once Google Analytics is set up and tracking standard metrics, you can take it a step further by tracking custom events.

This allows you to measure specific user interactions, such as button clicks, video plays, form submissions, and outbound link clicks.

1. What Are Custom Events in Google Analytics?

Custom events let you track actions that aren’t automatically recorded in Google Analytics.

Some examples include:

  • Click Tracking: Track when users click on specific buttons, links, or CTAs.
  • Form Submissions: Measure how many users fill out contact or signup forms.
  • Video Engagement: Track how many users start, pause, or complete a video.
  • Downloads: Monitor when users download files such as PDFs or reports.
  • Outbound Links: See which external links users click to leave your site.

📌 Google’s Guide to Event Tracking

2. How to Set Up Event Tracking in Google Analytics

There are two main ways to track custom events: using Google Tag Manager or manually adding event tracking code.

Option 1: Track Events Using Google Tag Manager (Recommended)
Google Tag Manager (GTM) makes it easier to track events without coding.

How to Track Click Events Using GTM

  1. Go to Google Tag Manager and open your container.
  2. Click Tags → New and name it (e.g., “Button Click Event”).
  3. Click Tag Configuration → Google Analytics: GA4 Event.
  4. In Configuration Tag, select your Google Analytics GA4 tag.
  5. In Event Name, enter the event (e.g., “button_click”).
  6. Click Triggering → New Trigger → Click – All Elements.
  7. Configure the trigger to fire only on specific button clicks (e.g., match a button’s CSS class or ID).
  8. Click Save → Submit → Publish.


Now, Google Analytics will track button clicks as events.

📌 Guide to Using Google Tag Manager

Option 2: Add Event Tracking Code Manually
If you prefer not to use Google Tag Manager, you can manually add event tracking code to your site.

For example, to track a button click, add the following JavaScript code to your button:

<button onclick="gtag('event', 'button_click', {'event_category': 'CTA', 'event_label': 'Subscribe Now'});">
  Subscribe Now
</button>

This code sends an event to Google Analytics when the button is clicked.

Breaking Down the Code:

  • ‘event’ → Specifies that this is a custom event.
  • ‘button_click’ → Event name in Google Analytics.
  • ‘event_category’ → Categorizes the event (e.g., CTA buttons).
  • ‘event_label’ → Identifies the specific button.


📌 Guide to Adding Events Manually

3. How to View Custom Events in Google Analytics

Once events are set up, you can track them in Google Analytics.

Steps to View Event Data:

  1. Go to Google Analytics Dashboard.
  2. Click Reports → Engagement → Events.
  3. Find your custom event in the list (e.g., “button_click”).
  4. Click on the event name to see detailed tracking data.


📌 Guide to Viewing Events

4. Setting Up Goals and Conversions

If an event is important to your business (e.g., a lead form submission or a purchase), you can set it as a conversion in Google Analytics.

How to Mark an Event as a Conversion

  1. Go to Google Analytics.
  2. Click Admin → Events.
  3. Find the event you want to track (e.g., “form_submission”).
  4. Toggle the switch under Mark as Conversion.

Now, this event will appear in your Conversions Report.

📌  Guide to Conversion Tracking

Next Steps
By setting up custom events and conversions, you can track meaningful interactions on your site and use data to optimize user experience and marketing strategies.

The final section will cover best practices for using Google Analytics to improve your website performance.

Step 7: Best Practices for Using Google Analytics

Now that Google Analytics is set up and tracking both standard and custom events, the final step is to make the most of your data.

Here are some best practices to improve your website performance, optimize content, and track meaningful results.

1. Set Up Custom Alerts for Important Changes

Google Analytics allows you to create custom alerts to notify you of sudden spikes or drops in traffic, conversions, or other key metrics.

How to Create a Custom Alert

  1. Go to Google Analytics.
  2. Click Admin → Custom Alerts.
  3. Click + New Alert and name it (e.g., “Traffic Drop Alert”).
  4. Select the View you want to monitor.
  5. Choose Conditions (e.g., traffic decreases by more than 50% in one day).
  6. Set up Email Notifications to get alerts.
  7. Click Save Alert.

📌 Guide to Custom Alerts

2. Use Segments to Analyze Specific User Groups

Segments allow you to filter and analyze specific groups of users, such as:

  • New vs. Returning Visitors
  • Users from a Specific Country
  • Traffic from Social Media vs. Organic Search


How to Create a Segment

  1. Go to Google Analytics.
  2. Open any report and click Add Segment at the top.
  3. Click + New Segment and name it.
  4. Set filters (e.g., “Users from the U.S.” or “Users who completed a purchase”).
  5. Click Save to apply the segment.

📌 Guide to Segments

3. Track Internal Site Search to Understand User Intent

If your site has a search bar, tracking internal search terms helps you understand what visitors are looking for.

How to Enable Site Search Tracking

  1. Go to Google Analytics.
  2. Click Admin → Data Streams → Your Website.
  3. Scroll to Enhanced Measurement and enable Site Search Tracking.
  4. Set the Query Parameter (usually s or q, depending on your site).

📌 Guide to Site Search Tracking

4. Set Up UTM Parameters for Tracking Marketing Campaigns

If you’re running ads, email campaigns, or social media promotions, use UTM parameters to track where traffic is coming from.

https://yourwebsite.com/?utm_source=facebook&utm_medium=social&utm_campaign=winter_sale

5. Create Custom Dashboards for Faster Insights

Instead of navigating multiple reports, create custom dashboards to track the most important data in one place.

How to Create a Custom Dashboard

  1. Go to Google Analytics.
  2. Click Customization → Dashboards.
  3. Click Create → Blank Canvas or use a template.
  4. Add widgets for key metrics (traffic sources, bounce rate, conversions, etc.).
  5. Click Save Dashboard.


📌 Guide to Custom Dashboards

Final Thoughts

Google Analytics is a powerful tool, but data is only useful if you act on it. Use these best practices to:

  • Improve content based on user behavior
  • Optimize conversion rates by tracking key actions
  • Enhance marketing campaigns with accurate traffic data
  • Make data-driven decisions instead of guessing


With Google Analytics fully set up, your WordPress site is now ready to track and analyze visitor behavior effectively.