How to Add Google Analytics to WordPress without using Plugins

Do you want to add Google Analytics to your WordPress Website without using Plugin? Then, this article will help you to install Google Analytics to WordPress via Theme Header (header.php) file.

how to add google analytics to WordPress without plugin

Google Analytics is the most popular and free analytics service available for website owners to track their visitor’s behavior.

Google Analytics is important to your site as it helps you to track your Website visitors, which page is getting more traffic, and which keywords are getting traffic to your website. You can also track total page views, sessions, real-time users and total no. of users.

Adding Google Analytics to WordPress site is a simple process. You just have to submit your site to Google Analytics, and it will provide a Unique tracking Id or an Analytics Code. You need to add this code to your WordPress Theme header file or you can use a WordPress plugin to add analytics to your site.

Follow the below step by step guide to add Google Analytics to WordPress without using Plugin.

Add your WordPress Site to Google Analytics

Step #1: Sign up to Google Analytics – First, go to Google Analytics page, and sign in using your Google (or Gmail ) account. If you don’t have a Google Account, create one for using Google Analytics services. Now sign up for Google Analytics.

Step #2: Setting up your Account – Now you need to add your website details. Fill all the details such as Account name (Analytics account), Website name, URL, category, and time-zone. Once you have filled all the information, click on Get Tracking ID.


Step #3: Get the Tracking Code from Analytics – On the next screen, you will see your website Tracking code.

google analytics code

You need to copy that code and add it to your WordPress website. You can do so with or without the help of WordPress Plugins.

Important: How to uninstall themes in WordPress without damaging your site

Add Google Analytics to WordPress without Plugins

This is the simplest method to add Google Analytics to WordPress. I will show you how to paste the analytics tracking code code into your WordPress Theme Header file.

Note: Remember your code will disappear if you update or change your WordPress Theme. You then, have to add the code again using the same process mentioned below.

  • Login to your WordPress Dashboard.
  • Go to Appearance > Editor.


open theme editor in WordPress

  • At the right side, you will see Theme Header (header.php). Click on it.
WordPress theme editor
  • Now paste the Tracking code (snippet) which you copied from the Google Analytics right after the <body> tag. 
add google analytics code to WordPress header

    OR– You can paste the code right before the </head> tag. Using any of the position will run your code successfully.

    • Now click on Update File to save the changes.

    That’s it. You have successfully added Google Analytics to your WordPress site.

    Note: You can also verify if you have added the code properly and if it is tracking all your posts or not. Just open any of your pages in a new browser tab. Press Ctrl + U to view the source code. Then use Ctrl+F to open search bar and type analytics, you will find your analytics tracking code.

    If you have any difficulty in setting up Google Analytics to your WordPress site, let me know by leaving a comment below.

    Leave a Comment

    This site uses Akismet to reduce spam. Learn how your comment data is processed.