Popular Searches

How To Set Up Google Analytics For a WordPress Site

WordPress Logo Dark Mode

Google Analytics is a powerful tool for collecting and viewing metrics on page views, user behavior, and other useful data. Best part is, it’s entirely free to use, so there’s no reason not to set it up for your website.

Setting Up Google Analytics

Head over to the Google Analytics dashboard and sign in. If it’s your first time using it, you can simply click “Start Measuring” to set it up. If you have an existing site, and want  to add another, you’ll need to click the settings icon in the bottom left and click “Create Account” to add a new one.

Creating an account will automatically create a “Property” for you, which represents your site. You can have multiple properties per account, but just one is fine for a single site.

To set up analytics, you’ll need to connect your website with a data stream. You can do this from the settings menu by clicking “Data Streams” > “Web.”

You’ll need to enter your website URL, and a name for the stream. Don’t worry, “Advanced Measurement” is free.


On the next screen, you’ll be presented with your “MEASUREMENT ID.” You will need this to link it to WordPress.

Enabling Google Analytics In WordPress

You have a few ways of adding the script to WordPress. If you’re comfortable modding your site directly, you can simply add the tracking script to the <header> of your site:

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

  gtag('config', 'G-LE23FH7NGK');

Otherwise, you can configure the analytics with a simple plugin. Head over to “Plugins” and click “Add New.” Search for “Google Analytics.”

There are a couple good ones, but “GA Google Analytics” is basic and just adds the tag and tracking code with some configuration.

Install and activate it, and then paste in the G-XXXXX.. tracking code that Google gave you. The default configuration is fine, so just save changes.

You should now see the script in the footer/header of your page’s HTML. After 24-48 hours, you’ll start to see entries in the Google Analytics console.

Anthony Heddings Anthony Heddings
Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon's AWS platform. He's written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times. Read Full Bio »

The above article may contain affiliate links, which help support CloudSavvy IT.