◾Front-end integration
This setup should be done in order to enable popups, gamification, web-push, and tracking of the online status of players.
1. Installing the Smartico script
Smartico javascript library should be plugged on all front-end pages of your site(s)
Your label key is: provided by the account manager
Your brand key is: provided by your account manager
Please note: if you have a production and testing environment, then you should have separate keys for label and brand. Be sure that you never use production keys on testing environment and vice versa.
2. Identifying the user
On every page, when you have a user identified, you should set user_id and language of user in the global variables
_smartico_user_id - should be user id as it's known in your system. It should be the same ID of the user as will be used in server-to-server integration
_smartico_language - is ISO 639-1 code of user language (2 symbols code)
Whenever the user is logged out, set these variables to null or delete from the global scope, e.g.:
Note: you can use additional protection from faking the user_id, you can see more details here
3. Preparation for Web-push notifications
The following 3 files should be put in the root of the web/mobile sites. They are needed for the Web Push notifications
https://libs.smartico.ai/manifest.json
https://libs.smartico.ai/smartico-messaging-sw-v2.js
https://libs.smartico.ai/smartico-messaging-sw.js
e.g. if your site is somesite.com, then files should be located as
https://somesite.com/manifest.json
https://somesite.com/smartico-messaging-sw-v2.js
https://somesite.com/smartico-messaging-sw.js
4. Triggering gamification widget
When the gamification setup is ready and tested, you can put the entry point to open the gamification widget in the following way.
The main case when it’s needed from the Partner site is to provide an entry point to open Gamification UI. Example:
Please note: it should be available only for identified users
5. Validating setup
When you complete steps 1,2 and 3, you should be able to see the following messages in the console log of the browser
After executing _smartico.requestPushPermissions() command in the console, you should see
If there are any issues identified during setup, you will get explanations about nature of issue and needed actions
Last updated