Event Handling

With YOM you can build custom web widgets that communicate directly with the stream via the postToYOM function:

postToYOM('AdjustSetting', {settingValue: 'newValue'});

This function facilitates sending commands or adjustments to the stream. Do ensure you register events inside of your game project, to bind the events to certain functions.

Example

We assume you have 3 buttons on your webpage (#spawnBot, #removeBot, #clearBot). On click we can trigger content within the stream using the postToYOM function:

document.addEventListener('DOMContentLoaded', function() {
    document.getElementById('spawnBot').addEventListener('click', function() {
        postToYOM('SpawnBot', {amount: '1'});
    });

    document.getElementById('removeBot').addEventListener('click', function() {
        postToYOM('RemoveBot', {amount: '1'});
    });

    document.getElementById('clearBot').addEventListener('click', function() {
        postToYOM('ClearBot', {});
    });
});

Listen for Events

Using YOM SDK you can push events from the game to the web browser. From there you can connect your own logic to it.

YOM SDK can automatically push events to the data layer for GTM and GA integration. Configure your GTM to capture these events for detailed interaction tracking.

Last updated