Loading MatchX game as part of your website

MatchX game can be shown as a separate page on your main website

You need to create an empty IFRAME element and set it specific to your design height and width styles.

As soon as the player is authorized you can make a JavaScript call

_smartico.miniGame(362, { 
    iframe:'match-x-game',
    zoom: 1,
    height: 'auto'
});.
  • The first argument is the ID of the MatchX game template (you can have multiple).

  • The second argument is a set of parameters:

    • iframe - id of the IFRAME element, where the game will be shown.

    • zoom - optionally gives a possibility to zoom in/out the UI of the game

    • height - can be set to 'auto' or to fixed height in pixels, e.g. '500px'. It's recommended to set the value to 'auto' for desktop users and to the fixed height on mobile devices. This approach will provide the best UX.

Example of the HTML/JavaScript code

<iframe id='match-x-game' style='width: 100%; height: 0px; display: none'>
</iframe>
<script>
    _smartico.miniGame(362, { iframe:'match-x-game', zoom: 1, height: 'auto'} );
</script>

Please note that if the 'width' of the div is 576px or less, the rendered UI will be adjusted for mobile devices.

Please note that at the time of the call to smartico.miniGame, the Smartico script should be already loaded. Otherwise, you will get an exception that _smartico is undefined.

If you don't have good control from the JavaScript when _smartico script is loaded, you can use the code below to trigger the game without exception.

<script>
var miniGameInterval = setInterval(function() {
    if (window._smartico && document.getElementById('match-x-game')) {
        _smartico.miniGame(362, { iframe:'match-x-game', zoom: 1, height: 'auto'} );
        clearInterval(miniGameInterval);
    }
}, 10)
</script>

You can see more examples of embedding MatchX and other gamification components on this demo page:

Custom theme to Match X in iframe

To apply a custom theme to Match X in an iframe, you should pass the theme as a parameter along with the theme name -> ‘theme-name’.

This parameter is optional if you want to use a custom Match X theme or one of our built-in themes (dark or light). Otherwise, Match X will use Smartico’s default colors.

Example:

_smartico.miniGame(362, { 
    iframe:'match-x-game',
    zoom: 1,
    height: 'auto',
    theme: 'theme-name'
});

Last updated