> For the complete documentation index, see [llms.txt](https://help.smartico.ai/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.smartico.ai/welcome/products/mini-games/mini-games-on-the-landing-pages.md).

# Mini-games on the landing pages

{% hint style="info" %}
The Visitor API and Mini-games for visitors require additional configuration to function correctly. Please see the guide below
{% endhint %}

Mini-games can work for anonymous users visiting your landing pages before completing registration.

You can display the Loyalty Wheel, Scratch & Catch, GiftBox, and most other games on your landing pages. After playing the game and completing registration, the user will receive a prize according to the prize pool definition.

Before you proceed with the setup of the mini-games, read the article about enabling [Visitor mode](/welcome/technical-guides/front-end-integration/visitor-mode.md) and placing the proper script on the landing pages

{% hint style="warning" %}
Important.

Smartico supports two modes to run mini-games for anonymous users.

1. The current page explains the setup of the game in your main "retention" label, with the possibility to issue prizes after the user completes registration
2. Another approach is to set up games under the Acquisition label, where prizes cannot be transferred after registration, but you can still use Popups and Push notifications for anonymous users.
   {% endhint %}

## Setting up the game template in Smartico BackOffice

You need to create a mini-game template for the Visitor mode and define the prize pool the same way as for the real users.

<div><figure><img src="/files/AhWS4IJEERM9aAbn2Bot" alt=""><figcaption></figcaption></figure> <figure><img src="/files/htz870OuaSFduk9ocAhz" alt=""><figcaption></figcaption></figure></div>

After creating a template, take the template ID and use it on the landing page as described below

**Display the game on the&#x20;**<mark style="color:red;">**landing page**</mark>**, add the following JavaScript to execute and show the game:**

```javascript
<script>
_smartico.showVisitorGame({ 
    template_id: 12345,
    onWin: function(prize) {
        window.location.href = 'https://my-casino.com/index.html?_smartico_visitor_win_uuid=' + prize.visitor_win_uuid;
    }
});
</script>
```

* Set `template_id` to the ID of the mini-game template set up in the Smartico BackOffice
* Define the `onWin` callback function and retain the value of `prize.visitor_win_uuid`, which should be passed to your main site after the user completes the registration

{% hint style="info" %}
You can choose how to preserve the value and pass it to the main site, such as using cookies, passing it as a URL parameter, or saving it during the registration flow and retrieving it later on the main site.
{% endhint %}

**Setting a position for the mini-game**

By default, the mini-game is opened in the center of the screen as a modal overlay.

You can optionally position the mini-game in a specific place on the page, rather than as a modal.

For this, you need to define an iframe with the required dimensions and position, and instruct the script to load the game within it.

```javascript

<iframe style="width:300px;height:300px" id="myframe"></iframe>

<script>
_smartico.showVisitorGame({ 
    template_id: 12345,
    frame_id: 'myframe'
});
</script
```

**Setting up Smartico scripts on the&#x20;**<mark style="color:red;">**main**</mark>**&#x20;site.**

When the user completes registration and is redirected to the main site, you need to transfer visitor\_win\_uuid to the main site.

**1st option** is just to pass it as a query parameter to the main site. .e.g

```javascript

 window.location.href = 
  'https://my-casino.com/index.html?_smartico_visitor_win_uuid='
  + prize.visitor_win_uuid;
                
```

**2nd option**, you are transferring the value in any way you prefer, but on the main site, you will need to set it in the global variable, like this.

```javascript
<script>
    window._smartico_visitor_win_uuid = '667018dc-b158-45b4-b52b-12f3a4a7175c';
</script>
```

**Extended possibilities on the&#x20;**<mark style="color:red;">**landing**</mark>**&#x20;page**

You can get more details about the won prize using the following code:

```javascript
<script>
_smartico.showVisitorGame({ 
    template_id: 12345,
    onWin: function(prize) {
        console.log('Prize ID', prize.id);
        console.log('Prize name', prize.name);
        console.log('Win UUID', prize.visitor_win_uuid);
    }
});
</script>
```

You can prevent the user from playing the game until they complete some steps in the registration process:

```javascript
<script>
var visitorEmail = undefined;

_smartico.showVisitorGame({ 
    template_id: 12345,
    onWin: function(prize) {
        console.log('Prize ID', prize.id);
        console.log('Prize name', prize.name);
        console.log('Win UUID', prize.visitor_win_uuid);
    },
    onBeforePlay: function() {
        if (!visitorEmail) {
            visitorEmail = prompt('Please enter your email', '');
            if (!visitorEmail) {
                return false;
            }
        }
        return true;
    },
})
</script>
```

The onBeforePlay callback should return true or false, indicating if a visitor is already allowed to play the game or still needs to pass some steps in the registration process.

**Show the game immediately when a visitor opens the landing page**

If you want to show the game immediately when the landing page opens, place the script in the correct order, as in the example.

```javascript
<script>
(function(d, r, b, h, s){h=d.getElementsByTagName('head')[0];s = d.createElement('script');s.onload=b;s.src=r;h.appendChild(s);})
(document, 'https://libs.smartico.ai/smartico.js', function() {
    _smartico.initVisitorMode('_label_key_', { brand_key: '_brand_key_', lang: 'DE' });
    _smartico.showVisitorGame({ 
        template_id: 12345,
        frame_id: 'myframe'
    });
});
</script>
```

## FAQ

**Q: Does the Visitor mode require additional configurations?**

A: Yes, the Visitor mode requires additional configurations that should be done by Customer Success Managers. If you have a multi-brand solution, this setup should be done for all brands associated with your landing pages. You should create and provide a test user ID - this test user should be used only for this.

**Q: Is there abuse protection for multiple wins in the game engine?**

A: Yes, the game's engine has abuse protection for multiple wins. Once a visitor plays a game on the landing page and receives a prize after registration, they won't receive additional prizes if they play the visitor game again.

**Q: Can the MatchX game run for the visitor?**

A: MatchX is not supported in visitor mode. It is still possible to provide it to non-registered users, but it will require creating separate labels and additional configuration. If you are interested, please contact your Customer Success Manager.

**Q: How are items deducted from the prize pool?**

A: The items in the prize pool are fixed and are not depleted when won by players.

**Q: How do we prevent visitors from playing the game multiple times?**

A: You can put a cookie or localStorage value in the user's browser in the onWin callback. Verify the value on the next visit, and don't show the mini-game if the value is set. Smartico doesn't have any logic to prevent the visitor from playing the game multiple times.

**Q: Can we give multiple attempts for the visitor to play?**

A: Smartico has no restrictions on how many times a specific visitor can play the game. If you want to apply limitations, do so using the operator's custom logic defined on the landing page.

**Q: What happens if existing users who registered a long time ago play in the visitor game and win the prize?**

A: There is a protection that will not issue prizes to the players who are playing "visitor' games after they registered.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.smartico.ai/welcome/products/mini-games/mini-games-on-the-landing-pages.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
