Delay the mPulse beacon from firing for X seconds

Document created by DPM Admin Employee on Jul 14, 2017Last modified by Will Smithee on Nov 16, 2017
Version 6Show Document
  • View in full screen mode

In certain cases, you may want to delay the mPulse beacon from firing on the load event.  The code below will delay the firing of the beacon for 2.5 seconds (i.e. the 2500 seen in the code below).  This code is simply prepended inside the main beacon code function that you copy out of the mPulse UI.

 

Note: the only impact to the data is that this code will effectively delay real-time by 2.5 seconds.

<script>
(function() {
  // Ensure we have the BOOMR namespace to work with
  BOOMR = window.BOOMR || {};
  BOOMR.plugins = BOOMR.plugins || {};

  // holds the beacon until this is true
  var complete = false;

  // create a custom plugin to hold the beacon until we're ready
  BOOMR.plugins.MyCustomPlugin = {
    is_complete: function() {
      return complete;
    }
  };

  function delayBeacon() {
    setTimeout(function() {
      complete = true;

      //trigger the beacon
      if (typeof BOOMR.sendBeacon === "function") {
        BOOMR.sendBeacon();
      }
    }, 2500);
  }

  if (window.addEventListener) {
    window.addEventListener("load", delayBeacon, false);
  } else if (window.attachEvent) {
    window.attachEvent("onload", delayBeacon);
  }

  //#########################################################
  // standard Boomerang loader script function code goes here
  //#########################################################

})();
</script>

Attachments

    Outcomes