1. Home
  2. Third-Party Integration
  3. Google
  4. How to Add Google Analytics to an HTML Website

How to Add Google Analytics to an HTML Website




You can use Google Analytics to track visitors on your website. You can see what pages they are landing on, where they are navigating to, and when they leave. It can be invaluable knowledge to have when assessing your site.

If you have a WordPress site, see our How to Add Google Analytics to a WordPress Site article.

Set Up Google Analytics

The first step is to set up the analytics on the Google end and get the tracking ID.

  1. Sign in or create a Google Analytics account
  2. In the left bottom of the sidebar, click Adminadmin interface
  3. On the right side of the screen, select the account you would like to use or create a new account by clicking the + Create Account buttoncreate account image
  4. Click the + Create Property buttoncreate property image
  5. Select Websitewebsite image
  6. Enter the following information:
    • Website Name: The name you will use to identify your site
    • Website URL: The website’s URL
    • Industry Category: The type of industry that the website falls under
    • Reporting Time Zone: This will determine the time displayed in analytics results
  7. Click the Get Tracking ID buttonget tracking id image
  8. Copy the code on the next page, under the Global Site Tag headerglobal site tag image

You will need this code for the next step.

Add Analytics to Your Site

Next, you need to go to your website files. Find the <head> tag on each of your web pages and add the code you copied in the previous section.

The code will look like this, but with your own tracking ID substituted.

 <!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TRACKING_ID"></script>

  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'TRACKING_ID');

Once you have added the tracking code, you can test to see if it’s working by visiting the live site, then looking at the REAL-TIME page in the analytics interface. If working, it should show that a visitor is viewing the page.

Google Analytics is provided by Google. Google Analytics is not a product of Pair Networks, Inc., and Pair Networks provides no warranty for Google Analytics.

Please note that there are many levels of website analytics products available. Please consult with your IT professional for advice and guidance on an appropriate analytic tracker. This specific product may or may not meet your needs. Pair Networks, Inc. is providing support for this analytics tracker for your convenience and is not responsible for Google Analytics' performance.

Please read carefully the terms and scope of services for any online service or product you are considering purchasing or using.

Updated on February 20, 2020

Was this article helpful?

Related Articles