Fixing Tracking Events Not Firing on Squarespace | Blue Frog Docs

Fixing Tracking Events Not Firing on Squarespace

Comprehensive troubleshooting guide for analytics and tracking issues on Squarespace, including GA4, GTM, Meta Pixel, and platform-specific problems.

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:

  1. Check if GA4 tag is loading:
// In browser console, type:
gtag
// Should show function, not "undefined"
  1. Verify Measurement ID:
  • Check your GA4 setup
  • Ensure ID format is G-XXXXXXXXXX (starts with G-)
  • Verify it matches your GA4 property
  1. 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:

  1. Go to Settings > Analytics > Google Analytics
  2. Click "Connect Account"
  3. Paste Measurement ID
  4. 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:

  1. Check event code placement:
  • Custom events should be in Footer Code Injection
  • Or wrapped in DOMContentLoaded listener
  1. Verify gtag is defined:
if (typeof gtag !== 'undefined') {
  gtag('event', 'your_event');
} else {
  console.error('gtag not defined');
}
  1. 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:

  1. Install Google Analytics Debugger extension
  2. Enable it
  3. In GA4, go to Configure > DebugView
  4. Trigger your event
  5. 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:

  1. 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>
  1. 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
  1. 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_manager undefined in console

Diagnostic Steps:

  1. Verify container code:
// In browser console:
google_tag_manager
// Should show object with your container ID
  1. Check code placement:
  • Header snippet must be in Code Injection > Header
  • Footer snippet should be in Code Injection > Footer
  • Both snippets required
  1. Verify Container ID:
<!-- Should have YOUR container ID -->
'GTM-XXXXXX'
<!-- NOT a placeholder -->

Solutions:

Re-install GTM:

  1. Get fresh code from GTM (Admin > Install Google Tag Manager)
  2. Remove old code from Code Injection
  3. Add new code (Header snippet in Header, noscript in Footer)
  4. Save
  5. 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:

  1. Use GTM Preview Mode:
  • Click Preview in GTM
  • Enter your site URL
  • Navigate site
  • Check Tags tab to see which fired
  1. Check Trigger Conditions:
  • Are conditions too restrictive?
  • Does the page match the trigger?
  • Are variables populated correctly?
  1. Check Tag Configuration:
  • Is tag enabled?
  • Is triggering set up?
  • Are variables available?

Solutions:

For Squarespace 7.1 Ajax Navigation:

Create History Change trigger:

  1. Triggers > New
  2. Trigger Type: History Change
  3. Fire on: All History Changes
  4. 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:

  1. Trigger Type: Form Submission
  2. Wait for Tags: Enabled (2000ms)
  3. Check Validation: Enabled
  4. Fire on: Some Forms
  5. 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:

  1. Check data layer in console:
dataLayer
// Should show array of objects
  1. Verify timing:
  • Is data pushed before GTM loads?
  • Data layer code must be BEFORE GTM snippet
  1. 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
  • fbq is undefined in console

Diagnostic Steps:

  1. Check if pixel loaded:
// In browser console:
fbq
// Should show function, not "undefined"
  1. Verify Pixel ID:
  • Check format: 15-16 digits
  • No spaces or extra characters
  • Appears in both places in code
  1. 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:

  1. Use Meta Pixel Helper:
  • Install extension
  • Visit your site
  • Click helper icon
  • Check which events fire
  1. Verify event code:
if (typeof fbq !== 'undefined') {
  fbq('track', 'EventName');
} else {
  console.error('fbq not defined');
}
  1. 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:

  1. Settings > Advanced > Code Injection
  2. Add to site-wide Header
  3. 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

  1. Open your site
  2. Press F12 (DevTools)
  3. Go to Console tab
  4. 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.

  1. Open incognito/private window
  2. Visit your site
  3. Test tracking
  4. If it works in incognito, it's likely an extension blocking

Step 3: Check Network Tab

See what requests are being sent:

  1. F12 > Network tab
  2. Reload page
  3. Filter by "gtag" or "fbevents" or "gtm"
  4. Check if requests are sent
  5. Check for any failed (red) requests

Step 4: Verify Code Syntax

Use validators:

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:

  1. Accept it:

    • You'll never track 100% of users
    • Focus on trends, not absolute numbers
  2. Server-Side Tracking:

    • Use GTM Server-Side
    • Requires technical setup
    • More complex but more reliable
  3. 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:

For GTM:

For Meta Pixel:

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

Professional Help

Consider hiring a developer for:

  • Complex tracking implementations
  • Custom integrations
  • Persistent issues you can't solve

Prevention Tips

  1. Test Before Publishing:

    • Always test in preview mode
    • Verify tracking works
    • Check console for errors
  2. Keep Backups:

    • Save copies of working code
    • Document what you change
    • Note dates of modifications
  3. Use Version Control (GTM):

    • Add version notes when publishing
    • Easy to rollback if issues
    • Track what changed when
  4. Monitor Regularly:

    • Check analytics weekly
    • Set up alerts for data anomalies
    • Review error reports

Next Steps


Additional Resources

// SYS.FOOTER