> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dema.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Product ID matching for ad spend

> How Dema matches product-level ad spend from product ads (Meta, Google, Pinterest, OpenAI, Zalando) to products in your catalog: the product ID matching setting, why spend goes to the UNKNOWN product, and when a change applies.

For product ads, ad platforms report spend per advertised product. Dema places each of these rows on a product in your catalog, so product reports can show **Marketing spend (Product ads)** for each product. Spend that Dema can't place goes to the product `UNKNOWN`.

> [card] [How spend is matched](#how-spend-is-matched)
>
> The order Dema tries

> [card] [Matching setting](#matching-setting)
>
> Match ad IDs to a catalog column

> [card] [When changes apply](#when-changes-apply)
>
> Recent and older ad spend

***

## How spend is matched

Dema tries these steps in order for each row of product ad spend, and uses the first that gives a product:

1. **The product ID the ad data already carries.** Meta and Zalando product ads carry one by default. For Google, Dema sets it per account. The ID is kept even if it isn't in your catalog.
2. **Your [matching setting](#matching-setting)**, if one is set.
3. **Built-in lookups:** the ad's variant number against your catalog's variant numbers, then its GTIN, then the variant number as a product ID.
4. **The product `UNKNOWN`.**

> [!WARNING]
>
> **A matching setting only affects rows without a product ID.** Meta and Zalando product ads carry one by default, so for these platforms the pre-filled product ID has to be turned off for the setting to apply to all rows. Ask your Customer Success Manager to change both together. Google product ads always carry the product ID Dema sets for your account, so the setting doesn't apply to them.

***

## Matching setting

Each storefront can have one matching setting per ad platform. It matches an ID from the ad data against a column in your product catalog:

| Part | Options |
| - | - |
| **ID from the ad data** | The platform's item ID (the usual choice), the variant number or the GTIN |
| **Catalog column** | SKU, GTIN, product ID, variant ID, custom attributes 1 to 20, or your e-commerce platform's product or variant IDs when your catalog uses other IDs |
| **Ignore case** | Off by default. Turn it on when the ad platform changes the case of your IDs. Pinterest, for example, sends item IDs in lowercase. |

Without a setting, Dema uses only steps 1, 3 and 4. To set up or change product ID matching, contact your Customer Success Manager.

> [accordion] An ID matches several products
>
> Choose a catalog column whose values are unique to one product. If an ID from the ad data matches several products:
>
> * **With case ignored, or on your e-commerce platform's IDs:** the setting skips that row, and the built-in lookups try it next.
> * **On any other column:** the spend goes to one of the matching products.

> [accordion] Field names
>
> Your Customer Success Manager may refer to the setting by its field names:
>
> | Option | Field name |
> | - | - |
> | Platform's item ID | `productItemId` |
> | Variant number | `datalayerVariantNo` |
> | GTIN (ad data) | `gtin` |
> | SKU | `sku` |
> | GTIN (catalog) | `gtin` |
> | Product ID | `merchant_product_id` |
> | Variant ID | `merchant_product_variant_id` |
> | Custom attributes | `custom_attribute_1` to `custom_attribute_20` |
> | E-commerce platform IDs | `external_product_ids`, `external_product_variant_ids` |
> | Ignore case | `caseInsensitive` |

***

## When changes apply

Each daily fetch of ad data replaces the recent days it covers, usually the last week. Spend in those days moves to the new matching on the next fetch. Older spend keeps the product it has, unless your Customer Success Manager fetches that period again.

***

## Need help?

> [card] Contact support
>
> Email us at [support@dema.ai](mailto:support@dema.ai) for further assistance

> [card] [Marketing integrations](https://docs.dema.ai/integrations/marketing/overview.md)
>
> Connect your ad platforms


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.