Documentation

Getting Started
Gleam Updates
Capture
Competitions
Galleries
Rewards
Installation
Advanced
Integrations
Action Types
Guides

Widget Callback

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

This is useful for updating content on the page, or outside the widget based on what the user is doing inside the widget. 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]))
    }
  };

  if (window.attachEvent) {
    window.attachEvent('message',eventHandler);
  } else {
    window.addEventListener('message', eventHandler, false);
  }
})();

Connect With Us