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

              
                <div class="container">

  <div class="canvas"><table align="center" border="0" cellpadding="0" cellspacing="10">
    <tbody>
      <tr>
        <td align="center" style="padding:12px 24px; background-color: #FFFFFF; border: 1px solid #DBDCDE; border-radius: 3px;">
          <table border="0" cellpadding="0" cellspacing="0" style="font-size:12px; font-weight: bold; font-family: helvetica, arial, sans-serif; color: #4a4a4a;">
            <tbody>
              <tr style="border-spacing: 0px;">
                <td align="center" colspan="2" style="border-spacing: 0px;"><span id="sentiment-message">What did you think of this email?</span><br /> &nbsp;
                </td>
              </tr>
              <tr style="border-spacing: 0px;">
                <td align="center" style="border-spacing: 0px;">
                  <a id="dislike-link" href="" target="_blank" style="text-decoration: none; color: #505E67;"><img alt="Hated it" height="40" src="https://hostedimages-cdn.aweber-static.com/OTE=/original/1510ec1e54b042f99582f77bffe0db20.png" style="border: 0px none;" width="40" /></a>
                </td>
                <td align="center" style="border-spacing: 0px;">
                  <a id="like-link" href="" target="_blank" style="text-decoration: none; color: #EA7880;"><img alt="Loved it" height="40" src="https://hostedimages-cdn.aweber-static.com/OTE=/original/3bd5370ad0c44282a107811f798ab2f5.png" style="border: 0px none;" width="40" /> </a>
                </td>
              </tr>
            </tbody>
          </table>
        </td>
      </tr>
    </tbody>
    </table></div>
  
  <div class="right-rail">
    <button class="button button--light button--selected" id="settings-tab">Settings</button>
    <button id="how-to-tab" class="button button--light">Setup Tutorial</button>
    <div id="settings">
      <h2>Settings</h2>
      <p>Remember to include <a href="https://support.google.com/analytics/answer/1033867?hl=en" target="_blank">utm parameters</a> if you want results to show up in your Google Analytics</p>

      <div class="form-control">
        <label>Dislike redirect URL<br/>
          <span>This is where users are redirected when they click the <strong>dislike</strong> button.</span>
          <span class="error-msg">please add a valid redirect url<span>
        </label>
        <input type='url' id="dislike-link-input" placeholder="start your link with www., http://, or https://" />
      </div>

      <div class="form-control">
        <label>Like redirect URL<br/>
          <span>This is where users are redirected when they click the <strong>like</strong> button.</span>
          <span class="error-msg">please add a valid redirect url<span>
        </label>
        <input type='url' id="like-link-input" placeholder="start your link with www., http://, or https://" />
      </div>
    
      <!--
      <label>Sentiment Title<br/>
        <span>The title text that appears above the icons.</span>
      </label>
      <input type="text" id="sentiment-title-input" />
      -->
      
      <div class="form-control">
        <label>
          Sticker Set
        </label>
        <div id="sticker-choices">
          <label>
            <span>Our team of amazing email geeks at <a href="http://www.aweber.com" target="_blank">AWeber</a> made these for you:</span>
          </label>
          <img src="https://hostedimages-cdn.aweber-static.com/OTE=/original/3bd5370ad0c44282a107811f798ab2f5.png" alt="hearts" id="icons-hearts" data-icons="0" />
          <img src="https://hostedimages-cdn.aweber-static.com/OTE=/original/8036568aeb964b4a851daf42d4c870c4.png" alt="faces" id="icons-faces" data-icons="1" />
          <img src="https://hostedimages-cdn.aweber-static.com/OTE=/original/531a7c4c8a3c47ae878fa106d582b45c.png" alt="Icecream" id="icons-icecream" data-icons="2" />
          <img src="https://s22.postimg.org/ckr094p5d/halloween_positive.png" alt="Pumpkin" id="icons-pumpkin" data-icons="4" />
          
          <label>
            <span>The insanely fun and creative folks from <a href="http://www.reallygoodemails.com" target="_blank">Really Good Emails</a> made a sticker too:</span>
          </label>
          
          <img src="https://hostedimages-cdn.aweber-static.com/OTc2MTMx/original/97e3e3f783924c6988417e24bc2fe377.png" alt="Icecream" id="icons-rge" data-icons="3" />
        </div>
      </div>

      <div class="button-container">
        <button id="getCode" type="submit" class="button">Get your code</button>
      </div>
    </div>
    
    <div id="how-to" style="display: none;">
      <h2>Setup Instructions</h2>
An easy way for anyone to use this sentiment widget is to use <a href="https://support.google.com/analytics/answer/1033867?hl=en">UTM parameters</a> to visualize clicks in Google Analytics.

<ol>
	<li>First, make sure that you have Google Analytics set up for the site you are directing traffic to. If you want to use this method, it's very important that you are directing your users to a site that is set up with Google Analytics. For help on setting up Google Analytics for your site, <a href="https://support.google.com/analytics/answer/1008015?hl=en&amp;ref_topic=3544906">click here</a>.</li>
	<li>Once you have analytics set up and working on your site, the next step is to create your utm link. Try using Google's <a href="https://support.google.com/analytics/answer/1033867?hl=en">URL Builder Form</a> to make this whole process easier. We recommend creating your link using the following guidelines:
	<ul>
		<li><strong>Campaign Source</strong> - This is a high level campaign name. We find it most helpful to put the name of your email list in this section (e.g., <strong>blogList</strong>).</li>
		<li><strong>Campaign Medium</strong> - We recommend setting this to <strong>email</strong>.</li>
		<li><strong>Campaign Term</strong> - Feel free to leave this blank.</li>
		<li><strong>Campaign Content</strong> - This is the primary value you will be using to differentiate between positive responses and negative responses. We recommend you set this as <strong>negative</strong> for your negative link and <strong>positive</strong> for your positive link.</li>
		<li><strong>Campaign Name</strong> - This is a name that should be used for a single specific email you plan on sending. In our case, we try and map this back to our subject line.</li>
	</ul>
	</li>
	<li>Next up, go <a href="https://codepen.io/cvasquez/full/oxBvMP/">create your widget</a> using the utm urls you just generated!</li>
</ol>

<h2>Analyzing Your Results:</h2>
After you send your first email that includes a sentiment widget, you'll probably be excited to start seeing results. As a quick note, when working with Google Analytics, you'll generally want to allow for 24 hours after you've sent your email to start seeing accurate results.<br />
<br />
An easy way to begin to see how many people are clicking your sentiment links is to do the following in Google Analytics:

<ol>
	<li>In Google Analytics, select Acquisition > Overview > All Traffic > Channels from the left hand rail.<br />
	<img alt="" src="https://surveygizmolibrary.s3.amazonaws.com/library/15034/ScreenShot20160316at1_55_48PM.png" /></li>
	<li>Select Email from the resulting list.</li>
	<li>Next, select Campaign as the primary dimension.<br />
	<img alt="" src="https://surveygizmolibrary.s3.amazonaws.com/library/15034/ScreenShot20160316at1_55_48PM.png" /></li>
	<li>The last step is to select Ad Content as your secondary dimension, and then you should be able to search for your campaign/content combination in the resulting list.<br />
	<img alt="" src="https://surveygizmolibrary.s3.amazonaws.com/library/15034/ScreenShot20160316at2_00_05PM.png" /></li>
</ol>
<br />
If you have any questions about the <a href="https://blog.aweber.com/">AWeber Blog</a>, feel free to <a href="https://www.aweber.com/contact-us.htm">contact us</a> at any time.
    </div>
  </div>
</div>

<div class="modal-wrapper">
  <div class="modal">
    <p>Copy the code below and paste it into the html of your email.</p>
    <textarea id="generated-html" style="width: 100%; height: 100px;"></textarea>
    <p style="text-align:right">
      <button id="close" type="submit" class="button button--gray">close</button>
    </p>
  </div>
</div>
              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
}
.button {
  padding: 10px 15px;
  border-radius: 3px;
  border: none;
  background: #0079C1;
  color: white;
  cursor: pointer;
  
  &:focus {
    border: none;
    }
  
  &.button--light {
    background: #EAEAEA;
    color: #777777;
    
    &.button--selected {
      background: #CCCCCC;
      color: #5a5a5a;
    }
  }
  
  &.button--gray {
    background: #777777;
  }
  
  
}

.container {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
  height: 100%;
  
  .canvas {
    width: 60%;
    padding-top: 60px;
    box-sizing: border-box;
    align-self: flex-start;
  }

  .right-rail {
    min-height: 100vh;
    width: 40%;
    box-sizing: border-box;
    padding: 20px;
    border-left: 1px solid #cccccc;
    background: #fafafa;
    font-family: helvetica, arial, sans-serif;
    
    h2 {
      margin-bottom: 0px;
    }
    
    p {
      margin: 5px 0 15px;
      font-size: 12px;
      line-height: 1.3;
    }
    
    img {
      max-width: 100%;
    }

    label {
      display: block;
      font-size: 14px;
      font-weight: bold;
      line-height: 1.5;
      margin: 5px 0;

      span {
        font-size: 12px;
        line-height: 1.3;
        display: block;
        font-weight: normal;
      }
    }
    
    .error-msg {
      color: red;
      display: none;
    }
    
    input {
      margin-bottom: 20px;
      padding: 8px 5px 10px;
      display: block;
      width: 100%;
      box-sizing: border-box;
      
      &.error {
        border: 1px solid red;
        background-color: rgba(255,0,0,0.1);
      }
    }
    
    #sticker-choices img {
      cursor: pointer;
      padding: 5px;
      border-radius: 30px;
      border: 1px solid transparent;
      box-sizing: content-box;
      height:50px;
      width: 50px;
      margin: 0 0 5px;
      
      &.selected,
      &.selected:hover {
        background: #EAEAEA;
        border-color: #CCCCCC;
      }
      &:hover {
        background: #f5f5f5;
        border-color: #e2e2e2;
      }
    }
    
    .button-container {
      text-align: center;
      margin-bottom: 20px;
    }
  }
}

.modal-wrapper {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 500;
  background: rgba(255,255,255,0.8);
  text-align: left;
}
.modal {
  font-family: helvetica, arial, sans-serif;
  font-size: 14px;
  padding: 10px;
  background: white;
  width: 100%;
  max-width: 600px;
  margin: 20px auto;
}

@media screen and (max-width: 600px) {
  .container {
    flex-direction: column;
    
    .canvas {
      width: 100%;
    }
    .right-rail {
      width: 100% !important;
      min-height: auto;
    }
  }
}
              
            
!

JS

              
                var theText = 'What did you think of this email?',
    theDislikeLink,
    theLikeLink,
    currentIcon,
    htmlTest,
    htmlTesting,
    theHTML = $('#generated-html');
    
var icons = [];
icons[0] = ["https://hostedimages-cdn.aweber-static.com/OTE=/original/1510ec1e54b042f99582f77bffe0db20.png", "https://hostedimages-cdn.aweber-static.com/OTE=/original/3bd5370ad0c44282a107811f798ab2f5.png", "40"];
icons[1] = ["https://hostedimages-cdn.aweber-static.com/OTE=/original/dd9732f8fb914be9bbdf0f39416e6088.png", "https://hostedimages-cdn.aweber-static.com/OTE=/original/8036568aeb964b4a851daf42d4c870c4.png", "40"],
  icons[2] = ["https://hostedimages-cdn.aweber-static.com/OTE=/original/cd5b7cb3f3ee4e759553dafeb2a4088d.png", "https://hostedimages-cdn.aweber-static.com/OTE=/original/531a7c4c8a3c47ae878fa106d582b45c.png", "50"],
  icons[3] = ["https://hostedimages-cdn.aweber-static.com/OTc2MTMx/original/ddaf90ec8ff644d8847f6cfbaa9221b7.png", "https://hostedimages-cdn.aweber-static.com/OTc2MTMx/original/333d4662cf594c24b56ef6139a4fde3b.png", "60"],
  icons[4] = ["https://hostedimages-cdn.aweber-static.com/OTc2MTMx/original/a73b46bb51a84baa9aefd83278785c77.png", "https://hostedimages-cdn.aweber-static.com/OTc2MTMx/original/719a8e8ce43d4e639582a37e9bb386e5.png", "40"];

$(document).ready(function() {
  $("#dislike-link").attr("href", theDislikeLink);
  $("#like-link").attr("href", theLikeLink);
  
  var startingSticker = Math.floor((Math.random() * 4));
  
  changeIcons(icons[startingSticker]);
  $("#sticker-choices img:nth-of-type(" + (startingSticker + 1) + ")").addClass("selected");
  
  htmlTest = $('.canvas').html();
  htmlTesting = htmlTest.replace(/&amp;/g, '&'); 
  theHTML.val(htmlTesting);
});


//Icon button
iconButton("#icons-hearts");
iconButton("#icons-faces");
iconButton("#icons-icecream");
iconButton("#icons-rge");
iconButton("#icons-pumpkin");

function iconButton(elem) {
  $(elem).on("click", function(){
    var iconNum = $(this).data("icons");
    changeIcons(icons[iconNum]);
    $(this).siblings().removeClass("selected");
    $(this).addClass("selected");
  });
}

// Icon switcher
function changeIcons(iconFamily) {
  $("#dislike-link img").attr({
    "src": iconFamily[0],
    "width": iconFamily[2],
    "height": iconFamily[2]
  });
  $("#like-link img").attr({
    "src": iconFamily[1],
    "width": iconFamily[2],
    "height": iconFamily[2]
  });
  
  htmlTest = $('.canvas').html();
  htmlTesting = htmlTest.replace(/&amp;/g, '&'); 
  theHTML.val(htmlTesting);
}


// Set dislike link redirect
$("#dislike-link-input").change(function(){
  theDislikeLink = $("#dislike-link-input").val();
  
  buildSentiment();
});


// Set like link redirect
$("#like-link-input").change(function(){
  theLikeLink = $("#like-link-input").val();
  
  buildSentiment();
});


/* @TODO: Change Sentiment Title
$("#sentiment-title-input").change(function(){
  theText = $("#sentiment-title-input").val();
  
  buildSentiment();
});
*/


// Update Sentiment contents and settings
function buildSentiment() {
  $("#dislike-link").attr("href", theDislikeLink);
  $("#like-link").attr("href", theLikeLink);
  
  htmlTest = $('.canvas').html();
  htmlTesting = htmlTest.replace(/&amp;/g, '&'); 
  theHTML.val(htmlTesting);
}

$("#getCode").on("click", function(){
  var fields = $(".form-control input"),
      errorMsgs = $(".form-control .error-msg"),
      errors = 0;
  for(var i=0;i<fields.length;i++){
    if(!$(fields[i]).val()){
      $(fields[i]).addClass("error");
    console.log($(fields[i]));      $(errorMsgs[i]).show();
      errors ++
    } else {
    $(fields[i]).removeClass("error");
      $(errorMsgs[i]).hide();
      errors = 0;
    }
  }
  if(errors==0) {
    $(".modal-wrapper").fadeIn();
  }
});

$("#close").on("click", function(){
  $(".modal-wrapper").fadeOut();
});

$("#settings-tab").on("click", function(){
 $(this).siblings().removeClass("button--selected");
  $(this).addClass("button--selected");
  $("#settings").show();
  $("#how-to").hide();
});

$("#how-to-tab").on("click", function(){
  $(this).siblings().removeClass("button--selected");
  $(this).addClass("button--selected");
  $("#how-to").show();
  $("#settings").hide();
});
              
            
!
999px

Console