Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Add Google Analytics to Your Website

This guide shows you how to put the Google Analytics tracking code on your website so you can see your visitors.

How-To Guides2 min read17 steps

What is Google Analytics?

Google Analytics is a free tool from Google. It counts how many people visit your site. It also shows where they come from and which pages they read. It is like a door counter for a shop.

To make it work, you add a small piece of code to your pages. This code is called a tracking tag.

Get your tracking code

  1. Go to the Google Analytics website and sign in with a Google account.
  2. Create an account and a property for your website if you have none. A property is one website in Analytics.
  3. Set up a web data stream and enter your website address.
  4. Open the stream and find View tag instructions.
  5. Choose to install manually. You will see a code block that starts with <script>.
  6. Copy the whole block.

Your tag includes a measurement ID that looks like G-XXXXXXXXXX. Do not change it.

Add the code to a plain HTML site

  1. Log in to your hosting control panel and open File Manager.
  2. Go to your website folder. It is often named public_html.
  3. Make a copy of your page file as a backup.
  4. Right-click the page, such as index.html, and choose Edit.
  5. Find the line with </head>.
  6. Paste the code just above that line.
  7. Click Save Changes.
  8. Repeat for every page, or edit the shared header file if your site has one.

If you use WordPress

Many people use a plugin that has a box for the measurement ID. Search the Plugins page for Google Analytics, install one, and paste your ID in its settings. Another way is to paste the code in your theme's header, but a plugin is safer.

Check that it works

  1. Open your website in a new browser tab.
  2. In Google Analytics, open the Realtime report.
  3. You should see yourself as one active visitor within a minute or two.
Tip: Full reports can take a day to fill in. Realtime is the quick way to test.

Quick recap

  • Create a property and web data stream in Google Analytics.
  • Copy the tracking code.
  • Paste it above </head> on each page, or use a plugin.
  • Check the Realtime report.