Snippets

Nudge Thought Catalog - Question Example

Created by Izac Hancock last modified
<!-- Live Example Preview 

  https://codepen.io/izchk/pen/abZgBgx


Link to Thought Catalog Stylesheet, this should NOT be added as it will already be on the page -->
<link rel="stylesheet" id="screen-css-0" href="https://thoughtcatalog.com/wp-content/themes/thoughtcatalog-2014/assets/css/app.css?m=1601650017g" type="text/css" media="screen">


<!--- COPY BELOW CODE FOR QUESTION -->
<!-- Nudge Tracking Javascript -->
<script src="https://cdn.ndg.io/ndg-2336634874.js" async ></script>

<!-- Detect user response and send to Nudge as an event -->
<script>
window.onload = ndgQuestion;
window.ndgResponseClick = false;

function ndgQuestion() {
  document.getElementById("btn").onclick = ndgResponse;
}

function ndgResponse(n) {
  if (!window.ndgResponseClick) {
    var img = document.createElement("img");
    img.setAttribute("src", "https://e.ndg.io/v1/v.gif?owner_id=2336634874&url=" + window.location.href + "&content_id=TC_response&name=" + n.target.id);
    img.setAttribute("width", "1");
    img.setAttribute("height", "1");
    if (n.target.tagName == 'BUTTON') {
      n.target.className += " btn-black";
      document.body.appendChild(img);
      window.ndgResponseClick = true;
    }
  }
}
</script>

<!-- Question block with Yes or No buttons --> 
<div class="box">
  <div class="entry-header-flair">
    <div class="sponsored-article-footer__body">
      <div class="row">
        <div class="sponsored-article-footer__title text-center">
          <p>Will you be checking out Clarice on CBS?</p>
          <div id="btn" class="buttons">
            <button id="Yes" class="btn btn-v2">Yes</button>
            <button id="No" class="btn btn-v2">No</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.