How to Add Google Tracking Code to a Website without using a plugin

How to Add Google Tracking Code to a Website without using a plugin


Divi WordPress Theme

To begin with, you will have to find your Google Tracking ID and Code to be able to achieve this.

The code is a Javascript code snippet as shown below. The Tracking ID is included in your Google Tracking Code and starts with a UA.

ALSO RELATED: HOW TO FIND YOUR GOOGLE TRACKING CODE

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.

Finding the head tag

Method 2: Use Google Tag Manager

Alternatively, you can decide to use the Google Tag Manager to add Google Analytics code to your website.


Bloom Email Optin Plugin

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.

Google Tag Manager

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.

Step 1

First, log in to your CPanel.

CPanel log in

Step 2

Then, in the Homepage Window> Files, click on File Manager.

File manager-CPanel

Step 3

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.

Add Google Tracking Code

Step 4

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.

TXT FILE=tracking code

Step 5

Right click to edit. A pop-up appears to authenticate, click on the Edit Button.

Edit TEXT file-add Google Tracking code

Step 6

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.

Add Google Code

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.

This image has an empty alt attribute; its file name is indexphp.png

Right click on index.php to edit. A pop up dialogue box appears to authenticate. Say edit, paste the code and save changes.

add Google Tracking Code

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.

This image has an empty alt attribute; its file name is php-code.png

Add Google Tracking Code

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.

Atieno Administrator
Authored By Atieno Ougo| A Blogger| Fashion lover | 4C Natural Hair enthusiast!

Leave a Reply

Your email address will not be published.