Invites

Give your players a link to share, and your Analytics tab tells you how many people it brought and whether your game grows on its own.

What it is

One call. When a player chooses to invite somebody, ask the SDK for a link and share it however your game shares things. The link credits that player, and everyone who opens it and goes on to play is counted as a player they brought.

The result is the Invites report in your game's Analytics tab: invites sent, the new players they brought, and the viral coefficient.

1

Ask for a link when a player invites somebody

<script src="https://indie.fun/js/indie.js"></script>
<script>
  const indie = new Indie({ appId: 'your-app-id' });

  inviteButton.onclick = async () => {
    const link = await indie.invite();
    await navigator.clipboard.writeText(link);
    // or: navigator.share({ url: link }), or your own share dialog
  };
</script>

Each call is one invite sent, so call it when the player actually invites somebody rather than when your menu opens. The player gets the same link every time; it adds ?indie_invite=… to your game's address and keeps whatever else was there.

What the SDK does with it

  • The link is your game's address. A build indie.fun hosts is linked at indie.fun/play/your-game; a game on your own site is linked at the page it is running on.
  • Arrivals are picked up for you. Somebody opening a page with ?indie_invite= on it is reported as the SDK starts. There is nothing to call on the receiving side.
  • Signed-in or not. Invites are filed against the player's account when there is one and their device otherwise, the same identity sessions use.
  • A visitor who declined analytics is not tracked. invite() still returns a link, so sharing still works, but it carries no invite and nothing is counted. The same goes for an arrival: it is reported only once the visitor may be tracked.
  • It never throws. If the request fails, the link comes back without an invite rather than not at all.

What is counted

Invites sent
Calls to invite() in the window, and how many players made them.
Invited players
New players in the window who arrived on an invite link and went on to play. Somebody who opened the link and never played is not one, and neither is somebody who was already playing your game before they clicked: they were not brought by it.
New from invites
Invited players as a share of the window's new players: how much of your growth is word of mouth.
Viral coefficient
Invited players per player in the window, the K-factor. Above 1.00 every player brings in more than one more, and the game grows without anybody paying for it.

Who gets the credit

The first invite link somebody opens is the only one that brought them. Opening a second friend's link later changes nothing, and opening your own link is never counted.

A player who arrives as a guest and signs in later is still the same invited player.

2

Check it worked

  1. Press your invite button and copy the link.
  2. Open it in a private window, which is a different player as far as your game can tell, and play for a moment.
  3. Open your game on My Games, then Analytics, then Invites. It shows one invite sent and one invited player.

Reference

Browser

await invite()A link to your game crediting this player. Each call is one invite sent. Always resolves to a link.

HTTP

POST /api/player/inviteBody { deviceId? }, with X-App-Id and either the player's bearer token or a deviceId. Returns { code }, the player's own invite code.
POST /api/player/invite/acceptBody { code, deviceId? }, with X-App-Id and either the player's bearer token or a deviceId. Records that this player arrived on that code.