Resources For:

How To Set Up Google Tag Manager And Install Google Analytics Into A WordPress Website

How To Set Up Google Tag Manager And Install Google Analytics Into A WordPress Website


arnold on Apr 07, 2019

First, Make sure you are signed into your Google account and go to

Then click On “Add Account”

Fill out the form similar to the image below

Creating New Tag Manager Account


Next you will have to accept the terms from Google to continue.

Accepting Google Tag Manager Terms

You will then be given access to the Google Tag Manager Code For Your Account:

Google Tag Manager Default Code

We will need to install the code on every page of our website as requested by Google. We also need to split up the code and install it in different sections of each page.

To install this code properly we need to go to the dashboard of our WordPress websites.

Once logged in go to APPEARANCE and then EDITOR as shown below.

How To Access Your WordPress Editor In You Dashboard


If you get a warning message then just click I UNDERSTAND.

WordPress Editor Change Warning

You will then see the editor section of your dashboard. On the right hand side you will need to select the theme to edit. Since we are using mesmerize that needs to be selected. Scroll down until you find header.php  (It may say Theme Header) and click on that to open up the header code.

header code insert

You should see a screen that looks something like this:

Header Theme Code In WordPress Editor

Now we need to simply copy our Google Tag Manager code into the editor. Go back to the tag manager and copy the header code and insert it as shown below. Then copy the body code and enter it as shown below.

Where to insert Google Tag Manager Code In WordPress Theme File

Once you click UPDATE FILE it will install the Google Tag Manager scripts into your website.

However, we need to install the GTM scripts one more time because MESMERIZE uses a separate theme file for their homepage. Click on header-homepage.php on the right.  Then insert the code one more time as shown below. Then click “Update File” one more time.

Inserting Google Tag Manager Code Into The WordPress Editor


Now you can go check the code. Go to your homepage on your website and right click on it.  Then select VIEW PAGE SOURCE and you will see the code on your website.  Look at the header code and you should see your Google Tag Manager code as shown below.

How To Check Homepage Code For Google Tag Manager Code

Sign Up For A Google Analytics Account

The next thing we need to do is set up our websites in Google Analytics.  Sign up for a Google account if you do not have one. If you have Gmail then you have a Google account.  If you need a Google account then go to this link:  and get signed up.

Do not use your CSU email or email account.  It will cause you a lot of problems later in the semester.  Make sure you are using a  account.

Now go to:

Click Sign Up:

Signing Up For Google Analytics

Get signed up like this example:

Setting Up Google Analytics

Then Click “Get Tracking ID” and accept the privacy notification that comes up.

Get Tracking ID From Google Analytics

You will need to accept their terms of use:

Accepting Google Analytics Terms Of Use

This will take you to a page that contains the following information: You will need your UA code later so copy that to save time later.

Google Analtyics Tracking ID US Code

Once your analytics account is set up and you have your UA code you now need to return to Google Tag Manager to set up your Google Analytics tag. In your Workspace select ADD A NEW TAG.

Adding A New Tag In Google Tag Manager


On the next screen give your tag a name.  We are creating a Google Analytics Pageview tag that will be installed on all pages. So that is how I named the tag, Once you name the tag click on CHOOSE A TAG TYPE TO BEGIN SETUP as shown below.

Naming A Tag In Google Tag Manager

Then on the right sidebar when it asks for tag type select GOOGLE ANALYTICS – UNIVERSAL ANALYTICS.

Selecting Google Analytics Universal In The Google Tag Manager

In the Tag Configuration you need to leave the Track Type as Page View and then select NEW VARIABLE in the settings box.

Selecting Tag Type In Google Tag Manager

In the screen that pops up you will need to enter your UA code as shown below. You also need to give it a name.  I just used the US code as a name and then I clicked save.  If you don’t know how to find your UA please continue to the next step for instructions.

Selecting The UA code in Google Tag Manager

To find your UA code go to Then Go To Admin which is in the bottom left. Then select PROPERTY SETTINGS and you will see your UA code which you can copy.

How To Find Your UA code in Google Analytics


We have one last step which is the select a trigger.

Selecting A Trigger In Google Tag Manager

Then select ALL Pages as shown below:

Selecting All Pages In Google Tag Manager


Your final configuration should look like the image below.  If it does click SAVE.

Correctly Set Up Google Tag Manager

Now we just need to submit our changes.  In the top right of your workspace click on SUBMIT.

Fill out your settings similar to the image below:

Publishing Your Changes In Google Tag Manager

Next we need to check that our set up worked.  We can do this by going to google analytics and checking our real-time traffic.

How To Check Real Time Analytics In Google Analytics

The next thing we need to do is to check to see if analytics was installed correctly.

Let’s go back to our analytics and look on the home page.

If you click Real-Time and then Overview you will be taken to the real time screen.  Load your website from a mobile phone and you should see your traffic appear:

Checking Real Time Analytics in Google Analytics


If you see this then you know your analytics was installed correctly!

The Ultimate