If you need to modify your loyalty widget using Javascript, you may need to use Stamped's listening event to run the code after the widget is loaded. Follow this guide to learn how to add the listening event code.
In This Guide
Adding The Listening Event Code
Add this JS function for listening to events fired by Stamped:
function addEventListenerStamped(el, eventName, handler) { if (el.addEventListener) { el.addEventListener(eventName, handler); } else { el.attachEvent('on' + eventName, function () { handler.call(el); }); } } // Listening for event addEventListenerStamped(document, '##replaceWithEventName##', function(e) { '##replaceWithFunction##' }); // Example // Listening for launcher loaded event addEventListenerStamped(document, 'stamped:launcher:loaded', function(e) { StampedFn.toggleRewardsModal(); });
Events
Event Name | Fired When |
stamped:launcher:loaded | The launcher loaded |
stamped:widget:rewards-earnings:loaded | Page Earnings widget loaded |
stamped:rewards:redeemed | A reward is redeemed in the launcher/widget |
stamped:launcher:opened | The launcher is opened |
JS Methods
Script | Function |
StampedFn.toggleRewardsModal(); | Open/close the Launcher |
StampedFn.loadLauncherView('view-referrals-email'); | Load the "Referrals" card view |
StampedFn.loadLauncherView('view-spendings'); | Load the "Spendings" card view |
StampedFn.loadLauncherView('view-earnings'); | Load the "Earnings" card view |
StampedFn.loadLauncherView('view-your-rewards'); | Load the "Your Rewards" card view |