How to Install Google Analytics on WordPress?

Home » WordPress Tutorials » Install Google Analytics on WordPress

3 Quick Methods To Install Google Analytics On WordPress

After installing WordPress and launching your new website, you should set up Google Analytics (GA) to track/measure the behavior of your WordPress website visitors.

First you’ll have to install and set up Google Analytics on WordPress in one of the 3 quick methods.

The step-by-step Google Analytics installation/setup guide include:

Install Google Analytics on WordPress

200+ Free Traffic Sources – The Complete List
Promote Your Website with Free Traffic
guide-free-traffic-sources
Get the Complete List as a PDF Document
fts-pdf-subscribe-form

Sign Up or Login to Gmail or Google Account, and Set Up Google Analytics

To use Google Analytics, you must have a Google account or a Gmail account.

You can use your existing Gmail account to login to Google Analytics.

Or register a new Google account (https://account.google.com/).

Set Up Google Analytics

Now go to Google Analytics (https://analytics.google.com/analytics/web/), and login with your Google account (or Gmail account).

Set up Google Analytics for your website in 3 steps.

  • Step 1: Account Setup.
  • Step 2: What Do You Want To Measure?
  • Step 3: Property Setup

Step 1: Account Setup.

Set up the account by entering a new account name.

create-ga-account.png

For example, the website using Google Analytics is going to be https://www.gordonchoi.com/, so set the account name to “ChinaMobileSEO.com“.

Under this account, you can create more than one Google Analytics Tracking ID.

Step 2: What Do You Want To Measure?

Select what you want to measure (e.g. Website, Apps). You have 3 choices to measure:

  • Web
  • Apps
  • Apps and Web

ga-measure-website.png

For your WordPress website, select Web.

Step 3: Property Setup

You need to provide property details. i.e. A website that you’re measuring/tracking through Google Analytics is called a GA property.

setup-ga-property.png

  • Enter your website name.
  • Enter your website URL.
  • Select an industry category for your WordPress website.
  • Select a reporting time zone. For example, if you locate in Hong Kong, normally you’ll choose HK time.

Get the Google Analytics Tracking Code.

Get the tracking code from within your Google Analytics account by copying it.

ga-tracking-code-sample.png

The latest tracking code is “Global Site Tag (gtag.js)”.

The next stage is to add this Google Analytics tracking code (GATC) to your WordPress website.

Method 1: Add Google Analytics Tracking Code directly to WordPress Website

Google Analytics suggests that the tracking code should added to the head section of your WordPress website.

In your WordPress account, under the left side menu go to “Appearance” and then “Theme Editor”. You’ll be taken to the Theme Editor screen.

Wordpress Theme Files

The head section HTML code can be found in a WordPress header file which usually is named “header.php“. Find this header file on the right side in the Theme Editor screen.

Now make sure you add the Google Analytics tracking code to the head section, and click “Update File”.

Method 2: Add Google Analytics through Google Tag Manager (GTM)

Go to Google Tag Manager (GTM) (https://tagmanager.google.com/) and login with your Google account.

Create a new Account. Complete the Account Setup by entering your new Account name and country.

New GTM account

Create a new Container. Complete the Container Setup by entering your new Container name.

Google Tag Manager has made 4 options available: Web, iOS, Android, or AMP.

For this case it is for a website, so select Web (for Target Platform).

GTM Container setup

Agree to the Google Tag Manager terms of service. You’ll have to click the Yes button.

GTM Code Sample

GTM provides you with 2 parts of tracking codes. You will have to:

  • Add the first part of the code to the head section of all the web pages of your website.
  • Add the second part to the body section of all your web pages.

Your GTM Container has an ID with this format:

  • GTM-XXXXXXX

Google Analytics - Universal Analytics

Create a tag, and select a tag type. In this case, select Google Analytics: Universal Analytics.

Add GA ID to GTM tag

Check “Enable overriding settings in this tag”, and enter your Google Analytics Tracking Code ID in the Tracking ID field.

Previously when you were creating your Google Analytics acount and property, you would have seen your GA ID in this format:

  • UA-XXXXXXXXX-1

Name the GTM tag

Name your GTM tag, and click Save.

Name the GTM trigger

You need a trigger to activate the tag. Create a trigger with Trigger Type “Page View”, and let this trigger fires on all page views. Name the trigger and click Save.

Go back to the previously created Tag, and add the Trigger to it.

Now make sure you add the two parts of the GTM code to the head section and the body section of all the pages of your WordPress website.

Method 3: Add Google Analytics through WordPress plugin

In your WordPress account, under the left side menu go to “Plugins” and then “Add New”.

Add New Plugins (WordPress)

Enter “google analytics” as keywords in the search box to find the plugin. Among many results, you will see the “GA Google Analytics” plugin.

GA Google Analytics Install & Activate

Click the “Install Now” button to install the “GA Google Analytics” plugin. Click the “Activate” button to enable it.

Again on the left side menu, now go to “Settings” and then “Google Analytics”.

GA Google Analytics (WordPress Plugin) Settings

Under the “Plugin Settings” section of the “GA Google Analytics” plugin, enter your GA ID (of this format: UA-XXXXXXXXX-1), and click “Save Changes”.

Start Marketing Your WordPress Website and Verify Your Google Analytics Data

Market Your WordPress Website

After successfully developing your website using WordPress and installing Google Analytics to track your website visitors’ behavior and the performance, the next immediate step is to get people to visit your new website.

I’ve compiled a list of over 200 free traffic sources where you can get traffic to your website.

Go through the list and pick out a small list of free traffic sources that can be regarded as “the low hanging fruits” i.e. traffic sources that you must place at the top of your priority, simply because you’re able to have them executed quickly.

Verify Data in Google Analytics Reports

You won’t see data showing up in your Google Analytics report right away. But once people started to visit your website, usually within 1-2 hours data will show up.

Conclusions

Regarding the installation of Google Analytics on WordPress websites with 3 methods, I have written the Chinese version of this article.

Articles on WordPress Topics

More on WordPress Topics