At this point, you should have created a Google Account and activated the service for Analytics. Google provides you with a code snippet to insert into every webpage you wish to track. This is important. You must have the code on every page you wish to track or you will not see results for pages the code is not inserted into. If you are managing multiple domains in Google Analytics you must get a different code for each website. At any time do you need to get your Analytics code snippet, you can log into your Google Analytics account and retrieve it. 

ga_12

In Step 2, there is the code you must paste into the webpage. Depending on how your website is built will determine how you insert the code. You will insert the code snippet between the <head> and the </head> tags whether or not your website is built with PHP or HTML. If your website is built with PHP and you are dynamically building the headers with a separate file, you will need to insert the code into that file.  

ga_13

Open your HTML document in an editor (there’s one included in file manager of cPanel). For more information on using file manager in cPanel please read our article. Once the file is opened, find the closing </head> tag. Insert the code snippet BEFORE the closing </head> tag.

ga_14

Save the page and upload it if you are editing it on your local computer. If you are using file manager you do not need to do anything besides saving the changes.

Adding Google Analytics to a WordPress Website

There are 3 ways to install Google analytics in WordPress. All of which are relatively easy to do. We’ll go over each one. If you are uncomfortable with editing the HTML or PHP code directly, we recommend using the plugin method.

Direct Paste Method

Copy the code that you received from Google, and paste it in your theme’s footer.php right above the </body> tag.

Functions.php Method

Add the following code in your theme’s functions.php file and don’t forget to paste your Google Analytics code here.

<?php

add_action('wp_footer', 'add_googleanalytics');

function add_googleanalytics() { ?>

// Paste your Google Analytics code from Step 6 here

<?php } ?>

Plugins Method 

There are tons of plugins available to add Google Analytics to your site. The two that we recommend are:

Google Analytics for WordPress by Joost de Valk
Google Analyticator by Ronald Heft

Verifying that Google Analytics is Installed Correctly

Google Analytics will itself check to see that the tracking code has been installed correctly on the home page of your site - once you've created a new profile, the Tracking Status will display a warning icon, "Tracking status unknown," until the system detects the code. Once the system detects your code has been entered correctly on the Home Page, it will display a green check under the "status" column. Be sure you are in "classic" view to see this easily. 

ga_22

Once the code is added to all of your webpages, you are finished with the installation part of getting started using Google Analytics. Now, it’s time to start using analytics.


Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!