How do I create a tracking code in HubSpot?

If you do not see a line of code that matches the code you typed in, then the tracking code is not installed correctly. You can try copying and pasting the code again, or you can contact HubSpot support for help.

To create a tracking code in HubSpot, you can follow these steps:

  1. Go to Settings > Tracking & Analytics > Tracking Code.
  2. Click Create tracking code.
  3. Enter a name for your tracking code.
  4. Select the domains that you want the tracking code to be installed on.
  5. (Optional) If you want to track specific pages or events, you can enter the URLs or event names in the Track specific pages or events section.
  6. Click Create.

Once you have created a tracking code, you can copy the code and paste it into the <head> section of your website's HTML.

Here are some additional tips for creating a tracking code in HubSpot:

  • Make sure to select the correct domains for your tracking code. If you select the wrong domains, the tracking code will not work on all of your pages.
  • If you want to track specific pages or events, you can enter the URLs or event names in the Track specific pages or events section. This will allow you to track more granular data about your website visitors.
  • You can create multiple tracking codes for different purposes. For example, you could create one tracking code for your website and another tracking code for your landing pages.
  • Once you have created a tracking code, you can test it to make sure it is working properly. You can do this by opening a page on your website in your browser and right-clicking anywhere on the page. In the dropdown menu, select Inspect Element or Inspect. A toolbar will appear at the bottom or side of your screen.

In the toolbar, click on the Console tab. Then, type in the following code:

Code snippet
document.querySelector('script[src*="hubspot.com/js/tracking/"])
Use code with caution. Learn more

If the tracking code is installed, you will see a line of code that matches the code you typed in. The line of code will include your HubSpot account ID.

If you do not see a line of code that matches the code you typed in, then the tracking code is not installed correctly. You can try copying and pasting the code again, or you can contact HubSpot support for help.