How to Install Google Analytics Tracking Code on Your Website [Quick Tip]

Download Now: Free Marketing Plan Template
Shilpa Pandya
Shilpa Pandya

Updated:

Published:

It’s no secret we love data, especially when that data is actionable and allows us to be better marketers, web developers, and content creators. Enter: marketing analytics!

install google analytics tracking code: image shows a computer with a magnifying glass coming out of it

Luckily, there are a host of marketing analytics tools out there -- we here at HubSpot, for instance, offer closed-loop analytics and reporting to give you a comprehensive understanding of your buying cycle. But there are also free tools out there you can use as either standalone tools, or in conjunction with paid tools.

The most popular? Google Analytics. It's easy to use if you're willing to roll up your sleeves a bit, and provides a wealth of data on the people coming to your website. With just a few easy steps that I'll outline in this post, you can get you up and running with this powerful tool in no time.

Why Install Google Analytics?

Knowing things like where your website visitors are coming from, how they found you, what content they viewed, and how long they stayed on parts of your site can provide you with infinite insight into your buyer personas and provide countless data-backed optimization opportunities. Combine this information with a closed-loop analytics platform that connects data on site visitor behavior with lead intelligence and customer data and you, my friend, are in prime position to take your marketing effectiveness to the next level. And who doesn’t want that?

First Things First: Make Sure You Can Edit Your Website 

Before opening up this proverbial can of worms, please do yourself a favor and make sure you have access to make edits to your website through a content management system (CMS). If not, you’ll need to work with someone else, probably a web developer or someone in IT, who can install the tracking code for you.

If your website is hosted on HubSpot, you're in luck! Just follow these quick steps to get started.

Without access to your website’s back end, you’re not going to make much progress, so hold off on reading any further until you’ve successfully met one of these two conditions.

Access Your Google Analytics Tracking Code

Once you’re sure you will be able to make edits to your website, we can move on to securing the appropriate Google Analytics tracking code. Log into your Google Analytics account and click ‘Admin’ in the upper right hand side of the page. Select the appropriate Account and Property, then click ‘Tracking Info’ in the middle column labeled ‘Property’.

Install_Google_Analytics_1

Click ‘Tracking Code’ under ‘Tracking Info’ to access the website tracking code you’ll need to install on your website. On this page, you’ll see a box with multiple lines of code. Be sure to copy the entire tracking code, beginning with <script> all the way through to </script>.

Note: Some CMSs have certain themes that include a built-in Google Analytics plugin. These plugins only require you to enter in your Google Analytics Tracking ID to complete analytics setup. If this is the case, you only need to copy the Tracking ID beginning with ‘UA-’ located at the top of the page. Each Google Analytics property created in your account will be assigned a unique Tracking ID. Make sure to use the appropriate Tracking ID or code for each domain.

Install_Google_Analytics_2

Add Tracking Code in the Right Place

With your tracking code in hand, you’re ready to install!

Log into your CMS and access your site’s HTML code. The script must be placed at the top of your website page, immediately before the </head> tag that appears on each page you want to track. As I mentioned earlier, some CMSs, including HubSpot, have a separate section where you can easily add either your tracking code or tracking ID. Make sure you look into your CMSs setup to ensure proper installation.

For HubSpot Customers

If you’re already a HubSpot user, you can follow these quick steps to install your Google Analytics tracking code on all HubSpot-hosted website pages. Just remember, following these steps will allow you to gather, access, and manage this data in Google Analytics only, not in your HubSpot account.

And We’re Off to the (Tracking) Races!

Basic analytics tracking is now installed on your website. You’ll notice that most of the reports under ‘Standard Reporting’ in Google Analytics will be delayed in populating data (up to 24 hours), but you can check the ‘Real Time’ tracking section in your Google Analytics account to start seeing data immediately.

Be sure to verify your installation is properly set up by revisiting the Tracking Code section -- located at Admin >> Tracking Info >> Tracking Code -- a few hours after you install the code. You’ll see a section labeled ‘Tracking Status Information’ at the top of the page. You want the status to read ‘Tracking Installed,’ which tells us the code is working as designed and data is being pulling into Google Analytics accurately. If the status reads ‘Waiting for Data,’ Google Analytics has found the tracking code on your homepage and is still working to gather the data into reports. In short, just give it some more time.

If the status is ‘Tracking Not Installed’ or ‘Not Verified,’ follow Google’s recommendations to troubleshoot the problem to ensure proper installation.

Knowing what visitors are doing on your website is essential to making smart, data-driven marketing decisions. With Google Analytics, you can begin to understand how people are navigating your website and respond appropriately to the story the data is telling you.

New Call-to-Action

Related Articles

Outline your company's marketing strategy in one simple, coherent plan.

    The weekly email to help take your career to the next level. No fluff, only first-hand expert advice & useful marketing trends.

    Must enter a valid email

    We're committed to your privacy. HubSpot uses the information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For more information, check out our privacy policy.

    This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.