How to Add Google Tracking Code to a Website without using a plugin
To begin with, you will have to find your Google Tracking ID and Code to be able to achieve this.
Ways to add Google Tracking Code to a Website
We are looking at three ways you can add Google Tracking Code to a website.
Method 1: In the <head> tag on each page of your website
Copy and paste your Tracking Code snippet and paste the head tag after the <head> tag on each page of your website that you would like to track in Google Analytics.
How to find the <Head> Tag
To view the source code of a particular page of your website, head to the page, press CTRL + U on your keyboard.
From there, press CTRL+F on your keyboard to search for <head>. By doing this, you know exactly where the code should be placed.
Method 2: Use Google Tag Manager
Alternatively, you can decide to use the Google Tag Manager to add Google Analytics code to your website.
Get started with Google Tag Manager
Google Tag Manager is a free tool and is very useful to website that use multiple analytics. Go to to tagmanager.google.com to get started with this.
Method 3: Add Tracking Code in CPanel
This is the method that i prefer since it would prevent you from adding a plugin to your website. More plugins slow down the website’s performance.
First, log in to your CPanel.
Then, in the Homepage Window> Files, click on File Manager.
Afterward, find public_html in the bottom left pane of the window. Click on public_html and create a new file and save it with a txt extension.
Once you have entered the name of the file and given it a txt extension, click on click on Create New File.
Refresh the page to view the txt file you have just created. Make sure to give it a name that you’ll easily remember. In this case we called it digitalresource.txt.
Right click to edit. A pop-up appears to authenticate, click on the Edit Button.
Paste your Google Tracking Code and Save Changes. The code sections blurred out in red contain a unique Tracking ID which I earlier mentioned is confidential.
Step 7: Make WordPress Aware of the changes
You have to make WordPress aware that you have introduced a new code In CPanel. Otherwise, your Analytics won’t work.
Still under public_html>name column find index.php.
Right click on index.php to edit. A pop up dialogue box appears to authenticate. Say edit, paste the code and save changes.
Paste this code at the bottom of the code lines you’ll find in the code window.
The code section underlined in red should be the name of the TEXT file you created in Step 3 above.
In summary, those are some methods we can use to Add Google Tracking Code to our websites.
To be notified when posts like this are published, feel free to enter your email address in the box below.