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>
  <script>
    function initializeCMP(callbacks) {
      window._iub = window._iub || [];
      _iub.csConfiguration = {
        cookiePolicyId: 417383,
        siteId: 1,
        logLevel: 'error',
        lang: 'en',
        enableTcf: true
      };

      if (callbacks) {
        _iub.csConfiguration.callback = callbacks
      }

      // Note: this gives error on codepen only
      // It should work on a regular top frame
      var stubScript = document.createElement('script');
      stubScript.src = '//cdn.iubenda.com/cs/tcf/beta/stub.js';
      document.body.insertBefore(stubScript, document.body.firstChild);

      var cmpScript = document.createElement('script');
      cmpScript.src = '//cdn.iubenda.com/cs/beta/iubenda_cs.js';
      cmpScript.setAttributeNode(document.createAttribute('async'));
      document.body.insertBefore(cmpScript, stubScript.nextSibling);
    }
  </script>
  <script>
    // Note: more scenarios can be produced by following this link: https://iabtcf.com/#/encode
    var scenarios = {
      'everything rejected': 'CPAQjlJPAQlAKB7D3CENBJCgAAAAAAAAAAAAHPQAAOfgAAAA',
      'everything accepted': 'CPAQjlJPAQmKhB7D3CENBJCsAP_AAH_AAAAAHPNd_X_fb39j-_59_9t0eY1f9_7_v-0zjgeds-8Nyd_X_L8X42M7vF36pq4KuR4Eu3LBIQFlHOHUTUmw6okVrTPsak2Mr7NKJ7PEinMbe2dYGHtfn9VTuZKYr97s___z__-__v__79f_r-3_3_vp9X---_e_UDnwCTDUvgIsxLHAkmjSqFECEK4kOgFABRQjC0TWEBK4KdlcBH6CBgAgNQEYEQIMQUYsAgAAAACSiICQA8EAiAIgEAAIAVICEABGgCCwAkDAIABQDQsAIoAhAkIMjgqOUwICJFooJ5KwBKLvYwwhDKLACgUf0VAA',
      'purpose 1 accepted': 'CPAQjlJPAQmF8B7D3CENBJCgAIAAAAAAAAAAHPNd_X_fb39je_59f9t0eY1P997_v-wjjgeds-8NyV_W_L8X42M7vF36pqoKuQ4EuzJBIQFlGOHURUmw6okVpSPMak2Mq5NKJ7PEinMbO2dYGGlfndVDuQKYr97sftrz_9-6_v__79f-r-33z_vJUX-u8tO9UAAAAAAA',
      'purpose 2 accepted with leg int': 'CPAQjlJPAQmfeB7D3CENBJCgAEAAAEAAAAAAHPNRZQ2AbmsDuR4ViZN0YQBXAOyivwQxhgcZE4wFwNPDGBcF4AM4nFnwJCYCORgEGGDAIAFlCKEQDQkwCokBrCCsaE2IAqJCBYKAikMaWwBIGGFdH9VROZKQhtqo55jSbPwtQGucJocUKqhOGfPhhBS4clQXUDn4AAAA',
      'purpose 2 rejected but leg int accepted': 'CPAQjlJPAQmo9B7D3CENBJCgAAAAAEAAAAAAHPQAAAAAAAAA',
      'special feature 1 accepted': 'CPAQjlJPAQmyVB7D3CENBJCoAAAAAAAAAAAAHGBJUGJETCJAi5pZIBAwYAhOA-SDFw0QiAIJEoEEgJqAdBIEgEIRFBjIoKgKgAgEqiBAAABBCKGADQgAIIkACQKMAkGADQNABgBAAFELA2FAACFLEsBToQAAjFgEJavQQIwhqGEFIBAAAUCQAIAABUwKOkAAAAAA',
      'vendor 826 accepted': 'CPAQjlJPAQnAkB7D3CENBJCgAAAAAAAAAAAAHGQAQE6AAAAA',
      'vendor 92 accepted with leg int': 'CPAQjlJPAQnJFB7D3CENBJCgAAAAAAAAAAAAAuQAQAuAC5ABAC4AAAAA',
      'vendor 92 rejected but leg int accepted': 'CPAQjlJPAQnPkB7D3CENBJCgAAAAAAAAAAAAAuQAABcgAgBcAAAA'
    };

    function initializeCMPWithScenario(scenario, cb) {
      var callbacks = {
        onBeforePreload: function() {
          // This function is used to store a user's consent programmatically
          _iub.cs.api.storeConsent({
            consent: true,
            tcfv2: scenarios[scenario]
          });
        }
      };

      if (cb) {
        callbacks.onReady = cb;
      }

      initializeCMP(callbacks);
    }
  </script>
</head>

<body>
  <header>
    <div class="wrapper">
      <h1>iubenda Cookie Solution</h1>
      <p>PoC to test CMP</p>
    </div>
  </header>

  <section class="wrapper">

    <p>In this <a href="https://www.iubenda.com/en/help/7440" target="_blank">TCF</a> demo we show vendors how to take advantage of <code>storeConsent()</code> to test our <a href="https://www.iubenda.com/en/cookie-solution" target="_blank">Cookie Solution</a>. Head to our <a href="https://www.iubenda.com/en/help/1205#banner-content" target="_blank">advanced guide</a> to learn more about this parameter.</p>

    <hr />

    <h4>Helpful guides</h4>
    <ul class="guides">
      <li><a href="https://www.iubenda.com/en/help/7440" target="_blank">The complete guide to TCF and iubenda's Consent Management Platform</a></li>
      <li><a href="https://www.iubenda.com/en/help/1205" target="_blank">How to configure your Cookie Solution (Advanced Guide)</a></li>
    </ul>

  </section>
</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                initializeCMPWithScenario('everything accepted', function() {
  console.log('CMP initialized');
  // Get TC data and verify it's consistent with the scenario
  __tcfapi('getTCData', 2, function(tcData) {
    console.log(tcData);
  });
});

              
            
!
999px

Console