How to install the HubSpot JavaScript tracking code

Date Published: 07/06/2011
Author: Diana Urban

Who is this document for?

All Professional and Enterprise HubSpot customers that want to use HubSpot's website analytics on a non-HubSpot hosted website. HubSpot Basic customers must have their entire websites hosted on HubSpot, so they can skip to the next steps at the bottom of this article.

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.

What does this document tell me?

The HubSpot tracking code is what makes the HubSpot website analytics work with your site if you are not hosted with HubSpot.

Here's exactly what it does for you:

  • Allows HubSpot to tell you how your website is generating traffic and leads.
  • Lets you see what you can do to improve your website traffic.
  • Lets HubSpot provide you with sophisticated lead intelligence that enables you to turn more website leads into customers.

The tracking code is installed out of the box on any HubSpot hosted pages, but if you are not hosting your full site with HubSpot you must install the tracking code on your website. The sooner you get your JavaScript installed on all of your website pages, the sooner you’ll be able to start getting value out of HubSpot!

Do you use Wordpress or Joomla?

We have specific instructions on how to install the tracking code if you are hosting your site with Wordpress or Joomla that are linked to below:

General Instructions for a non-HubSpot hosted website

 


1. Assign this task to someone on your team

  • If you DO have access to the HTML of your website (or 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 – they should be able to complete these steps in no time flat.

 

Note that they will have to log in to HubSpot to complete the steps, so you need toÊcreate a HubSpot user account for them.


2. Go to your Reports Settings

Log into HubSpot, and click on Reports > Reports Settings.



3. Copy the HubSpot Javascript tracking code

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


 

Note that the tracking code is different for every 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:


 

 

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


5. Verify that the code installation worked

Go back to HubSpot's report settings and use the Validate your Installation input to check that your tracking code was properly installed.



 
 

Next Steps:


Was the content and structure of this article helpful? (If you are running into an issue in your account or have a specific question about your setup, please contact our Support team.)  Yes  No