How to Add Google Analytics to WordPress Without a Plugin

Looking for a way to add Google Analytics to your WordPress website without a plugin?

Setting up Google Analytics on WordPress helps you track your website traffic and gives valuable insights about your visitors.

Let’s take a look at how to add Analytics tracking code to your site without a plugin.

Why is Google Analytics Important for Your WordPress Website?

Once you’ve started a WordPress website, you should know how it’s performing. And to get this useful data, you need Google Analytics. It’s a powerful tool that helps you understand how people use your site.

MonsterInsights is the best WordPress Analytics plugin. Get it for free!

Here are some benefits of using Analytics:

  • Identify Traffic Sources – You can find out where your visitors come from, which channel they use (search, social, paid, etc.), which country they belong too, and more.
  • Better Understand Your Audience – Once someone lands on your website, what do they do? With Google Analytics, you can track their every interaction and see what links they click or which files they download.
  • Create Content That People Like – Google Analytics helps you track your pages and posts, so you know which content is driving a lot of traffic. This way you can find similar topics to cover and boost your traffic.
  • Conversions and Sales – If you have an eCommerce store, then Google Analytics can help you track your conversions and see how much revenue your store is making.
  • Improve Your Site’s User Experience – Find out how people behave on your site, which pages they visit, which device or browser they use, so you can improve the user experience of your website.

With that, let’s see if it’s a good idea to set up Google Analytics with or without a plugin…

Is It Best to Add Google Analytics With or Without a Plugin?

You might think that the fewer plugins you use on your site the better, but that’s not always necessarily true.

It’s true that badly coded plugins could add bloat and slow down your site.

But a well-made, lightweight plugin can save you a lot of time and hassle, without any ill effects.

In fact, the number of plugins on a WordPress site has actually next to no direct correlation with your site’s speed and performance. It’s all about the quality of the plugins installed.

Best WordPress plugins, like MonsterInsights, which have millions of installs, are more tested and optimized for speed. They have no impact on site load speed whatsoever.

You can read more about how plugins affect your site’s speed here.

Before we jump in, let’s take a look at why you should add Google Analytics to WordPress site without a plugin may not be the best choice for your site.

  • Not as easy: Adding Google Analytics to your site without a plugin is not as easy as with a plugin. With MonsterInsights, the best Google Analytics plugin for WordPress, you can easily set up Analytics with just a few clicks.
  • You may lose tracking code: When you switch your themes, you may forget to add the Analytics tracking code again to your new theme. In the period of time before you add your tracking code again, your visitors won’t be tracked. With a plugin, you won’t miss out on that data.
  • You miss powerful Analytics features: You’ll miss powerful features like events tracking, custom dimensions, file download tracking, and more. Without a plugin, it’s very time consuming to set up these features on your WordPress site.

If you’re looking for an easy way to set up Google Analytics on your WordPress site, you may use MonsterInsights, instead.

With MonsterInsights, you can easily set up these advanced tracking features with just a few clicks:

You can read how to properly set up Google Analytics in WordPress with MonsterInsights.

Get Started with MonsterInsights Today!

If you’d rather set up Google Analytics without a plugin, follow the step-step-guide below or view our video tutorial.

Video Tutorial

You can also take a look at the written steps to learn how to set up Google Analytics without a plugin in WordPress.

Add Google Analytics to WordPress Without a Plugin

Before we get started, make sure to backup your WordPress theme, so in case something goes wrong, you can easily revert it back.

You’ll be directly editing the code that outputs your site, so a mistake as small as a misplaced comma could bring down your whole site. Be sure to make a backup just in case.

Step 1: Get Your Google Analytics Tracking Code

Log into your Google Analytics account and select the website for which you need the tracking code.

click on google analytics view

Click on Admin in the left taskbar.

click admin

In the property column, click Tracking Info, and then Tracking Code.

get google analytics tracking-code

Now you can get the tracking code under the Website tracking section. Just copy the Google Analytics script.

Step 2: Add the Tracking Code to the header.php file

Now, are you wondering where to place Google Analytics tracking code on your website?

Log in to your WordPress dashboard and navigate to Appearance » Theme Editor. Now click the Theme Header (header.php) file on the right-hand side below the Tempe Files section.


Paste the tracking code you just copied from your Analytics profile before the closing </head> tag. 

Then click Update File.

That’s it!

You’ve just learned how to add Google Analytics to WordPress without a plugin.

But if you’re looking for a simpler method, then MonsterInsights is the best solution. It’s one of the most popular Google Analytics WordPress plugin and makes it super simple to connect your site with Analytics.

Get Started with MonsterInsights Today!

And if you’re still wondering whether it’s a good idea to install Google Analytics without a plugin, you should check out our post on is MonsterInsights worth it.

After installing Google Analytics, you might also want to stop Google Analytics from tracking logged in WordPress users. And if you want, you can also check out our amazing guide on how to create an email newsletter and Mailchimp alternatives.

For more tutorials like this, follow us on Twitter and Facebook.

Want to Try MonsterInsights for Free?

Enter the URL of Your WordPress website to install MonsterInsights Lite.


    1. Sunil,
      You just need to follow the tutorial. It will add the Analytics tracking code to the entire site.

  1. This is completely true. Monster Insights will not slow down your site at all. We have done extensive testing and every-time this plug in comes out on top with no speed loss.
    We even testing no cache on a site with Google page speed installed on the Apache server and only used Yoast and Monster insights. Still no speed loss at all.
    So it is 100% true what Monster Insights tells you here, it’s the coding of the plugin that matters most. Quit using junk plugins.

  2. I don’t have a header.php section in my theme. It is a child theme so maybe that is why. I have no idea, but really have no idea where to put this code.

    1. Hey Stacy! Thanks for stopping by the blog. Yes, if you’re using a child theme that doesn’t have a header.php, that means it’s using the header.php from the parent theme.

  3. If I have synced my google analytics with the MonsterInsights plugin, does this mean my iOS google analytics app will get the same data?

    or will I still need to insert the global tag in my header.php to get the google analytics app to display the correct info?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.