Passback implementation tutorial

Let's do a basic tutorial on how to create passbacks for publishers.

  1. Example passback code Click Here
  2. Sandbox environment Here
  3. Video tutorial

At a high level, the goal is to first force a no-ad response from Virool (RP's VAST tag) and then see the passback code execute. Feel free to use any text editor and sandbox environment you'd like. If you're having trouble forcing a No-Ad from Virool, make sure to remove the "test_ad" parameter, and proxy to a different country.

  1. Add additional callback function
  2. Add boiler plate code
  callbacks: {
        onadfail: function (unit) {
        console.log("on ad fail");
        var passbackCode = "[ADD YOUR PASSBACK AS 1 Line]";
        var passbackContainer = window.top.document.getElementById(unit.passbackId);
        if (passbackContainer) {
          var scrpt = window.top.document.createElement('script');
          scrpt.type = 'text/javascript';
          scrpt.src = 'https://cdnjs.cloudflare.com/ajax/libs/postscribe/2.0.6/postscribe.min.js';
          scrpt.onload = function () {
            passbackContainer.style.display = 'inline';
            window.top.postscribe(passbackContainer, passbackCode, {
              done: function() { console.log('vrl: passback script has been added'); }
            });
          };
          passbackContainer.parentNode.insertBefore(scrpt, passbackContainer);
        }
      }
   }

Things to keep in mind when you are inserting your script within the passbackCode variable.

  • The whole script needs to be 1 line.
  • All ending script tags need to be escaped (i.e. turns into <\/script>)
  • All quotes inside need to be single quotes (no double quotes "")

Once you are done modifying the tag, make sure you test it throughly using dev tools and ensure that the passback is executing and there are no unexpected errors.