1. Create a Google Analytics Account
- Visit analytics.google.com
- Sign in with your Google account
- Click Start Measuring
- Enter Account Name → Continue
- Add your Website Name
- Select Platform: Web
- Enter your site URL
- 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)
- Go to Plugins → Add New
- Search Site Kit by Google
- Install → Activate
- Click Start Setup
- Connect your Google account
- Approve permissions → Allow
- Choose your Analytics property
- 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)
- Go to RankMath → General Settings → Analytics
- Click Connect Google Services
- Log in with your Google account
- Select your Analytics property
- Save settings
RankMath adds tracking code + search analytics in your dashboard.
C. Using MonsterInsights (Alternative Plugin)
- Install MonsterInsights – Google Analytics for WordPress
- Activate
- Run the Setup Wizard
- Connect your Google account
- Choose your Analytics property
- 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:
- Go to Admin → Data Streams
- Choose your web stream
- Scroll to Tagging Instructions
- 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)
- Go to Appearance → Theme File Editor
- Open header.php
- Paste the code before
</head> - Save
Option B — Use Code Snippets Plugin (Safe Method)
- Install Code Snippets
- Add New Snippet
- Paste the Analytics code
- Set to Run on Frontend
- 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.
