Embed on your site
Two lines of code put a game on any page: in an article, on a games page or inside your app. The game sizes itself to fit, loads only when readers scroll near it, and follows every update you publish.
Copy the code
Publish the game
See Publish and update. The code appears once the game is live.
Copy it
In the game's top bar, press Embed. Under Add to your site, press Copy code.
Paste it where the game should appear
Paste it into your page's HTML, at the spot where the game goes. Using a website builder? See Website builders.
The code looks like this, with your game's own id:
<div class="playgent" data-id="pg_7hk2qp0azx" style="min-height:640px"></div>
<script async src="https://play.playgent.com/embed/v1.js"></script>- The
divmarks where the game goes.data-idsays which game. Themin-heightholds the space while the game loads, so your page doesn't jump. - The
scriptloads the games. It must come fromplay.playgent.com, so don't copy it to your own server.
More than one game on a page
Add one div per game. One copy of the script is enough for all of them:
<div class="playgent" data-id="pg_7hk2qp0azx" style="min-height:640px"></div>
<p>More of your article…</p>
<div class="playgent" data-id="pg_3mf8wd2kqe" style="min-height:640px"></div>
<script async src="https://play.playgent.com/embed/v1.js"></script>Loading the script twice does no harm either.
How the game fits your page
- Width. The game fills the width of its spot, up to 560 px, and stays centered.
- Height. It grows to fit the game, from 200 to 4,000 px, so there is never a scrollbar inside the game. It sizes itself again when a phone turns or the width changes.
- Loading. The game loads when a reader scrolls within 600 px of it, so it doesn't slow down the top of your page.
- Scrolling. Scrolling over the game scrolls your page. A board that needs dragging only holds the touch while someone is playing.
- Back button. The game never adds to the browser's history, so Back stays your page's.
Build your code
Choose how the game opens, its size and more. The code updates as you go. Every option is described in the Embed reference.
<div class="playgent" data-id="pg_7hk2qp0azx" style="min-height:640px"></div>
<script async src="https://play.playgent.com/embed/v1.js"></script>Test it on your computer
Pages on localhost and 127.0.0.1 can always show your games, on any port, even when you have limited Your sites. Other local names, such as mysite.localhost or a network address, are treated like any other site.
Check that it works
Open your page. You should see the game's cover. If you see a message instead:
| Message in the game | Why | Fix |
|---|---|---|
| This game isn’t available on this site | Your workspace limits which sites may show games, and this one isn't listed. | Add the site in Your sites. |
| This game isn’t available right now | The game is not published, was taken offline, or is paused because the workspace has no plan. | Publish it, or pick a plan. |
| This game could not be loaded | The reader's connection dropped, or the data-id is mistyped. | Check the id against Studio's code. |
More fixes in Troubleshooting.