Installing Google Analytics on your Website

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. 


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.  


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.


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.


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. 


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.

Carrie Smaha Manager, Demand Generation

More Articles by Carrie


  • This is very helpful. I use Google Analytics Counter Tracker plugin on wordpress for my website and its so awesome, very simple and easy to install and operate.

  • Great post. Installing Google Analytics on your website takes only a minute and is painless. Soon, you’ll be tracking social media metrics in your sleep, thanks to Google Analytics.

  • Ditto on the great, concise and current info.

    In the head… why do other genius “advisors” make the choice so complicated???


  • This was the best site for how to put code on my website thank you for the help, regards , Ricky Tworivers&nbsp

Was this article helpful? Let us know!