Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!doctype html>
<html>

<head>
    <!-- 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-KJ2TH74');
    </script>
    <!-- End Google Tag Manager -->

    <script type="text/javascript">
        var _iub = _iub || [];
        _iub.csConfiguration = {
            lang: 'en',
            siteId: 896537, //use your siteId
            cookiePolicyId: 8207462, //use your cookiePolicyId

            enableCcpa: true,
            ccpaApplies: true,

            enableGdpr: true,
            gdprAppliesGlobally: false,
            gdprApplies: true,
            perPurposeConsent: true,

            timeoutLoadConfiguration: 30000,
            consentOnScroll: false, //avoid consent to be given when the user scrolls the page

            banner: {
                position: 'float-top-center',
                acceptButtonDisplay: true,
                customizeButtonDisplay: true,
                rejectButtonDisplay: true,
            },
            
            callback: {
                onPreferenceExpressedOrNotNeeded: function(preference) {
                    dataLayer.push({
                        iubenda_ccpa_opted_out: _iub.cs.api.isCcpaOptedOut()
                    });
                    
                    if (!preference) {
                        dataLayer.push({
                            event: "iubenda_preference_not_needed"
                        });
                    } else {
                        if (preference.consent === true) {
                            dataLayer.push({
                                event: "iubenda_consent_given"
                            });
                        } else if (preference.consent === false) {
                            dataLayer.push({
                                event: "iubenda_consent_rejected"
                            });
                        } else if (preference.purposes) {
                            for (var purposeId in preference.purposes) {
                                if (preference.purposes[purposeId]) {
                                    dataLayer.push({
                                        event: "iubenda_consent_given_purpose_" + purposeId
                                    });
                                }
                            }
                        }
                    }
                }
            }
        };
    </script>
    <script async src="//cdn.iubenda.com/cs/iubenda_cs.js"></script>
</head>

<body>
    <header>
        <div class="wrapper">
            <h1>iubenda Cookie Solution</h1>
            <p>Google Tag Manager integration for CCPA, GDPR and per-category consent</p>
        </div>
    </header>

    <section class="wrapper">

        <p>💡 Click on "Accept", "Reject", "Learn more and customize" and "Do Not Sell My Personal Information" to customize your consent preferences for cookies.</p>
      
        <div class="scripts">
          <div class="script" id="no-purpose"> No Purpose</div>
          <div class="script" id="no-purpose-sells"> No Purpose - Sale (to be blocked when CCPA opted out)</div>
          <div class="script" id="purpose-1"> Strictly Necessary (no consent required)</div>
          <div class="script" id="purpose-2"> Basic Interactions & Functionalities</div>
          <div class="script" id="purpose-3"> Experience Enhancement</div>
          <div class="script" id="purpose-4"> Analytics</div>
          <div class="script" id="purpose-4-sells"> Analytics - Sale (to be blocked when CCPA opted out)</div>
          <div class="script" id="purpose-5"> Targeting & Advertising</div>
        </div>

        <div class="note">
            <ul>
                <li>Remember to use your own credentials from <a href="https://www.iubenda.com/en/dashboard" target="_blank">your iubenda account</a></li>
                <li>This is a sample for pure demonstrative purposes, <strong>no consents are saved</strong> (result of <code>_iub.csConfiguration.skipSaveConsent = true</code>). Just refresh the page to make the cookie banner reappear.</li>
            </ul>
        </div>

        <h3>Learn more</h3>
        <div class="tip">
          <p>Read the guide <a href="https://www.iubenda.com/en/help/1235" target="_blank">How to Use Google Tag Manager to Simplify the Blocking of Cookies</a> for more information about additional settings.</p>
        </div>

        <p>Other helpful resources:</p>
        <ul class="guides">
            <li><a href="https://www.iubenda.com/en/help/1177" target="_blank">Cookie Solution - Getting Started</a></li>
            <li><a href="https://www.iubenda.com/en/help/3831" target="_blank">How to Customize the Look and Behavior of the Cookie Banner (Beginner's Guide)</a></li>
            <li><a href="https://www.iubenda.com/en/help/1205" target="_blank">How to Configure Your Cookie Solution (Advanced Guide)</a></li>
            <li><a href="https://www.iubenda.com/en/help/21165" target="_blank">CCPA: How to add a notice of collection and a "Do not sell" link</a></li>
        </ul>

    </section>
</body>
</html>
              
            
!

CSS

              
                /* don't copy this CSS (just for demo purposes) */

div.scripts .script {
  border-bottom: 1px solid #D5D5D5;
  margin-bottom: -1px;
  padding: 14px 6px;
}

div.scripts .script:last-of-type {
  border-bottom: none;
}

div.scripts .script:before {
  content: '🚫';
}

div.scripts .script.activated:before, 
div#purpose-1:before {
  content: '✅';
}
              
            
!

JS

              
                //don't copy this JS (just for demo purposes)

//don't save consent, always show the banner
_iub.csConfiguration.skipSaveConsent = true;

// for testing purposes only to avoid setting the CCPA cookie
_iub.csConfiguration.callback.onCcpaOptOut = _iub.csConfiguration.callback.onCcpaAcknowledged = function() {
    setTimeout(function() {
        _iub.cs.cookie.resetLocalCookie('usprivacy');
    });
};
              
            
!
999px

Console