Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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> 
    <title>Home Questionnaire</title> <span id="selection-marker-1" class="redactor-selection-marker"></span>
</head> 
<body> 
<h1>What is your favorite place to travel?</h1> 
<p>I am building a directory of the sweetest travel destinations.</p>  
<form name="travel" onsubmit="identify(event)">
     What is your favorite travel destination?
    <input name="destination" required="" size="81" type="text"/> 
    <br><br><br> 
    Any recommendations (cool things to do, places to visit or restaurants to eat)? 
    <br><br> 
    <textarea cols="81" name="details" required="" rows="10">
    </textarea> 
    <br><br> 
    Name: <input name="fullname" required="" size="75" type="text"/> 
    <br><br> 
    Email: <input name="email" required="" size="75" type="email"/> 
    <br><br>
    <input name="submit" type="submit" value="submit"/>
</form> 
 <!--  Div Below is where consent manager will be injected to  -->
  <div id="target-container"></div>
</body> 
</html>
              
            
!

CSS

              
                 #target-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}
              
            
!

JS

              
                
//code below loads consentManagerConfig object and specifies content popup contains. Need to update with your own writeKey and what container code should be injected to, I am using empyty div 

//note, may need to view demo in debug mode to save tracking preferences in browser


window.consentManagerConfig = function(exports) {
      return {
       //Need to update with the container where you want Consent Manager to load
        container: '#target-container',
        //Need to update with you 
        writeKey: 'VuOZbPNXuR76IXTQeYaU6twg3qpSNAw9',
        bannerContent:
          'Consent manager is awesome! We use cookies (and other similar technologies) to collect data to improve your experience on our site. Also, Segment is Awesome',
        bannerSubContent: 'You can change your preferences at any time.',
        preferencesDialogTitle: 'Website Data Collection Preferences',
        preferencesDialogContent:
          'We use data collected by cookies and JavaScript libraries to improve your browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.',
        cancelDialogTitle: 'Are you sure you want to cancel?',
        cancelDialogContent:
          'Your preferences have not been saved. By continuing to use our website, you are agreeing to our Website Data Collection Policy',
        closeBehavior: 'accept',
      }
};

</script>
<!--script that loads Prebuilt Consent Manager UI via Preact-->
 <script src="https://unpkg.com/@segment/consent-manager@5.0.0/standalone/consent-manager.js"> </script>

<!--Load Analytics.js-->
<script>
        !(function() {
          var analytics = (window.analytics = window.analytics || [])
          if (!analytics.initialize)
            if (analytics.invoked)
              window.console && console.error && console.error('Segment snippet included twice.')
            else {
              analytics.invoked = !0
              analytics.methods = [
                'trackSubmit',
                'trackClick',
                'trackLink',
                'trackForm',
                'pageview',
                'identify',
                'reset',
                'group',
                'track',
                'ready',
                'alias',
                'debug',
                'page',
                'once',
                'off',
                'on', 
                //methods below needed for consent manager version 5.0.0 and greater!!
                'addSourceMiddleware', 
                'addDestinationMiddleware'
              ]
              analytics.factory = function(t) {
                return function() {
                  var e = Array.prototype.slice.call(arguments)
                  e.unshift(t)
                  analytics.push(e)
                  return analytics
                }
              }
              for (var t = 0; t < analytics.methods.length; t++) {
                var e = analytics.methods[t]
                analytics[e] = analytics.factory(e)
              }
              analytics.load = function(t, e) {
                var n = document.createElement('script')
                n.type = 'text/javascript'
                n.async = !0
                n.src =
                  ('https:' === document.location.protocol ? 'https://' : 'http://') +
                  'cdn.segment.com/analytics.js/v1/' +
                  t +
                  '/analytics.min.js'
                var o = document.getElementsByTagName('script')[0]
                o.parentNode.insertBefore(n, o)
                analytics._loadOptions = e
              }
              analytics.SNIPPET_VERSION = '4.1.0'
              analytics.page()
            }
        })()
      </script>

<!--Javascript that controls form submits and mapping user input data to Segment Analytics.js methods-->
<script type="text/javascript">
    function identify(e){
      e.preventDefault();
      var form = e.target;
      var email = form["email"].value;
      var fullname = form["fullname"].value;
      var destination = form["destination"].value;
      var details = form["details"].value;
      var user = {
          email: email, 
          name: fullname, 
          destination: destination, 
          details: details
      };
      analytics.identify('1234', {
          email: email, 
          name: fullname
      });
      analytics.track('destination submitted', user, , function() {
          window.location.href = "";
      });
      analytics.page('Home', user, {
        url: "/" 
      });
      analytics.alias('507f191e81');
      analytics.group("0e8c78ea9d97a7b8185e8632", {
            name: "Initech", 
            industry: "Technology",
            employees: 329, 
            plan: "enterprise", 
            "total billed": 830
            });
    }
</script>




              
            
!
999px

Console