How to begin tracking your marketing data within HubSpot

Last updated: June 21, 2016


Product: HubSpot Marketing
Subscription: Basic, Professional, & Enterprise

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. This article will show you how to begin tracking your website activity within HubSpot. Click on one of the links below for specific instructions:

The HubSpot 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.

Please note: 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.

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

From your HubSpot Dashboard, navigate to Reports > Reports Settings.

HubSpot Help article screenshot

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.

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

4. Paste the JavaScript above the closing 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 tag in an HTML code view of a page:

HubSpot Help article screenshot
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.

How to install the tracking code on a WordPress website

To install the HubSpot tracking code on a WordPress site, install the HubSpot Tracking Code for WordPress plugin, within your WordPress instance.

What does the plugin do?

  • Installs the HubSpot tracking code on your WordPress site.
  • Sets content type for filtering between pages and posts in the Page Performance tool.
  • Creates contacts with Lifecycle Stage of Subscriber when non-HubSpot forms are filled out on the site.
The "HubSpot Tracking Code for WordPress" plugin replaces the "HubSpot for WordPress" plugin. Unlike the older plugin, this plugin does not include various deprecated features and improves the reliability of the plugin. Forms and CTAs should now be embeded directly in the WordPress editor. WordPress no longer transmits meta information such as publish date and comment count to Page Performance. 


  • Your website or blog must be using a install. The Tracking code plugin cannot be installed on sites, as they do not allow you to add plugins or Javascript.
  • You must have WordPress version 3.0 or higher installed on your sever (the latest version is recommended).
  • The wp_footer function must be included in your WordPress theme’s footer file (footer.php). This function is required for our tracking code to be installed on every page of your site.
  • You must be a WordPress admin to be able to install plugins for your site. If you are not the admin, you can forward these instructions to the person who manages your WordPress install.

1. Log in to your WordPress account

Log in to your WordPress instance. You can generally access the login screen by adding /wp-admin to your URL. 

HubSpot Help article screenshot

2. Add new plugin

Hover over the Plugins menu item in the WordPress side menu and then click on the Add New option.

HubSpot Help article screenshot

3. Search for the HubSpot plugin

Type "HubSpot Tracking Code" into the search field and click the Search Plugins button to search for the HubSpot plugin.

HubSpot Help article screenshot

4. Install the plugin

Click on the Install Now link to install the latest version of the HubSpot Tracking Code for WordPress plugin into your WordPress website.

HubSpot Help article screenshot

5. Activate the plugin

Click the Activate Plugin link to activate the plugin for your WordPress website.

HubSpot Help article screenshot

You'll see a Plugin activated message to confirm that the plugin is active. Next you'll configure the plugin to work with your HubSpot account.

HubSpot Help article screenshot

6. Edit plugin settings

Hover over the Settings menu item in the WordPress side menu and click the HubSpot Settings option.

HubSpot Help article screenshot

7. Enter your Hub ID

Enter your Hub ID and click Save Settings.

HubSpot Help article screenshot

8. Verify the tracking code

To verify that the tracking code is working, follow these steps

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:

Previous article:

Learn Inbound Marketing

Next article: