HubSpot Tracking Issues
Platform-specific guides for diagnosing and fixing analytics and tracking issues on HubSpot.
Common Issues
Events Not Firing
Debug why analytics events aren't being captured on HubSpot.
Overview of HubSpot Tracking Issues
HubSpot CMS Hub's integrated marketing platform creates unique tracking scenarios. The platform's built-in analytics, HubL templating language, smart content features, and tracking code management system require special consideration. Understanding HubSpot's tracking architecture alongside external analytics implementation is crucial for effective troubleshooting.
HubSpot-Specific Tracking Challenges
HubSpot's Dual Tracking Environment
HubSpot has its own tracking alongside external analytics:
- HubSpot tracking code - Automatically injected, cannot be removed
- External analytics - Added via Settings > Tracking Code
- Tracking code conflicts - Multiple tracking scripts may interfere
- HubSpot COS vs CMS Hub - Different capabilities and restrictions
- Smart content - Personalized content affects tracking implementation
- A/B testing - Test variations need proper tracking differentiation
Template and Module Restrictions
HubSpot's template system has specific limitations:
- HubL template language - Server-side rendering affects JavaScript timing
- Module-based pages - Drag-and-drop modules may not support custom tracking
- Template restrictions - Limited access to header/footer in some templates
- Global content - Partial templates shared across pages
- Custom modules - JavaScript execution order in custom modules
- Required wrappers - HubSpot-specific div wrappers affect selectors
Permission and Access Levels
Different HubSpot user permissions affect tracking:
- Marketing Hub permissions - Access to tracking code settings
- Website permissions - Ability to edit templates and modules
- Developer access - Required for advanced tracking implementations
- Portal-level settings - Tracking configurations apply to entire portal
- Domain restrictions - Tracking behavior differs across connected domains
Smart Content and Personalization
HubSpot's personalization features create tracking complexity:
- Smart rules - Different content for different visitors
- List-based personalization - Content varies by list membership
- Lifecycle stage - Content changes based on contact stage
- Country/device targeting - Geo and device-specific content
- Dynamic content loading - AJAX-loaded personalized modules
Diagnostic Checklist for Tracking Issues
Work through these steps systematically:
1. Verify Tracking Code Settings
// Check if HubSpot tracking is active
console.log('HubSpot loaded:', typeof _hsq !== 'undefined');
if (typeof _hsq !== 'undefined') {
console.log('HubSpot queue:', _hsq);
}
// Check for external analytics
console.log('GTM loaded:', !!document.querySelector('script[src*="googletagmanager.com/gtm.js"]'));
console.log('GA loaded:', typeof gtag !== 'undefined' || typeof ga !== 'undefined');
// Check for tracking code placement
var trackingScripts = document.querySelectorAll('head script, body > script');
console.log('Total scripts in head/body:', trackingScripts.length);
2. Check HubSpot Tracking Code Settings
Navigate to Settings > Tracking & Analytics > Tracking Code:
- Verify tracking code is installed
- Check if tracking code is in header or footer
- Review excluded pages/URLs
- Confirm tracking code applies to your domain
- Check "Don't track" IP addresses
3. Inspect Template Files
For HubL templates:
{# Check if tracking code region exists in template #}
{% if site_settings.tracking_code %}
{{ site_settings.tracking_code }}
{% endif %}
{# Look for standard_header_includes and standard_footer_includes #}
{{ standard_header_includes }}
{{ standard_footer_includes }}
4. Test Across Different Page Types
- System pages (blog, landing pages)
- Template-based pages
- Website pages vs landing pages
- Blog posts vs blog listing
- Thank you pages
- Form submission pages
5. Check Cookie Banner Integration
HubSpot has built-in cookie consent:
// Check cookie consent status
if (typeof _hsp !== 'undefined') {
console.log('HubSpot privacy:', _hsp);
}
// Check cookie consent
console.log('Cookies:', document.cookie);
Verifying Tracking Code Loads Correctly
Method 1: HubSpot Settings Verification
- Go to Settings > Tracking & Analytics > Tracking Code
- Verify "Install tracking code" is enabled
- Check tracking code placement (header recommended for GTM)
- Ensure no pages are excluded inadvertently
Proper GTM installation in HubSpot:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
Method 2: Browser Console Verification
// Open Console (F12) and run:
// Check HubSpot tracking
if (typeof _hsq !== 'undefined') {
console.log('✓ HubSpot tracking active');
console.log(' Portal ID:', _hsq.portalId || 'Unknown');
} else {
console.warn('✗ HubSpot tracking not detected');
}
// Check external tracking
var tracking = {
'dataLayer exists': typeof dataLayer !== 'undefined',
'GTM loaded': !!window.google_tag_manager,
'GA4 (gtag)': typeof gtag !== 'undefined',
'GA (analytics.js)': typeof ga !== 'undefined'
};
console.table(tracking);
// Check for HubSpot form tracking
if (typeof hbspt !== 'undefined') {
console.log('✓ HubSpot forms API available');
}
Method 3: Network Tab Verification
- Open DevTools Network tab (F12)
- Filter by "hs-scripts" or "analytics"
- Reload page
- Look for:
hs-analytics.js- HubSpot analyticsforms.jsorforms-embed.js- HubSpot formsgtm.js- Google Tag Managercollect- Analytics hits
Verify requests include:
- Correct portal ID for HubSpot
- Page URL and title
- User cookies (hubspotutk)
Method 4: Page Source Inspection
<!DOCTYPE html>
<html>
<head>
<!-- HubSpot tracking should be here if header placement -->
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/PORTAL_ID.js"></script>
<!-- External tracking (GTM/GA) from Tracking Code settings -->
<script>/* GTM or GA code */</script>
</head>
<body>
<!-- Content -->
<!-- Footer tracking if footer placement selected -->
</body>
</html>
Browser Developer Tools Debugging Guide
Console Debugging
// Enable verbose HubSpot tracking logging
localStorage.setItem('HS_BEACON_DEBUG', 'true');
// Monitor dataLayer pushes
(function() {
if (typeof dataLayer === 'undefined') {
console.warn('dataLayer not initialized');
return;
}
var originalPush = dataLayer.push;
dataLayer.push = function() {
console.log('[dataLayer.push]', arguments[0]);
return originalPush.apply(dataLayer, arguments);
};
})();
// Monitor HubSpot form submissions
window.addEventListener('message', function(event) {
if (event.data.type === 'hsFormCallback') {
console.log('HubSpot form event:', event.data.eventName, event.data);
// Push to dataLayer if needed
if (typeof dataLayer !== 'undefined' && event.data.eventName === 'onFormSubmitted') {
dataLayer.push({
'event': 'form_submission',
'form_id': event.data.id,
'form_guid': event.data.formGuid
});
}
}
});
// Check smart content
if (document.querySelector('[data-smart-content]')) {
console.log('Smart content detected on page');
var smartElements = document.querySelectorAll('[data-smart-content]');
console.log('Smart content elements:', smartElements.length);
}
HubSpot-Specific Debugging
// Check HubSpot environment
if (typeof hsVars !== 'undefined') {
console.log('HubSpot variables:', hsVars);
console.log('Portal ID:', hsVars.portal_id);
console.log('Page ID:', hsVars.page_id);
console.log('Content ID:', hsVars.content_id);
}
// Check visitor identification
if (typeof hubspot !== 'undefined') {
console.log('HubSpot object:', hubspot);
}
// Check form embeds
if (typeof hbspt !== 'undefined' && hbspt.forms) {
console.log('HubSpot forms available');
// Monitor form events
hbspt.forms.create({
portalId: "YOUR_PORTAL_ID",
formId: "YOUR_FORM_ID",
onFormReady: function($form) {
console.log('Form ready:', $form);
},
onFormSubmit: function($form) {
console.log('Form submitting:', $form);
},
onFormSubmitted: function($form) {
console.log('Form submitted:', $form);
}
});
}
Network Tab Debugging
Filter for HubSpot and analytics requests:
hs-scripts
hs-analytics
forms.js
gtm
analytics
collect
Inspect HubSpot request headers:
hubspotutkcookie - Visitor tracking cookie__hstc- Main tracking cookie__hssc- Session cookie__hssrc- Determines if visitor restarted session
Common Symptoms and Their Causes
| Symptom | Likely Cause | Solution |
|---|---|---|
| No tracking on any page | Tracking code not installed or disabled | Check Settings > Tracking Code |
| HubSpot tracking works, GA doesn't | External tracking code not added | Add GA/GTM to Tracking Code settings |
| Tracking on some pages, not others | Page excluded in tracking settings | Check "Don't track these pages" setting |
| Duplicate page views | Both HubSpot and external analytics configured similarly | Differentiate or use only one for page views |
| Form submissions not tracked externally | No form event listener | Add HubSpot form callback tracking |
| Smart content breaks tracking | JavaScript runs before content loads | Use MutationObserver for dynamic content |
| Tracking delayed significantly | Tracking code in footer | Move to header in tracking settings |
| Different data in HubSpot vs GA | Different tracking methodologies | Normal - HubSpot tracks contacts, GA sessions |
| CTA clicks not tracked | No event tracking on CTAs | Add onclick handlers or GTM click triggers |
| Blog pages missing tracking | Blog template doesn't include tracking code | Check blog template includes standard_header_includes |
| Subdomain not tracking | Domain not configured in settings | Add domain to Settings > Domains & URLs |
| Landing pages not tracking | Landing page template issue | Verify tracking code enabled for landing pages |
Tag Manager Troubleshooting for HubSpot
GTM Container Setup in HubSpot
Installation location: Settings > Tracking & Analytics > Tracking Code
Header tracking code (recommended):
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
Footer tracking code (noscript):
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
DataLayer Configuration for HubSpot
Push HubSpot-specific data to dataLayer:
In a custom module or template:
<script>
window.dataLayer = window.dataLayer || [];
// Push HubSpot page data
{% if content %}
dataLayer.push({
'hubspot_portal_id': {{ portal_id }},
'hubspot_page_id': {{ content.id }},
'hubspot_page_name': '{{ content.name }}',
'hubspot_page_type': '{{ content_type }}',
'hubspot_author': '{{ content.blog_post_author.display_name|default("Unknown") }}'
});
{% endif %}
// Push contact/visitor data if available
if (typeof hsVars !== 'undefined') {
dataLayer.push({
'hubspot_visitor': true,
'hubspot_portal': hsVars.portal_id
});
}
</script>
GTM Preview Mode Issues
Problem: GTM Preview mode doesn't connect
Solutions:
- Ensure tracking code saved and published in HubSpot
- Clear browser cache
- Disable HubSpot's script minification temporarily
- Check that GTM container ID matches exactly
Debug GTM loading:
// Check if GTM container loaded
if (window.google_tag_manager) {
console.log('✓ GTM containers loaded:', Object.keys(window.google_tag_manager));
} else {
console.error('✗ GTM not loaded');
}
// Check specific container
var containerId = 'GTM-XXXXXX';
if (window.google_tag_manager && window.google_tag_manager[containerId]) {
console.log('✓ Container', containerId, 'loaded');
} else {
console.error('✗ Container', containerId, 'not found');
}
HubSpot Form Tracking with GTM
Track form submissions via dataLayer:
<script>
window.addEventListener('message', function(event) {
if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
dataLayer.push({
'event': 'hubspot_form_submit',
'form_id': event.data.id,
'form_guid': event.data.formGuid,
'form_name': event.data.formName || 'Unknown',
'page_url': window.location.href
});
console.log('HubSpot form submitted, event pushed to dataLayer');
}
});
</script>
HubSpot Form Tracking
Form Submission Events
HubSpot forms use iframe embed, requiring special tracking:
// Add to tracking code or template
<script>
window.addEventListener('message', function(event) {
if (event.data.type === 'hsFormCallback') {
console.log('HubSpot form callback:', event.data.eventName);
switch(event.data.eventName) {
case 'onFormReady':
console.log('Form ready:', event.data.id);
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'form_loaded',
'form_id': event.data.id
});
}
break;
case 'onFormSubmit':
console.log('Form submitting:', event.data.id);
break;
case 'onFormSubmitted':
console.log('Form submitted successfully:', event.data.id);
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'form_submission',
'form_id': event.data.id,
'form_guid': event.data.formGuid,
'page_title': document.title,
'page_path': window.location.pathname
});
}
break;
}
}
});
</script>
Non-HubSpot Form Tracking
For custom HTML forms on HubSpot pages:
<script>
document.addEventListener('DOMContentLoaded', function() {
var forms = document.querySelectorAll('form:not(.hs-form)');
forms.forEach(function(form) {
form.addEventListener('submit', function(e) {
var formId = form.id || form.name || 'unknown';
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'custom_form_submit',
'form_id': formId,
'form_action': form.action
});
}
console.log('Custom form submitted:', formId);
});
});
});
</script>
Cookie and Consent-Related Tracking Problems
HubSpot Cookie Policy
HubSpot has built-in cookie consent management:
- Navigate to Settings > Privacy & Consent
- Enable "Cookie Consent Banner"
- Configure cookie policy and banner text
- Set up cookie categories
Cookie Consent and External Tracking
// Check if cookie consent given
function hasConsentForAnalytics() {
// Check HubSpot cookie consent
var cookieConsent = document.cookie.match(/hubspot-cookie-consent=([^;]+)/);
if (cookieConsent) {
try {
var consent = JSON.parse(decodeURIComponent(cookieConsent[1]));
return consent.categories && consent.categories.analytics === true;
} catch(e) {
console.error('Error parsing cookie consent:', e);
}
}
return false;
}
// Initialize tracking based on consent
if (hasConsentForAnalytics()) {
console.log('Analytics consent granted');
if (typeof gtag !== 'undefined') {
gtag('consent', 'update', {
'analytics_storage': 'granted'
});
}
} else {
console.log('No analytics consent');
}
// Listen for consent changes
window.addEventListener('message', function(event) {
if (event.data.type === 'hsConsentUpdate') {
console.log('Consent updated:', event.data);
if (event.data.categories && event.data.categories.analytics) {
// Re-initialize tracking
console.log('Analytics consent now granted');
}
}
});
GDPR Compliance
// Don't track contact email or PII without consent
// HubSpot automatically handles contact data
// For custom tracking, use anonymized identifiers
if (typeof hsVars !== 'undefined' && dataLayer) {
dataLayer.push({
'visitor_id': hsVars.visitor_id, // Already anonymized
// Don't include: email, name, phone, etc.
});
}
HubSpot-Specific Integration Conflicts
HubSpot vs External Analytics Conflicts
Issue: Duplicate tracking events
Solution: Differentiate data sources
// Use HubSpot for contact/marketing analytics
// Use GA/GTM for website behavior analytics
// Don't duplicate page views in both systems
// Or use different naming conventions
dataLayer.push({
'event': 'ga_pageview', // Prefix for GA
// vs
'event': 'hubspot_pageview' // Prefix for HubSpot
});
jQuery Conflicts
HubSpot loads jQuery, which may conflict:
// Check jQuery version
console.log('jQuery version:', typeof jQuery !== 'undefined' ? jQuery.fn.jquery : 'not loaded');
// If you need a specific jQuery version
var jq = jQuery.noConflict();
Smart Content and Tracking
Smart content can break selectors and event listeners:
// Use MutationObserver for dynamic content
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
// Re-attach event listeners
console.log('DOM changed, checking for new elements');
var smartElements = document.querySelectorAll('[data-smart-content]');
smartElements.forEach(function(el) {
// Attach tracking as needed
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
Event Tracking Validation Steps
1. Create Event Tracking Code
Add to Settings > Tracking & Analytics > Tracking Code (footer):
<script>
(function() {
'use strict';
// Wait for DOM ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
function init() {
console.log('HubSpot event tracking initialized');
// Track CTA clicks
var ctas = document.querySelectorAll('a[href*="cta/"], .cta, [data-cta]');
ctas.forEach(function(cta) {
cta.addEventListener('click', function(e) {
var ctaText = this.textContent.trim();
var ctaUrl = this.href;
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'cta_click',
'cta_text': ctaText,
'cta_url': ctaUrl,
'page_url': window.location.href
});
}
console.log('CTA clicked:', ctaText);
});
});
// Track outbound links
var links = document.querySelectorAll('a[href^="http"]');
links.forEach(function(link) {
link.addEventListener('click', function(e) {
var href = this.href;
var hostname = new URL(href).hostname;
if (hostname !== window.location.hostname) {
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'outbound_click',
'outbound_url': href,
'outbound_domain': hostname
});
}
console.log('Outbound click:', href);
}
});
});
// Track downloads
var downloadLinks = document.querySelectorAll('a[href$=".pdf"], a[href$=".doc"], a[href$=".docx"], a[href$=".zip"]');
downloadLinks.forEach(function(link) {
link.addEventListener('click', function(e) {
var fileUrl = this.href;
var fileName = fileUrl.split('/').pop();
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'file_download',
'file_name': fileName,
'file_url': fileUrl
});
}
console.log('File download:', fileName);
});
});
}
})();
</script>
2. Validate Events in Real-Time
// Monitor events for 30 seconds
(function() {
if (typeof dataLayer === 'undefined') {
console.error('dataLayer not available');
return;
}
var events = [];
var originalPush = dataLayer.push;
dataLayer.push = function(obj) {
if (obj.event) {
events.push({
time: new Date().toISOString(),
event: obj.event,
data: obj
});
console.log('Event captured:', obj.event);
}
return originalPush.apply(dataLayer, arguments);
};
setTimeout(function() {
dataLayer.push = originalPush;
console.log('Event monitoring complete. Total events:', events.length);
console.table(events);
}, 30000);
console.log('Monitoring dataLayer for 30 seconds...');
})();
3. Test HubSpot Form Events
// Test form submission event
function testFormEvent() {
if (typeof dataLayer === 'undefined') {
console.error('dataLayer not available');
return;
}
dataLayer.push({
'event': 'hubspot_form_submit',
'form_id': 'test-form-123',
'form_guid': 'test-guid',
'test': true
});
console.log('Test form event pushed. Check GTM Preview or GA4 DebugView');
}
testFormEvent();
Ecommerce Tracking Troubleshooting
HubSpot doesn't have native ecommerce, but integrates with platforms:
Shopify + HubSpot Integration
If using HubSpot with Shopify:
// Track ecommerce events when Shopify data available
if (typeof Shopify !== 'undefined' && Shopify.checkout) {
var checkout = Shopify.checkout;
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'transaction_id': checkout.order_id,
'value': checkout.total_price,
'currency': checkout.currency,
'items': checkout.line_items.map(function(item) {
return {
'item_id': item.product_id,
'item_name': item.title,
'price': item.price,
'quantity': item.quantity
};
})
}
});
}
}
CDN and Caching Troubleshooting
HubSpot CDN
HubSpot serves content through its CDN:
Problem: Tracking code changes not appearing
Solutions:
- Clear cache: File Manager > Settings > Clear cache
- Wait for propagation: Changes may take 5-10 minutes
- Force refresh: Ctrl+Shift+R or Cmd+Shift+R
- Check preview vs published: Ensure changes published
Verify tracking code version:
// Check when tracking script was loaded
var scripts = document.querySelectorAll('script[src*="hs-scripts"]');
scripts.forEach(function(script) {
console.log('HubSpot script:', script.src);
// Check cache headers
fetch(script.src)
.then(r => {
console.log('Cache headers:', {
'Cache-Control': r.headers.get('Cache-Control'),
'Age': r.headers.get('Age')
});
});
});
External CDN Integration
If using external CDN with HubSpot:
- Ensure CDN not caching HTML pages
- Configure cache rules to respect HubSpot headers
- Purge CDN after tracking changes
Debugging Code Examples
Complete HubSpot Diagnostic Script
(function() {
console.log('=== HubSpot Analytics Diagnostic ===');
// HubSpot environment
var hsChecks = {
'HubSpot tracking (_hsq)': typeof _hsq !== 'undefined',
'HubSpot forms (hbspt)': typeof hbspt !== 'undefined',
'HubSpot vars (hsVars)': typeof hsVars !== 'undefined',
'HubSpot analytics script': !!document.querySelector('script[src*="hs-scripts.com"]')
};
console.table(hsChecks);
if (typeof hsVars !== 'undefined') {
console.log('Portal ID:', hsVars.portal_id);
console.log('Page ID:', hsVars.page_id);
console.log('Content type:', hsVars.content_type);
}
// External tracking
var externalChecks = {
'dataLayer exists': typeof dataLayer !== 'undefined',
'dataLayer items': typeof dataLayer !== 'undefined' ? dataLayer.length : 0,
'GTM loaded': !!window.google_tag_manager,
'GA4 (gtag)': typeof gtag !== 'undefined',
'GA (analytics.js)': typeof ga !== 'undefined'
};
console.table(externalChecks);
// Cookie check
var cookies = {
'hubspotutk': document.cookie.includes('hubspotutk'),
'__hstc': document.cookie.includes('__hstc'),
'__hssc': document.cookie.includes('__hssc'),
'_ga': document.cookie.includes('_ga')
};
console.log('Cookies present:');
console.table(cookies);
// Check for issues
var issues = [];
if (typeof _hsq === 'undefined') {
issues.push('HubSpot tracking not loaded');
}
if (typeof dataLayer === 'undefined' && document.querySelector('script[src*="gtm.js"]')) {
issues.push('GTM script loaded but dataLayer not initialized');
}
if (issues.length > 0) {
console.warn('Issues detected:');
issues.forEach(issue => console.warn('- ' + issue));
} else {
console.log('✓ No obvious issues detected');
}
console.log('=== Diagnostic Complete ===');
})();
Test Event Function
function testHubSpotEvent(eventName, eventData) {
console.log('Testing event:', eventName);
if (typeof dataLayer === 'undefined') {
console.error('❌ dataLayer not available');
return false;
}
var eventObj = {
'event': eventName,
'timestamp': new Date().toISOString(),
'test': true,
'hubspot_portal': typeof hsVars !== 'undefined' ? hsVars.portal_id : 'unknown'
};
Object.assign(eventObj, eventData);
dataLayer.push(eventObj);
console.log('✓ Event pushed:', eventObj);
setTimeout(function() {
var found = dataLayer.some(item => item.event === eventName && item.test === true);
console.log(found ? '✓ Event in dataLayer' : '❌ Event not found');
}, 100);
return true;
}
// Usage:
testHubSpotEvent('test_cta_click', { cta_text: 'Test CTA' });
When to Contact Support
1. HubSpot Tracking Code Issues
Contact HubSpot support if:
- Tracking code not loading despite being enabled
- Portal ID showing incorrectly
- Tracking code settings keep reverting
Provide:
- Portal ID
- Screenshot of Tracking Code settings
- Page URL where tracking fails
- Browser console errors
2. Form Tracking Problems
Contact if:
- Form callbacks not firing
- Form submissions not appearing in HubSpot
- Form events not accessible via message listener
Provide:
- Form GUID
- Form embed code
- Browser console output
- Form submission test video/screenshot
3. Template/Module Issues
Contact if:
- Custom module JavaScript not executing
- Template doesn't support tracking code
- HubL syntax errors breaking tracking
Provide:
- Template name and ID
- Module code snippet
- Error messages
4. Permission/Access Issues
Contact if:
- Cannot access Tracking Code settings
- Settings not saving
- Different behavior for different users
Provide:
- User permission level
- Screenshot of error
- Account admin confirmation
Information to Gather Before Contacting Support
// Run this and share output with support
(function() {
var diagnostics = {
url: window.location.href,
hubspot: typeof hsVars !== 'undefined' ? {
portal_id: hsVars.portal_id,
page_id: hsVars.page_id,
content_type: hsVars.content_type
} : 'not available',
tracking: {
hubspot_loaded: typeof _hsq !== 'undefined',
forms_available: typeof hbspt !== 'undefined',
dataLayer_exists: typeof dataLayer !== 'undefined',
gtm_loaded: !!window.google_tag_manager
},
cookies: document.cookie.split(';').filter(c =>
c.includes('hubspot') || c.includes('_ga') || c.includes('_gid')
),
errors: []
};
var errors = [];
window.addEventListener('error', function(e) {
errors.push({
message: e.message,
source: e.filename,
line: e.lineno
});
});
setTimeout(function() {
diagnostics.errors = errors;
console.log('=== HubSpot Diagnostics for Support ===');
console.log(JSON.stringify(diagnostics, null, 2));
}, 3000);
})();
General Fixes
For universal tracking concepts, see the Global Tracking Issues Hub.