# Cross-Game Products/Data

### Setting up game parenting

<figure><img src="/files/G84XSrE9SM2ZpbheUhsy" alt=""><figcaption></figcaption></figure>

When you set the parent game ID for a game it will pull all of its API data from the parent game allowing you to share data across your games.

#### 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:

```csl
// 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);
}
```

### 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.allout.game/data-and-persistence/cross-game-products-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
