Wix
Embed games in Wix pages using the HTML element, with or without Velo for richer event handling.
Wix supports two ways to add custom HTML: the HTML iframe element (works on any paid plan) and the Custom Code dashboard setting (also paid). Together they cover both quick embeds and site-wide SDK loading.
The HTML iframe element and Custom Code both require a Premium plan. They aren't available on the free Wix tier.
Wix's HTML element wraps your snippet in a sandboxed <iframe srcdoc>. The game renders correctly, but SDK lifecycle events (onComplete, onStart, etc.) won't reach code running on the outer Wix page. If you need to listen to events on the host page, use the Velo pattern at the bottom of this guide.
Embed on a page
In the Wix Editor, click Add Elements → Embed Code → Embed HTML (or "Custom Embed", depending on your editor version). Drop the element onto the page where you want the game. Click Enter Code and paste:
<div id="playgent-host"></div>
<script src="https://static.playgent.com/player/v2.js"></script>
<script>
Playgent.init({
containerId: "playgent-host",
player: "plyr_acme",
game: "sudoku",
mode: "daily",
});
</script>
Replace plyr_acme with your player ID. Resize the HTML element on the canvas to give the game enough room — Wix doesn't auto-fit to embedded content.
Dedicated games page
Create a new page in the Wix Editor (Pages → +). Drop in an HTML element with a multi-game switcher:
<div id="playgent-host"></div>
<div style="display:flex; gap:8px; margin-top:12px;">
<button onclick="player.load({ game: 'sudoku', mode: 'daily' })">Sudoku</button>
<button onclick="player.load({ game: 'wordsearch', mode: 'daily' })">Wordsearch</button>
<button onclick="player.load({ game: 'trivia', mode: 'daily' })">Trivia</button>
</div>
<script src="https://static.playgent.com/player/v2.js"></script>
<script>
const player = Playgent.init({
containerId: "playgent-host",
player: "plyr_acme",
game: "sudoku",
mode: "daily",
});
</script>
Velo: receive events on the Wix page
If you need onComplete (or any other event) to drive logic on your Wix page — e.g. unlock a coupon, navigate, log to Wix's database — turn on Dev Mode (Velo) in the editor.
In Velo, the recommended pattern is to host the Playgent embed in an HTML component and use window.postMessage to forward events. Inside the HTML element, expose a wrapper:
<div id="playgent-host"></div>
<script src="https://static.playgent.com/player/v2.js"></script>
<script>
Playgent.init({
containerId: "playgent-host",
player: "plyr_acme",
game: "sudoku",
mode: "daily",
onComplete: (data) => window.parent.postMessage({ source: "playgent", ...data }, "*"),
});
</script>
Then in your Velo page code:
import wixWindow from "wix-window";
$w.onReady(() => {
$w("#html1").onMessage((event) => {
if (event.data?.source !== "playgent") return;
const { score, won, timeMs } = event.data;
// your logic — unlock a coupon, save to a collection, navigate, etc.
});
});
$w("#html1") is the HTML element's Velo ID — check the property panel for the actual ID Wix assigned.
Wix gotchas
Sandboxed iframe by default
The HTML element loads your snippet inside an isolated iframe. The game works, but events don't escape the sandbox without the Velo bridge above.
Editor preview doesn't run scripts in the panel
The Editor's right panel preview of the HTML element shows a static placeholder. Click Preview (top-right) or the published URL to see the actual embed running.
Wix's mobile layout
Wix renders mobile versions of pages separately. If your game shows on desktop but not mobile, drop an HTML element into the mobile layout too — Wix doesn't always carry over Embed elements automatically.
Site-wide Custom Code
If you have many embeds, you can move the SDK script tag to Settings → Custom Code → Add Custom Code → Head in the Wix dashboard. After that, every HTML element only needs the <div> and the Playgent.init call.
Origin allowlist
Add your domains to the player in Hub → Configuration → Players:
- Your custom domain (
acme.com). - The Wix preview domain (
username.wixsite.com/...) — useful while you're testing before connecting a custom domain.
Because the HTML element runs inside Wix's own sandboxed iframe, the origin reported to the player is one of Wix's iframe origins (e.g. static.wixstatic.com or editor.wix.com). If embeds are rejected in preview but work on the published site, check the browser console for the exact origin and add it to the allowlist.