Fixing Tracking Events Not Firing on Squarespace
When tracking tags or events aren't working on your Squarespace site, it can prevent you from measuring conversions, optimizing campaigns, and understanding user behavior. This guide helps you diagnose and fix common tracking issues.
Quick Diagnostic Checklist
Before diving deep, check these common issues:
- Is the tracking code actually installed?
- Did you save changes in Code Injection?
- Are you testing in incognito mode (no ad blockers)?
- Are there JavaScript errors in the console?
- Is the event trigger condition actually being met?
- Are you testing on the live site (not preview)?
- Did you publish your changes?
Common Tracking Issues by Platform
Google Analytics 4 (GA4)
Issue: No Page Views Tracking
Symptoms:
- No data in GA4 Realtime reports
- Empty reports after 24 hours
- DebugView shows no events
Diagnostic Steps:
- Check if GA4 tag is loading:
// In browser console, type:
gtag
// Should show function, not "undefined"
- Verify Measurement ID:
- Check your GA4 setup
- Ensure ID format is
G-XXXXXXXXXX(starts with G-) - Verify it matches your GA4 property
- Check Code Injection:
- Settings > Advanced > Code Injection
- Ensure code is in Header section
- Verify no syntax errors (missing closing tags)
Solutions:
If using native integration:
- Go to Settings > Analytics > Google Analytics
- Click "Connect Account"
- Paste Measurement ID
- Save
If using code injection:
<!-- Verify this code is in Header -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Check for conflicts:
- Don't use both native integration AND code injection
- Choose one method only
Issue: Events Not Firing
Symptoms:
- Page views work, but custom events don't appear
- Form submissions not tracked
- Commerce events missing
Diagnostic Steps:
- Check event code placement:
- Custom events should be in Footer Code Injection
- Or wrapped in DOMContentLoaded listener
- Verify gtag is defined:
if (typeof gtag !== 'undefined') {
gtag('event', 'your_event');
} else {
console.error('gtag not defined');
}
- Check event syntax:
// Correct
gtag('event', 'form_submit', {
'form_name': 'contact'
});
// Incorrect - missing quotes around event name
gtag('event', form_submit, {
'form_name': 'contact'
});
Solutions:
Ensure code runs after gtag loads:
<script>
document.addEventListener('DOMContentLoaded', function() {
// Wait for DOM to be ready
if (typeof gtag !== 'undefined') {
// Your event tracking code here
}
});
</script>
Test in DebugView:
- Install Google Analytics Debugger extension
- Enable it
- In GA4, go to Configure > DebugView
- Trigger your event
- Check if it appears in DebugView
Issue: Ecommerce Events Not Tracking
Symptoms:
- Add to cart not firing
- Purchase events missing
- Product views not tracked
Squarespace-Specific Causes:
- Ajax Cart (Squarespace 7.1): Cart updates don't trigger page reloads
Solution:
<script>
if (window.Y && window.Y.Squarespace) {
window.Y.use(function(Y) {
Y.on('cart:item:added', function(e) {
if (typeof gtag !== 'undefined') {
gtag('event', 'add_to_cart', {
currency: 'USD',
value: e.item.price / 100,
items: [{
item_id: e.item.id,
item_name: e.item.title,
price: e.item.price / 100
}]
});
}
});
});
}
</script>
- Purchase Event in Wrong Location:
Check: Purchase code must be in ORDER CONFIRMATION PAGE section, not site-wide Footer.
Correct Location:
- Settings > Advanced > Code Injection
- Scroll to ORDER CONFIRMATION PAGE
- Add purchase tracking there
- Price in Cents:
Squarespace stores prices in cents:
// Wrong
value: orderData.grandTotal.value // This is in cents!
// Correct
value: orderData.grandTotal.value / 100 // Convert to dollars
Google Tag Manager (GTM)
Issue: GTM Container Not Loading
Symptoms:
- No tags firing
- Preview mode won't connect
google_tag_managerundefined in console
Diagnostic Steps:
- Verify container code:
// In browser console:
google_tag_manager
// Should show object with your container ID
- Check code placement:
- Header snippet must be in Code Injection > Header
- Footer snippet should be in Code Injection > Footer
- Both snippets required
- Verify Container ID:
<!-- Should have YOUR container ID -->
'GTM-XXXXXX'
<!-- NOT a placeholder -->
Solutions:
Re-install GTM:
- Get fresh code from GTM (Admin > Install Google Tag Manager)
- Remove old code from Code Injection
- Add new code (Header snippet in Header, noscript in Footer)
- Save
- Test in Preview mode
Issue: Tags Not Firing
Symptoms:
- GTM loaded but specific tags don't fire
- Preview mode shows tags not triggered
- Events missing in GA4
Diagnostic Steps:
- Use GTM Preview Mode:
- Click Preview in GTM
- Enter your site URL
- Navigate site
- Check Tags tab to see which fired
- Check Trigger Conditions:
- Are conditions too restrictive?
- Does the page match the trigger?
- Are variables populated correctly?
- Check Tag Configuration:
- Is tag enabled?
- Is triggering set up?
- Are variables available?
Solutions:
For Squarespace 7.1 Ajax Navigation:
Create History Change trigger:
- Triggers > New
- Trigger Type: History Change
- Fire on: All History Changes
- Save
Use this trigger for page view tags on 7.1 sites.
For Form Submissions:
Check if form is Squarespace native:
// Forms have class: .sqs-block-form
document.querySelectorAll('.sqs-block-form form');
Create Form Submission trigger:
- Trigger Type: Form Submission
- Wait for Tags: Enabled (2000ms)
- Check Validation: Enabled
- Fire on: Some Forms
- Condition: Form Classes contains
sqs-block-form
Issue: Data Layer Variables Undefined
Symptoms:
- GTM variables show "(not set)"
- Data layer events not triggering tags
- Custom variables empty
Diagnostic Steps:
- Check data layer in console:
dataLayer
// Should show array of objects
- Verify timing:
- Is data pushed before GTM loads?
- Data layer code must be BEFORE GTM snippet
- Check variable names:
- Case-sensitive
- Must match exactly
Solutions:
Correct data layer placement:
<!-- In Header, BEFORE GTM snippet -->
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'pageType': 'homepage',
'userType': 'guest'
});
</script>
<!-- THEN GTM container code -->
<script>(function(w,d,s,l,i)...
For Squarespace Commerce Data:
Wait for data to be available:
document.addEventListener('DOMContentLoaded', function() {
if (window.Static && window.Static.SQUARESPACE_CONTEXT) {
var product = window.Static.SQUARESPACE_CONTEXT.product;
if (product) {
dataLayer.push({
'productId': product.id,
'productName': product.title
});
}
}
});
Meta Pixel
Issue: Pixel Not Loading
Symptoms:
- Meta Pixel Helper shows no pixel
- Events Manager shows no activity
fbqis undefined in console
Diagnostic Steps:
- Check if pixel loaded:
// In browser console:
fbq
// Should show function, not "undefined"
- Verify Pixel ID:
- Check format: 15-16 digits
- No spaces or extra characters
- Appears in both places in code
- Check Code Injection:
- Should be in Header
- Both
<script>and<noscript>tags
Solutions:
Re-install Meta Pixel:
Get fresh code from Meta Events Manager:
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=YOUR_PIXEL_ID&ev=PageView&noscript=1"/>
</noscript>
Check for conflicts:
- Don't use both native integration (External API Keys) AND code injection
- Remove from one location
Issue: Events Not Firing
Symptoms:
- PageView works, but custom events don't
- Purchase event missing
- AddToCart not tracking
Diagnostic Steps:
- Use Meta Pixel Helper:
- Install extension
- Visit your site
- Click helper icon
- Check which events fire
- Verify event code:
if (typeof fbq !== 'undefined') {
fbq('track', 'EventName');
} else {
console.error('fbq not defined');
}
- Check Test Events:
- Events Manager > Test Events
- Enter your URL
- Trigger events
- Verify they appear
Solutions:
For Squarespace Ajax Cart:
<script>
if (window.Y && window.Y.Squarespace) {
window.Y.use(function(Y) {
Y.on('cart:item:added', function(e) {
if (typeof fbq !== 'undefined') {
fbq('track', 'AddToCart', {
content_ids: [e.item.id],
content_name: e.item.title,
value: e.item.price / 100,
currency: 'USD'
});
}
});
});
}
</script>
For Purchase Event:
Must be in ORDER CONFIRMATION PAGE section:
<script>
var orderData = {orderInformation};
if (orderData && typeof fbq !== 'undefined') {
fbq('track', 'Purchase', {
value: orderData.grandTotal.value,
currency: orderData.grandTotal.currency
});
}
</script>
Squarespace-Specific Issues
Issue: Member Area Pages Not Tracking
Symptoms:
- Tracking works on public pages
- Member-only pages don't track
- Login pages missing from analytics
Cause: Member areas may have different script loading behavior.
Solution:
Ensure tracking code is in site-wide Header, not page-specific:
- Settings > Advanced > Code Injection
- Add to site-wide Header
- NOT in page-specific settings
For member status tracking:
<script>
if (window.Squarespace && window.Squarespace.user) {
window.Squarespace.onInitialize(Y, function() {
var isLoggedIn = Y.Squarespace.User.isLoggedIn();
if (typeof gtag !== 'undefined') {
gtag('set', 'user_properties', {
'member_status': isLoggedIn ? 'member' : 'guest'
});
}
});
}
</script>
Issue: Events Fire on Page Load but Not on Ajax Actions
Symptoms:
- Initial page load works
- Subsequent navigation doesn't track
- Cart updates not tracked
- Form submissions on 7.1 not working
Cause: Squarespace 7.1 uses Ajax for some interactions.
Solutions:
For 7.1 Navigation (GTM):
Use History Change trigger instead of Page View.
For Ajax Cart:
Use Y.Squarespace events:
if (window.Y && window.Y.Squarespace) {
window.Y.use(function(Y) {
Y.on('cart:item:added', function(e) {
// Track add to cart
});
Y.on('cart:item:removed', function(e) {
// Track remove from cart
});
});
}
For Form Submissions:
Forms may use Ajax. Track submission confirmation:
var forms = document.querySelectorAll('.sqs-block-form form');
forms.forEach(function(form) {
form.addEventListener('submit', function() {
setTimeout(function() {
var success = form.querySelector('.form-submission-text');
if (success && success.style.display !== 'none') {
// Form submitted successfully
gtag('event', 'form_submit');
}
}, 1000);
});
});
Issue: Y.Squarespace or YUI Errors
Symptoms:
- Console error: "Y is not defined"
- "Y.Squarespace is undefined"
- Commerce events not working
Cause: YUI framework not loaded yet.
Solution:
Wrap code in proper callback:
// Wrong
if (window.Y && window.Y.Squarespace) {
Y.on('cart:item:added', function(e) {
// May not work - Y not ready
});
}
// Correct
if (window.Y && window.Y.Squarespace) {
window.Y.use(function(Y) {
// Now Y is properly loaded
Y.on('cart:item:added', function(e) {
// This will work
});
});
}
General Troubleshooting Steps
Step 1: Check Browser Console
- Open your site
- Press F12 (DevTools)
- Go to Console tab
- Look for errors (red text)
Common Errors:
| Error | Meaning | Solution |
|---|---|---|
| "X is not defined" | Script/variable not loaded | Check script is installed and loads first |
| "Failed to load resource" | File not found or blocked | Check URL, test without ad blockers |
| "Uncaught SyntaxError" | Code syntax error | Check for missing brackets, quotes, semicolons |
| "Mixed Content" warning | HTTP on HTTPS site | Update URLs to HTTPS |
Step 2: Test in Incognito Mode
Ad blockers and extensions can block tracking.
- Open incognito/private window
- Visit your site
- Test tracking
- If it works in incognito, it's likely an extension blocking
Step 3: Check Network Tab
See what requests are being sent:
- F12 > Network tab
- Reload page
- Filter by "gtag" or "fbevents" or "gtm"
- Check if requests are sent
- Check for any failed (red) requests
Step 4: Verify Code Syntax
Use validators:
- JSHint for JavaScript
- HTML Validator for HTML
Common syntax errors:
// Missing closing bracket
gtag('event', 'test', {
'param': 'value'
// Missing }); here
// Unmatched quotes
gtag('event', "test", {
'param': 'value'
});
// Missing comma
gtag('event', 'test', {
'param1': 'value1'
'param2': 'value2' // Missing comma after 'value1'
});
Testing Checklist
Before concluding tracking works:
- Test in incognito mode
- Test on desktop
- Test on mobile device
- Test in different browsers (Chrome, Safari, Firefox)
- Trigger all event types
- Check Realtime reports (GA4) or Test Events (Meta)
- Wait 24-48 hours for full reports
- Verify conversion tracking with test purchase
When Ad Blockers Are Blocking
Reality: 25-40% of users have ad blockers.
Solutions:
Accept it:
- You'll never track 100% of users
- Focus on trends, not absolute numbers
Server-Side Tracking:
- Use GTM Server-Side
- Requires technical setup
- More complex but more reliable
First-Party Tracking:
- Use Squarespace's native analytics
- Won't be blocked
- Limited compared to GA4
Don't:
- Try to "defeat" ad blockers (unethical and ineffective)
- Panic about missing data (expected with ad blockers)
Debugging Tools
For GA4:
- Google Tag Assistant
- Google Analytics Debugger
- GA4 DebugView (in GA4 interface)
For GTM:
- GTM Preview Mode (built-in)
- DataLayer Inspector
For Meta Pixel:
- Meta Pixel Helper
- Meta Events Manager Test Events
General:
Getting Help
Squarespace Support
Will help with:
- Platform issues
- Account problems
- Template bugs
Won't help with:
- Custom code debugging
- Third-party integration issues
- Analytics setup
Community Resources
- Squarespace Forum
- r/squarespace
- Stack Overflow (tag: squarespace)
Professional Help
Consider hiring a developer for:
- Complex tracking implementations
- Custom integrations
- Persistent issues you can't solve
Prevention Tips
Test Before Publishing:
- Always test in preview mode
- Verify tracking works
- Check console for errors
Keep Backups:
- Save copies of working code
- Document what you change
- Note dates of modifications
Use Version Control (GTM):
- Add version notes when publishing
- Easy to rollback if issues
- Track what changed when
Monitor Regularly:
- Check analytics weekly
- Set up alerts for data anomalies
- Review error reports
Next Steps
- Optimize Performance if tracking scripts are slowing your site
- Review Integration Setup to ensure proper implementation
- Set up monitoring alerts in GA4 or Events Manager