> For the complete documentation index, see [llms.txt](https://docs.allout.game/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.allout.game/data-and-persistence/cross-game-products-data.md).

# Cross-Game Products/Data

If you have multiple games that share the same data (e.g. a hub world and minigames) you can link them together automatically using the parent game system.

### Setting up game parenting

<figure><img src="https://3803321901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzA8RGUKJ88fD0oXVALlz%2Fuploads%2Fgit-blob-c30da1039399fb5cc98ac2364f5bb4344a4038a9%2Fimage.png?alt=media" alt="Parent Game ID field in game settings"><figcaption></figcaption></figure>

When you set the parent game ID, the child game uses the parent's data store for the shared systems below.

#### Types of data shared:

* Products & Player Purchases
* Player save data
* Game wide save data
* Leaderboards
* Generated assets

If you only want to share **some** data (for example if you have separate xp systems for each game) you can prefix your save keys with the current game ID in code.

Use `Game.get_game_id()` to fetch the ID at runtime:

```go
// little helper you can write to make this easier
get_scoped_key :: proc(local_key: string) -> string {
    return format_string("%:%", {Game.get_game_id(), local_key});
}

save_player_xp :: proc(player: Player, xp: s64) {
    Save.set_int(player, get_scoped_key("xp"), xp);
}

load_player_xp :: proc(player: Player) -> s64 {
    return Save.get_int(player, get_scoped_key("xp"), 0);
}
```

Use the same prefix for every read, write, migration, and portal edit of that key.

### Migrating Data Between games

{% hint style="warning" %}
If you did not set up game parenting initially and need to do so retroactively please contact us to migrate each game's data to the parent game first. This is a manual and potentially error prone process (if you have keys with the same name in each game already) so we highly suggest you consider this up front!
{% endhint %}
