Training

How to Install HubSpot Tracking Code: Complete Step-by-Step Tutorial

HubSpot tracking code installation is essential for getting accurate analytics data from your website. Without proper tracking code installation, you're missing critical data about visitor behavior, lead sources, and conversion paths that power your marketing decisions.

This guide walks you through the complete process of adding the tracking script to your site so you can finally see which marketing efforts are actually driving results.

What is HubSpot Tracking Code and Why You Need It

The tracking code is a unique JavaScript snippet that enables website integration for analytics and lead tracking. Every account gets its own code snippet that must be installed on external pages to track website activity. If your website was built in HubSpot, you don't need to do this.

What tracking enables:
  • Website conversion tracking capabilities
  • Lead tracking from first visit to sale
  • Visitor behavior analytics and personalization
  • Attribution reporting for marketing campaigns

Before You Install the Tracking Code

Important prerequisites:
Team access: Your developer needs a user account
Domain setup: External domains must be added to settings
WordPress sites: Use the official plugin instead of manual installation
Single tracking rule: Never install multiple tracking codes on one page

 

Step 1: Access Your Tracking Code

How to find your tracking script:
  1. Log into your account
  2. Click the settings icon ⚙️ in the top navigation bar
  3. Navigate to tracking settings:
    • Marketing Starter/Free: Click Tracking Code in left sidebar
    • Professional/Enterprise: Go to Tracking & Analytics > Tracking code
  4. Locate the Embed code section

Your tracking code for website integration will be displayed in a gray text box.
 

Step 2: Copy Your Tracking Code

Two options to get your code snippet:
Option A: Copy the code directly
  1. In the Embed code section, click Copy
  2. The tracking script is now in your clipboard
Option B: Email to your developer
  1. Click Email to my web developer
  2. Enter your developer's email address
  3. The system sends installation instructions with the code

Pro tip: The email option includes context that helps your team understand the integration requirements.

 

Step 3: Install the Code on Your Website

Where to place the tracking script:
The code must be installed before the closing </body> tag on every page you want to track.

For WordPress Sites

Recommended: Use the Plugin
  1. Install HubSpot All-in-One Marketing plugin
  2. Connect your account
  3. The plugin automatically handles tracking code installation

For Other Platforms

Manual installation:
  1. Access your website's HTML editor
  2. Open the template file that appears on all pages (usually footer.php or similar)
  3. Paste the tracking script before </body>
  4. Save and publish changes
Code placement example:
html
<!-- Your existing page content -->[YOUR TRACKING CODE HERE]
</body></html>

 

Step 4: Add External Domains

Configure the system to recognize your external site:
  1. Go to Settings > Tracking & Analytics
  2. Click Domains & URLs
  3. Add your external domain(s)
  4. Save changes
This step ensures your external pages appear in analytics and reporting.

 

Step 5: Verify Installation

Test your website integration:
  1. Visit a page with the tracking code
  2. Go to Reports > Analytics Tools
  3. Check for recent page views in your analytics
  4. Use browser developer tools to verify the script loads

Troubleshooting: If tracking isn't working, check:
  • Code placement (must be before </body>)
  • External domains added to settings
  • No duplicate tracking codes installed

Step 6: Configure Additional Settings

Optimize your tracking setup:
Privacy and compliance:
  • Configure cookie consent if required
  • Review data sharing settings in account preferences
Advanced tracking:
  • Set up conversion tracking for forms
  • Configure lead tracking for specific pages
  • Enable tracking pixels for email campaigns

Common Installation Issues


Multiple tracking codes: Only the first code loads
Solution: Remove duplicate installations

Wrong placement: Code in <head> instead of before </body>
Solution: Move code to correct location

Ad blockers: Can interfere with tracking
Solution: Test with ad blockers disabled

AMP pages: Not supported
Solution: Use alternative tracking methods

Best Practices for Tracking Code

Maximize your analytics setup:
  • Test thoroughly: Verify tracking on key pages
  • Monitor regularly: Check analytics for data gaps
  • Document installation: Keep records of where code is installed
  • Update team: Ensure developers know about tracking requirements

What Happens After Installation

Once your install HubSpot tracking code process is complete, you'll start seeing:
  • Visitor analytics in your dashboard
  • Lead source attribution for new contacts
  • Page view tracking for content optimization
  • Conversion data for ROI analysis

Questions or comments? Share below!

RELATED POST