# Export Segments (GAM Key/Values) via Firestore

## Overview

In this destination service, DinMo will create a custom targeting Key and keep its Values up to date in Google Ad Manager through Firestore.

To do so, you will need to go through these three steps:

1. **Create a GAM via Firestore destination**.
   * You may need to create a new [Firestore destination](/integrations/destination-platforms/firestore.md) if this has not already been done.
   * Then refer to the [Google Ad Manager (GAM) connection guide](/integrations/destination-platforms/google-ad-manager.md) for detailed instructions on how to authenticate.
   * Finally, use the documentation below (Destination Setup) to complete the setup.
2. **Create a DinMo user segment** representing the audience you wish to export.
3. **Activate the segment** with the GAM via Firestore destination to begin synchronization.

Each time the activation runs:

* DinMo will find or create a custom targeting key named `dinmo_segments` in GAM under Inventory > Key-values tab
* DinMo will add the activated DinMo segment UUID as the targeting value Name in GAM (or a custom ID if defined in DinMo)
* DinMo will add the activated DinMo segment name as the targeting value Display Name in GAM (or a custom name if defined in DinMo)
* DinMo will update the Firestore collection specified by the user.
* Any profile entering your DinMo segment will have the Targeting Value Name (default to segment UUID) added to the `gam_segments` field within the corresponding Firestore document. This field is an array of segment UUIDs and will be automatically created by DinMo if it does not already exist.

## Destination setup

{% hint style="info" %}
Learn how to create such a destination in our [step-by-step tutorial](/guides/get-started-with-dinmo/initial-configuration-of-dinmo/create-a-destination.md)
{% endhint %}

To start exporting segments, you are first required to create a Google Ad Manager destination with the corresponding destination service.

You will need to create or choose an existing Firestore platform and collection. If you choose to create a new one, you will be prompted in a new tab and after creating it you can come back to this step and the Firestore platform will show up in the list.

### Activation configuration

{% hint style="info" %}
Learn how to activate a segment in our [step-by-step tutorial](/guides/get-started-with-dinmo/create-and-activate-segments-on-dinmo/activate-your-first-segment.md)
{% endhint %}

Once the destination has been set up, and your DinMo segment created, you can create an activation to start sending data to Google Ad Manager and Firestore right away.

### Activation core parameters

The `Targeting Value Name` is by default the DinMo segment UUID and can be modified. This value will be the segment name in Google Ad Manager and the value in the `gam_segments` array in each Firestore document belonging to a profile present in the DinMo segment.

The `Display Name` is the human-readable display name for this segment in Google Ad Manager. It can be modified as well and has the DinMo segment friendly name by default.

### Fields mapping

During activation, specify:

* **Document ID Mapping**: Choose the DinMo user profile field that corresponds to the Firestore document ID. DinMo uses this mapping to match profiles in Firestore.

### Scheduling

Specify the frequency of audience updates in Firestore. With each scheduled update:

* New profiles entering the DinMo segment will have the audience name added to their `gam_segments` array.
* Profiles leaving the DinMo segment will have the audience name removed from their `gam_segments` array.
* Updates ensure your audience data remains current, enabling accurate personalization.

### Adding to the Google Ad Manager tag

Once the data is available in Firestore, your technical teams need to configure your tag manager to retrieve the values of the `gam_segments` key from the Firestore document corresponding to the user, and inject it as values of the `dinmo_segments` key in your Google Ad Manager tag (Google Publisher Tag). See Google documentation here.


---

# 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.dinmo.io/integrations/destination-platforms/google-ad-manager/export-segments-via-firestore.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.
