How to start the Game with Arguments

Similar to deep links on mobile, you can start games on web with Pley Game Arguments.

Pley Game Arguments (PGA) allows you to start the game with some paramater, which the game can fetch using a Pley SDK C# method (GetGameArguments();). This allows you to create links which leads to specific states in the game, use it to link accounts across platforms, or send players a "reward link" giving them an item on startup.

❗The GetGameArguments method will provide any data from the URL query parameter which starts with pga_ , or any utm_ parameters.

  1. Start the game with a URL query parameter website.com/game?pga_metadata=XXXYYYZZZ.
  2. Once the game starts, call GetGameArguments(); through the Pley Unity SDK.
  3. Recieve a PleyResult GetGameArguments(out GameArgument[] gameArguments) in return with the data.

Having the argument data clientside allows you handle the case in the C# game code.

API Reference: GetGameArguments(); documentation

URL examples

website.com/game?pga_metadata=XXXYYYZZZ&utm_campaign=FB&utm_source=web

KeyValue
metadataXXXYYYZZZ
utm_campaignFB
utm_sourceweb

Code Example

You have your game on webgame.com, on a game subpage.
Then, you send this link to players: webgame.com/game?pga_reward=abc123.

In-game, you call GetGameArguments();

public class PleyArgsHandler : MonoBehaviour
{
    void Start()
    {
        if (SDK.GetGameArguments(out var parameters) == PleyResult.OK)
        {
            foreach (var arg in parameters)
            {

              Debug.Log($"Pley Game Argument: {arg}");
              //Here you can parse and handle the arguments. The array contains the value "abc123".
              
	      //For example granting a reward:
	      GrantReward(arg);
            }
        }
    }

    void GrantReward(string code)
    {
        Debug.Log($"Granting reward: {code}");
        // Add your reward logic here. The code will be "abc123".
    }
}

For Headless Destination Games using Web SDK 2

Create the playable with your channel's Distribution ID, as described in Web SDK setup. Game arguments and playable behavior are configured through the distribution channel and the SDK2 options supported by your integration; see Distribution Channels & the Smart Playable URL.

The earlier createPlayable(containerId, releaseTrackId, { gameArguments }) example belongs to the previous Web SDK. Do not reuse that call or add legacy pga_data, scope, or release track parameters to a Smart Playable URL. Confirm the supported argument options for your SDK2 integration with the Pley team.

The in-game GetGameArguments() API described above is separate from the host website's Web SDK integration.