Open a webshop from your game
Understand how a game opens a webshop with an authenticated player session and how players are authenticated.
Read time 4 minutesLast updated 11 hours ago
A webshop runs outside the Unity game context. To identify the player in the webshop, your game opens the shop with an outbound link that includes an authenticated player session. This is the recommended way to open the shop; the player can complete a purchase without an extra sign-in step. Players can also open the shop directly from a browser, bookmark, marketing link, or shared link. If the shop doesn’t receive a player session, it shows an unauthenticated landing page instead of the product list. After a purchase, the shop can return the player to your game with a return deep link. The shop also uses this link to handle unauthenticated players automatically. For more information, refer to Handle inbound deep links. Webshops handle authentication from the session your game passes. You don’t need to build a separate sign-in flow. For more information, refer to Authenticate players and persist sessions.
Outbound links
The game opens the shop URL using the platform's standard external URL handling. On a mobile device, this typically opens the shop in the system browser or an in-app web view. The URL format is the following:To resolve this URL at runtime for the live published shop or for an environment's draft preview, refer to Integrate a webshop into a Unity game. The following query parameters identify the player and load the correct webshop context:https://shop.unity.com/{studio}/game/{slug}?sessionToken={token}&projectId={projectId}&environment={env}
Parameter | Purpose |
|---|---|
| A short-lived session token from the Unity Authentication SDK. The shop exchanges this token in the player's browser for an authenticated player session. |
| The Unity Cloud project ID the player belongs to. The shop uses this value to load the correct webshop and catalog. |
| The Unity Environment name to load. This parameter is optional and defaults to |
localecurrencyAfter the shop parses the authentication and store parameters, it removes them from the URL. This helps prevent screenshots or accidentally shared URLs from exposing the session token. If you omithttps://shop.unity.com/acme/game/dungeons?sessionToken=…&projectId=…&environment=production&locale=ja-JP¤cy=JPY
sessionTokenprojectIdAuthenticate players and persist sessions
Webshops authenticate player sessions through Unity Authentication. When the game opens the shop, it includes a short-lived Unity Authentication token in thesessionTokensessionTokenlocalStorage/_preview/...sessionStoragelocalStorageHandle the unauthenticated landing page
When a player opens the shop URL without authentication context and without a cached session inlocalStoragePost-purchase return to the game
After a purchase, the webshop can send the player back to your game with a return deep link. Configure it in the Deeplink URL field in the dashboard, for examplemygame://purchase-success
When the return link is enabled, the webshop appends the purchase outcome as query parameters:
The webshop appendsmygame://purchase-success?status=success&playerId={playerId}
status=successplayerIdThe game registers the custom URL scheme and reads the query parameters to resume the player where they left off. The Back to game button appears on the purchase result screen only when all of the following conditions are met:mygame://?status=success
- The player opened the shop from your game through a deep link.
- The player is on a mobile device, such as iOS or Android.
- The webshop has a return deep link configured.