How to install HubSpot tracking code
The HubSpot tracking code is unique to each HubSpot account and allows HubSpot to monitor your website traffic.
Getting Your Tracking Code
- Go to HubSpot Settings (gear icon)
- Navigate to:
- Marketing Starter/Free: Go to "Tracking Code"
- Other subscriptions: Go to "Tracking & Analytics" > "Tracking code"
- Find "Embed code" section
- Click "Copy" or "Email to my web developer"
Installation by Platform
1. Standard Website
- Paste code before closing
</body>
tag - Add to all pages of your website
- Best practice: Add to footer file for site-wide implementation
2. WordPress
Recommended Method:
- Install "HubSpot All-in-One Marketing" plugin
- Plugin automatically handles code installation
Manual Method:
- Go to Appearance > Editor
- Select Footer file
- Paste tracking code
- Click "Update File"
3. Shopify
- Login to Shopify admin
- Go to Online Store > Themes
- Click Actions > Edit code
- Open theme.liquid
- Paste code before
</body>
- Save changes
4. Wix
- Go to Settings > Advanced
- Click Custom Code
- Click "+ Add Custom Code"
- Paste tracking code
- Name it "HubSpot Tracking Code"
- Select:
- All pages
- Load code on each new page
- Body - end
- Click Apply
5. Squarespace
- Go to Settings
- Navigate to Advanced > Code Injection
- Paste code in Header field
- Save changes
Important Notes
Do's
- Install on all pages
- Verify installation
- Add external domains to HubSpot settings
- Use only one tracking code per page
Don'ts
- Don't install multiple tracking codes
- Don't use on AMP sites
- Don't forget to verify installation