1. Create a Google Analytics Account

  1. Visit analytics.google.com
  2. Sign in with your Google account
  3. Click Start Measuring
  4. Enter Account Name → Continue
  5. Add your Website Name
  6. Select Platform: Web
  7. Enter your site URL
  8. Click Create Stream

Copy the Measurement ID (looks like: G-XXXXXXX).


2. Method 1 — Install Google Analytics Using a Plugin (Recommended)

A. Using Site Kit by Google (Best Option)

  1. Go to Plugins → Add New
  2. Search Site Kit by Google
  3. Install → Activate
  4. Click Start Setup
  5. Connect your Google account
  6. Approve permissions → Allow
  7. Choose your Analytics property
  8. Complete the setup

Site Kit automatically adds the tracking code and displays analytics reports inside WordPress.


B. Using RankMath Analytics (If you already use RankMath SEO)

  1. Go to RankMath → General Settings → Analytics
  2. Click Connect Google Services
  3. Log in with your Google account
  4. Select your Analytics property
  5. Save settings

RankMath adds tracking code + search analytics in your dashboard.


C. Using MonsterInsights (Alternative Plugin)

  1. Install MonsterInsights – Google Analytics for WordPress
  2. Activate
  3. Run the Setup Wizard
  4. Connect your Google account
  5. Choose your Analytics property
  6. Finish setup

3. Method 2 — Add Google Analytics Tracking Code Manually

Use this if you prefer not to use plugins.

Step 1: Copy the Global Site Tag (gtag.js)

In Google Analytics:

  1. Go to Admin → Data Streams
  2. Choose your web stream
  3. Scroll to Tagging Instructions
  4. Copy the gtag.js tracking code

Example:

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

Step 2: Add the Code to WordPress

Option A — Insert Into header.php (Not Recommended for Updates)

  1. Go to Appearance → Theme File Editor
  2. Open header.php
  3. Paste the code before </head>
  4. Save

Option B — Use Code Snippets Plugin (Safe Method)

  1. Install Code Snippets
  2. Add New Snippet
  3. Paste the Analytics code
  4. Set to Run on Frontend
  5. Save & Activate

4. Verify Google Analytics Installation

Use one of these:

  • Real-time report inside Analytics
  • Chrome extension: Tag Assistant Legacy
  • Google Site Kit validation (auto)

If real-time data appears, installation is successful.


5. Submit Your WordPress Sitemap to Analytics/Google Search Console (Optional but Important)

If using RankMath or Yoast:

Your sitemap:

https://yourdomain.com/sitemap_index.xml

Submit it through Google Search Console for better indexing.


FAQ: Installing Google Analytics in WordPress

1. Do I need a plugin for Google Analytics?

No. You can manually add the tracking code.

2. Does Site Kit slow down WordPress?

No, it loads scripts directly from Google.

3. Can I use multiple analytics plugins?

No. It may cause duplicate tracking.

4. Does Google Analytics 4 (GA4) work on WordPress?

Yes. All methods above support GA4.

Categorized in:

WordPress Tips & Tricks,