PlaygentDocs

Publish and embedEmbed on your site

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

  1. Publish the game

    See Publish and update. The code appears once the game is live.

  2. Copy it

    In the game's top bar, press Embed. Under Add to your site, press Copy code.

  3. 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:

HTML
<div class="playgent" data-id="pg_7hk2qp0azx" style="min-height:640px"></div>
<script async src="https://play.playgent.com/embed/v1.js"></script>
  • The div marks where the game goes. data-id says which game. The min-height holds the space while the game loads, so your page doesn't jump.
  • The script loads the games. It must come from play.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:

HTML
<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.

Opens on
<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 gameWhyFix
This game isn’t available on this siteYour 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 nowThe 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 loadedThe reader's connection dropped, or the data-id is mistyped.Check the id against Studio's code.

More fixes in Troubleshooting.