Google Analytics is a free web analytics service provided by Google that helps website owners and marketers track and analyze website traffic and user behavior. This guide will outline a few different methods for adding Google Analytics to your site.
Set Up Google Analytics
Create an Analytics Account
If you don’t already have a Google Analytics account, you’ll need to create one:
- Go to https://analytics.google.com.
- Sign in with your Google account (or create one).
- Click “Start measuring”.
- Fill in the Account Name (e.g. your business name).
- Choose the data-sharing settings you prefer and click Next.
Set up a GA4 Property
- Enter a Property Name (e.g., “My Website”).
- Select your time zone and currency.
- Click Next, then answer some basic questions about your business.
- Click Create and accept the terms of service.
Set up a Data Stream
- Choose your platform: Web, iOS, or Android. For a website, choose Web.
- Enter your website URL and a stream name.
- Click Create Stream.
- You’ll now see your Measurement ID (looks like: G-XXXXXXXXXX) and the global site tag (gtag.js).
If you intend on using the custom snippet method, copy the global site tag code to your clipboard.
See Google Analytics Help for additional help and information.
Add Google Analytics to Your Site
Custom Snippet Method
<!-- Example -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Your site code should look something like the above Javascript example.
- Copy the full site code snippet generated by Google. Make sure your Measurement ID (i.e. id=G-XXXXXXXXXX) is correct.
- Use a plugin such as Code Snippets to insert the site code snippet inside the <head> tag of your site.
Plugin Method: Site Kit by Google
Site Kit is the official WordPress plugin from Google.
- Install the Site Kit by Google plugin.
- Activate the plugin.
- Connect Site Kit to your Google Analytics Account.
For more detailed instructions, visit this Site Kit Setup and Installation document.
Plugin Method: MonsterInsights
MonsterInsights is one of the most popular Google Analytics plugin for WordPress.
- Install Google Analytics for WordPress by MonsterInsights.
- Activate the plugin.
- Navigate to the Insights tab in your WordPress admin menu and configure the plugin.
For more detailed instructions on how to set up MonsterInsights, please see their setup document.
Plugin Method: Flying Analytics
For enhanced performance, Flying Analytics copies the Google Analytics scripts to your local server.
- Install the Flying Analytics plugin.
- Activate the plugin.
- Navigate to Settings → Flying Analytics.
- Add your Google Analytics Tracking ID (a.k.a. Measurement ID)
- Save your changes.
Verify Google Analytics Tracking
- Visit your site in a new browser tab.
- Go back to Google Analytics.
- Under Reports → Realtime, you should see your visit show up within a few seconds.
Note: you may need to log out of WordPress for your traffic to be recorded. Do not use an Incognito/private window or a browser with an ad blocker as this may block the Google Analytics script.


