Skip to content
WSWS ThemesDocs
Engine4 min readUpdated August 2026

Script Gating & Category Blocking

How to block third-party marketing and analytics scripts until visitors grant explicit consent.

Under strict privacy regulations like GDPR and Law 25, non-essential tracking pixels must never execute prior to explicit opt-in. WS Cookie Consent provides an intelligent script interception engine.

How Script Gating Works#

The gating engine dynamically prevents target scripts from executing by intercepting DOM script element creation and evaluating data-ws-consent-category tags.

Tagging Custom Inline Scripts#

To gate custom tracking snippets (such as custom TikTok pixels, Hotjar, or affiliate trackers) added to theme.liquid, change type="text/javascript" to type="text/plain" and add the category attribute:

html
<!-- Gated Marketing Script -->
<script type="text/plain" data-ws-consent-category="marketing">
  !function(f,b,e,v,n,t,s){
    // Third-party tracking script executes ONLY after consent is granted
    fbq('init', '1234567890');
    fbq('track', 'PageView');
  }();
</script>

Auto-Gated Third-Party Integrations#

  • Meta Pixel (Facebook Ads)
  • TikTok Pixel & Events SDK
  • Pinterest Tag
  • Klaviyo Onsite Tracking (Marketing)
  • Hotjar & Microsoft Clarity (Analytics)

Have feedback or question about this guide?

Our commerce engineering studio provides direct developer assistance.