How to insert Google Analytics code to WordPress Websites in 2 Minutes

Henry Nguyen
3 min readDec 21, 2020

--

Source: from Enniye Timiebi on medium.com

If you are a beginner with google analytics, this post would be helpful to you in setting up Google Analytics to your WordPress website without adding plugins. I understand how a newbie finds it hard to find out where is the tracking info in Google Analytics property and then figure out where to insert the tracking code on the website. That is why you will find this article helpful. Let’s follow step by step with pictures attached below to Set up Analytics for a website (Universal Analytics) in 2 minutes only.

Note: This article is for those guys who have already had Google Analytics Account.

Step 1: Open Admin setting

Log into your Google Analytics account and click on Admin (Gear icon) in the left taskbar at the bottom as the picture above, then click on Create Property (Middle column)

Step 2: Create a property

Fill name for the property and choose the reporting time zone and currency as required in Property Setup

Next, you need to click Show advanced options (below the property-setup fields) and then turn on the switch for Create a Universal Analytics property. Fill the gap as required with the website URL. Next, choose to Create Both a Google Analytics 4 property and a Universal Analytics property as recommended by Google.

After that, you should click Next to switch to About your business below and provide information about your business (This step like a survey from Google), and then click Create

Step 3: Getting tracking code from The Universal Analytics property

Once you click Create after filling in business information from step 3, the two properties have been created. Both these properties have the same name, but Google Analytics 4 property will have a “GA4” designation at the end of its name. Learn more detail about Universal Analytics versus Google Analytics 4 data. In this article, I only guide you on how to get a tracking code from Universal Analytics property, follow the pictures as below, choose the property with the name you have created without “GA4”

In the property column, you click Tracking Info, and then Tracking Code to see Website Tracking, then copy all code (Google Analytics script) under Global Site Tag (The area I drew a red rectangle)

Step 4: Add the Tracking Code to WordPress

Now, you log in to your WordPress dashboard and navigate to Appearance >> Theme Editor (Or Customize >> CSS/HTML Editor). Then click the Theme Header (header.php) file on the right-hand side below the Tempe Files section.

All you need to do now is to paste the tracking code you just copied from your Analytics profile from step 3 before closing the </head> tag as Google required and then click Update File.

Read the full post with the last step of how to Make sure your Google Analytics tracking code works well at my site

--

--