Embed a game
Integrate a game in your site using an iframe
Through our gamification solution it's possible to create games and integrate them into your website using an iframe. The process involves creating and selecting a campaign from the Games Hub, and then appending a token to the URL of the campaign.
Prerequisites
Follow our guide on how to create a game campaign.
Append token
Once you have finished creating your game, the base URL for that campaign will be visible at the top of the page.
The URL uses the following format: https://game-type.games.xtremepush.com/play/project_id/campaign-name?token=34523453
.
The URL displayed on the platform contains a placeholder value for the token parameter. This placeholder should be dynamically appended when iframing the game on your website.
Two options can be considered for the token parameter:
- Use the User ID: The simplest approach is to append the user ID as the token value in the iframe URL. For example:
https://game-type.games.xtremepush.com/play/1/campaign-test-1?token=34523453
- JWT Authentication: For this option, navigate to the Configuration section from the game menu. You can either provide a desired UTF8 secret into the JWT Auth Secret field or click on the generate icon to generate a secret key. After that, save your settings. This secret key will be used to sign the signature of the JWT token using HS256.
The token should be signed with the JWT Auth Secret key and passed as the token param in the iframe.
The expected token format is shown below:
{
"account": "34523453",
"expiration": "2024-12-18T15:31:00.983Z"
}
account
: expects the user ID value of the logged-in user for whom you are launching the game. (required, string)expiration
: date in ISO 8601 format; defines the validity of the token. (optional)
Updated 3 months ago