How to install the tracking code on a website(Generic Instructions)

Last Updated: May 29, 2015

If you're not hosting your entire website on HubSpot, or have pages of your website that are not hosted on HubSpot, you'll need to install the HubSpot tracking code on those non-HubSpot pages in order to capture those HubSpot analytics.

You will need access to your site's HTML to complete this task. If you do not have access, email this article to your Webmaster or IT Administrator. He or she will know what to do.

Tracking code helps you monitor:

  • How well your website is generating traffic and leads
  • What you can do to improve your website traffic
  • Sophisticated lead intelligence that enables you to turn more website leads into customers.

Your tracking code is installed automatically on all of your HubSpot hosted pages. But if you're not hosting your full site with HubSpot, you'll need to install the tracking code manually on your website.

Instructions for installing HubSpot tracking code on popular CMS platforms

If your external site is built using one of the Content Management Systems listed below, please follow the instructions specific to your platform:

General instructions for a non-HubSpot hosted website

If you don't use a content management system, like WordPress or Joomla, follow these steps to install the tracking code on your website.

Remember that if your website is hosted on the HubSpot COS or CMS that you do not need to follow these steps to install the tracking code. The tracking code is installed on all pages you create in HubSpot.

1. Assign this task to someone on your team

  • If you DO have access to the HTML of your website (or to your content management system) you can complete the steps below yourself.
  • If you DO NOT have access to your website's HTML, email the URL of this article to your IT department or web developer. 

Whoever is installing the tracking code will have to log in to HubSpot to complete the steps, so you need to create a HubSpot user account for them. For a refresher on creating a new HubSpot user account, click here

2. Go to your Reports Settings

Log in to HubSpot, and then click on Reports > Reports Settings.


3. Copy the HubSpot Javascript tracking code

Copy the tracking code provided in your account by using the Copy to clipboard button, or by highlighting the code and using the copy function of your keyboard.

3. Copy the HubSpot Javascript tracking code

The tracking code is different for every HubSpot account and corresponds to your HubSpot account number.

4. Paste the JavaScript above the </body> tag on each website page

Paste the code immediately before the </body> tag in the HTML code of each page of your site. Here's what the code would look just before the </body> tag in an HTML code view of a page:

4. Paste the JavaScript above the &lt;/body&gt; tag on each website page

Because every website/CMS is structured differently, we can't provide you with exact instructions on how to access your HTML code. If you're not sure how to access the HTML code of your site, email this document to your webmaster, IT department, or technical resource.

Most content management systems and IT departments have a way to batch-upload a piece of code to all pages of your site. Sometimes this comes in the form of a footer file that is referenced across all pages. If you don’t have access to your content management system, send these instructions to the person who does.

5. Verify that the code installation worked

To verify your tracking code is working, please follow the instructions listed here.

Next Article: How to install the tracking code on a WordPress website