Optimize for non-Webflow sites

Integrate with TrustArc

Updated

Let visitors opt in or out of Optimize using TrustArc cookie preferences.

TrustArc is a service that helps companies manage privacy and data protection compliance. If your company uses TrustArc, you can modify the Optimize snippet to respect a visitor’s cookie preferences — either by blocking the snippet by default (opt-in) or loading it by default (opt-out).

Good to know

Optimize does not use cookies to apply variations.

How to implement

  1. Decide whether you want to use the opt-in or opt-out snippet version
  2. Replace all 123456789 placeholders with your actual Optimize account ID
  3. Add the snippet to every page on your website — use the default snippet install doc as a reference

Snippet with opt-out behavior

This version loads Optimize by default. If the visitor later opts out of functional cookies, the snippet will no longer run.

Steps:

  • Find your account ID in your Optimize Account Settings
  • Replace all 123456789 instances in the code below with your actual account ID
<!-- Optimize opt-out snippet -->
    <style>.anti-flicker, .anti-flicker * {visibility: hidden !important; opacity: 0 !important;}</style>
    <script>(function(e,t,p){var n=document.documentElement,s={p:[],r:[]},u={p:s.p,r:s.r,push:function(e){s.p.push(e)},ready:function(e){s.r.push(e)}};e.intellimize=u,n.className+=" "+p,setTimeout(function(){n.className=n.className.replace(RegExp(" ?"+p),"")},t)})(window, 4000, 'anti-flicker')</script>
    <link rel="preload" href="https://cdn.intellimize.co/snippet/123456789.js" as="script">
    <link rel="preconnect" href="https://api.intellimize.co" crossorigin>
    <link rel="preconnect" href="https://123456789.intellimizeio.com"> 
    <link rel="preconnect" href="https://log.intellimize.co" crossorigin>
    <script>
        (function(){
            function removeFlickerGuard() {
                document.documentElement.className = document.documentElement.className.replace(RegExp(' ?anti-flicker'), '');
            }
            let hasOptedOut = false;
            try {
                const ta_gdpr_prefs = JSON.parse(localStorage.getItem('truste.cookie.notice_gdpr_prefs')).value;
                // TrustArc levels: 0 = required, 1 = functional, 2 = advertising
                const TA_FUNCTIONAL = 1;
                // Check if "functional" preference is set
                hasOptedOut = ta_gdpr_prefs.indexOf(TA_FUNCTIONAL) === -1;
            } catch(xx) { /* TrustArc preferences not set */ }
            
            // if user has opted out
            if (hasOptedOut) {
                // Remove page hiding
                removeFlickerGuard();
                return;
            }
            
            // Load Intellimize
            const iS = document.createElement('script');
            iS.type = 'text/javascript';
            iS.async = true;
            iS.src = 'https://cdn.intellimize.co/snippet/123456789.js';
            iS.onerror = function() { removeFlickerGuard(); }
            const s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(iS, s);
        })();
    </script>
<!-- Optimize end -->

Snippet with opt-in behavior

This version blocks Optimize by default. The snippet only loads if the visitor explicitly opts in to functional cookies.

Steps:

  • Find your account ID in your Optimize Account Settings
  • Replace all 123456789 instances in the code below with your actual account ID
<!-- Optimize opt-in snippet -->
    <style>.anti-flicker, .anti-flicker * {visibility: hidden !important; opacity: 0 !important;}</style>
    <script>(function(e,t,p){var n=document.documentElement,s={p:[],r:[]},u={p:s.p,r:s.r,push:function(e){s.p.push(e)},ready:function(e){s.r.push(e)}};e.intellimize=u,n.className+=" "+p,setTimeout(function(){n.className=n.className.replace(RegExp(" ?"+p),"")},t)})(window, 4000, 'anti-flicker')</script>
    <link rel="preload" href="https://cdn.intellimize.co/snippet/123456789.js" as="script">
    <link rel="preconnect" href="https://api.intellimize.co" crossorigin>
    <link rel="preconnect" href="https://123456789.intellimizeio.com"> 
    <link rel="preconnect" href="https://log.intellimize.co" crossorigin>
    <script>
        (function(){
            function removeFlickerGuard() {
                document.documentElement.className = document.documentElement.className.replace(RegExp(' ?anti-flicker'), '');
            }
            let hasOptedIn = false;
            try {
                const ta_gdpr_prefs = JSON.parse(localStorage.getItem('truste.cookie.notice_gdpr_prefs')).value;
                // TrustArc levels: 0 = required, 1 = functional, 2 = advertising
                const TA_FUNCTIONAL = 1;
                // Check if "functional" preference is set
                hasOptedIn = ta_gdpr_prefs.indexOf(TA_FUNCTIONAL) >= -1;
            } catch(xx) { /* TrustArc preferences not set */ }
            
            // if user has opted in
            if (hasOptedIn) {
                // Load Intellimize
                const iS = document.createElement('script');
                iS.type = 'text/javascript';
                iS.async = true;
                iS.src = 'https://cdn.intellimize.co/snippet/123456789.js';
                iS.onerror = function() { removeFlickerGuard(); }
                const s = document.getElementsByTagName('script')[0];
                s.parentNode.insertBefore(iS, s);
            } else {
                // Remove page hiding
                removeFlickerGuard();
            }
        })();
    </script>
<!-- Optimize end -->