How to add Google Analytics Code to WordPress Website (Simple Method)

Are you searching for a simple and proper solution of inserting the Google Analytics tracking code to your WordPress website? Or, Still; You are curious to know about “How to add Google Analytics tracking code to your WordPress website with the help of plugin and without a plugin?”
So, Here you are at the right place to learn and get your proper solution of this query without any complication.

Now be ready and concentrate here to get your solution.

Okay!

Before jump to the learning methods of adding Google Analytics code to WordPress, you should be aware of “how to get the Google Analytics tracking code?”

How to get the Google Analytics tracking code?

To get the Google Analytics tracking code, follow the below steps.

Step 1: Go to Google Analytics site by clicking here, or simply type “Google Analytics” in Google search and click on the first link of the search result as seen below.

Google Analytics in Google search

Step 2: Sign in with your existing Gmail account.

Sign in with Gmail account to continue to Google Analytics

Enter your existing Gmail id and password to connect with Google Analytics.

Enter the Gmail id password

Step 3: After sign in with your Google Gmail account, Just click on the “Sign up” button to create the Google Analytics account.

Sign up to create the google account

Important things to learn before creating a Google Analytics account and getting the Google Analytics tracking code.

  • The “Account Name” of Google Analytics could be universal (same for many websites). Which contains more than one tracking code according to the number of websites you are added to that specific Analytics account.
  • You can also create up to 100 accounts in Google Analytics to manage your website or apps easily through the admin panel of Google Analytics account.
  • A Google Analytics tracking code is only for the individual website, which you have entered to get the tracking code. If you want to add your another website with Google Analytics account and get the tracking code, then you will have to create another property through the Google Analytics admin panel to get the tracking code.

This will be your brand new Google Analytics account creation registration form. So, to be careful while entering your information related to the website.

Step 4: Just enter the data like Google Analytics account name, website name, website URL, website category, and your time zone. Enter the website URL without HTTP/HTTPS because it’s already mentioned to choose anyone.

Take a look at the below image to creating a new account of Google Analytics.

New account creation of Google Analytics to get the tracking code

After entering the all required data, click on “Get Tracking id”.

Step 5: Now you will have to accept all the terms of Google Analytics to get the Google Analytics tracking code.

Google Analytics terms acceptance

Here is the Result! Google Analytics tracking code after following the above steps carefully.

Google Analytics tracking code

We learned how to get the Google Analytics tracking code with the help of the above simple way.

Now the time to learn “How to add a Google Analytics tracking code to a WordPress website”.

How to add Google Analytics tracking code to WordPress website?

You will learn two methods in this post to add the Google Analytics tracking code to a WordPress website.

  1. Add Google Analytics tracking code with a plugin (Simple and Recommended)
  2. Insert Google Analytics tracking code manually by editing the theme header file of the WordPress website (Advanced and complex)

1. Add Google Analytics tracking code with a plugin (Recommended)

This is the very simple and recommended method to easily add the Google Analytics tracking code into a WordPress website.

Follow the below steps to add the Analytics tracking code to WordPress.

Step I: Open your WordPress website dashboard and click on “Add new” by navigating the Plugins>Add New section of your WordPress dashboard.

Simply search the “Insert headers and footers” in the search bar of Add plugins section as seen in below image.

Add Insert Headers and Footers plugin by seaching in plugins store

Click on “Install Now” and then “Activate”.

You may directly upload this plugin by clicking on “Upload Plugin” after download it through the WordPress site.

WordPress plugin Download link: Insert Headers and Footers

Step II: Just click on the “Insert Headers and Footers” option by navigating the Settings>Insert Headers and Footers in your WordPress dashboard section.

Take a look at the screenshot of “Insert Headers and Footers” plugin, which you will view after opening them.

Insert Headers and Footers script area to put the code in header

Step III: Paste your Google Analytics tracking code in the “Scripts in Header” area. As you can look at the below screenshot.

Paste Google Analytics code in Insert Headers and Footers plugin

Now, everything has been done perfectly to successfully get your result.

So, Just click on the “Save” button to add the Google Analytics tracking code to the WordPress website.

Done!

A benefit of using the “Insert Headers and Footers” plugin is when you change your WordPress theme, it will always be inside the header of your new theme also. So you don’t have to worry in the future about the Google Analytics tracking code.

Note: If you uninstalled the “Insert Headers and Footers” plugin, then the tracking code will automatically be removed from the WordPress website header. So keep in mind before doing this same.

2. Insert Google Analytics tracking code without a plugin (Advanced)

Inserting Google Analytics tracking code manually without a plugin by editing the theme header file of the WordPress website is Advanced and complex to implement the task.

If you are not familiar with at least understand the structure and syntax of coding, then avoid this advance method to add the Google Analytics tracking code to WordPress website.

Click on the “Theme Editor” by navigating the Appearance>Theme Editor on the dashboard of WordPress.

And just choose and open on the “Theme header (Header.php)” file.

Insert tracking code in the theme header file

Carefully identify the <head> and </head> tags in the header.php file to insert the Google Analytics tracking code.

Take a look at the below image and understand how I inserted the tracking code between the <head> and </head> in the header.php file of the WordPress theme.

Google analytics code inserted between the head tag

After inserting the tracking code into the correct tags of the header.php file. Just click on the “Update File” to successfully insert the Google Analytics tracking code into the WordPress website header.

How to verify Google Analytics code working or not?

After adding the Google Analytics tracking code to the WordPress website, you can verify its working by the below method.

Method 1: This is the simplest method to verify the Google Analytics code is successfully working on your WordPress website or not.

Just open your website on any device’s web browser and visit any webpage of your website.

And then, open your Google Analytics account on a desktop or Google Analytics app. You will see the realtime view of your website page by just clicking on the realtime overview option on the Google Analytics dashboard section.

Google Analytics realtime

Method 2: This is the advanced method to verify the Google Analytics code inserted into your WordPress website or not.

Okay! So, Just open your website on desktop and right-click on the background of your website’s webpage and click on the “View page source”. Where you will find a Google Analytics tracking code tag.

Take a look at the below screenshot to identify the Google Analytics tracking code.

Google Analytics tracking code in website page source

I hope you learned the methods of adding the Google Analytics tracking code to a WordPress website, along with how to get the Google Analytics tracking code. If you have any doubt, query, and suggestion regarding this tutorial, then you can comment below. I will try to solve your problem as shortly asap.

Please follow Blogsnode on the social network to get connected with us!

Sharing is caring!

3 thoughts on “How to add Google Analytics Code to WordPress Website (Simple Method)

  1. Wonderful guide. I found many beginners ignore this and don’t use Google Analytics tracking code on their blog. But if you ask me, this is one of the most important thing to do after starting a blog as through this only one can collect all necessary data in analytics to understand how your website is performing. Excellent article brother, keep up the good work.

  2. Hello Mukesh,
    This is an awesome guide. You made it very simple to learn how to add G-analytics code to a website.

    I’ve got to know about this plugin by Wpbeginner for long. Happy to know it’s still one of the best to implement codes to header of websites.

    Thanks and do have a nice day…

Leave a Reply

Your email address will not be published. Required fields are marked *