Widget Callback

The Gleam widget sends callbacks which you can listen for on your page using the following Javascript.

This is useful for:

  • Firing tracking or conversion scripts on your page
  • Adding a Coupon to the users cart
  • Updating content on the page
  • Unlocking something on the page based on which Action the user completes

The Callback will provide the specific ActionID of the action that has been completed:

(function () {
  var callback = function (actionId) {
    alert('Action ' + actionId + ' performed');

  var eventHandler = function (e) {
    if(e.origin === 'https://gleam.io' && e.data && e.data.match(/GleamEntry/)) {
      callback.call(window, parseInt(e.data.match(/\d+/)[0]))

  window.addEventListener('message', eventHandler, false);