Add Google Analytics Tracking Code in Default WordPress Theme without Plugin

In this post, I will explain the simple and uncomplicated method of adding the Google Analytics Tracking Code in the Default WordPress Themes without using a Plugin.

This method works in the Default WordPress Twenty Twenty One Themes and other similar default WordPress Themes without any difficulty, It should also work in the latest upcoming Twenty Twenty Two Themes, which have been released recently. However, I will keep you updated after I try the Tracking Code on them.

Go to Google Analytics and copy the Tracking Code as shown in the image given below:


There are two easy methods of adding the Tracking Code in your WordPress Theme, I have described both these methods in this post. 

1] Adding Google Analytics Tracking Code in WordPress Themes:

Go to Appearance – Editor - header.php

And paste the code as shown in the image given below. 



2] Adding Google Analytics Tracking Code in WordPress through the CPanel: This method is useful if your security plug-in has blocked access to the Theme Editor. In such cases you can easily add the Tracking Code by following the simple steps given below:

Go to CPanel - File Manager – public_html – wp-content – Themes - Twenty Twenty One – header.php

Paste the Tracking Code in the same manner as shown in the first method. In both cases do not forget to back up your Theme.

Note: In case you manually update your WordPress Themes you will most likely lose the Tracking Code, so save it before manually updating your Themes.

Click on the images to enlarge them, in case you cannot view them properly. 

Comments