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

# GAM Demand Mediation

> Turn Unsold Inventory into Revenue with fast setup

export const LastUpdated = ({date, lang = "en"}) => {
  const translations = {
    en: "Last updated:",
    es: "Última actualización:",
    pt: "Última atualização:",
    fr: "Dernière mise à jour:",
    de: "Zuletzt aktualisiert:"
  };
  const label = translations[lang] || translations.en;
  return <>
<style>{`
.last-updated-component {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 10px 16px;
border-radius: 8px;
margin-top: 12px;
margin-bottom: 16px;
font-size: 14px;
background-color: rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.12);
color: rgba(0, 0, 0, 0.75);
line-height: 1;
}

        .last-updated-component svg {
          flex-shrink: 0;
          vertical-align: middle;
        }

        .last-updated-component span {
          display: inline-flex !important;
          align-items: center !important;
          line-height: 1 !important;
        }

        [data-theme="dark"] .last-updated-component {
          background-color: #3a3a3a;
          border: 2px solid #888888;
          color: #ffffff;
        }

        [data-theme="dark"] .last-updated-component svg {
          stroke: #ffffff;
        }
      `}</style>
      <div className="last-updated-component">
        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
          <circle cx="12" cy="12" r="10" />
          <polyline points="12 6 12 12 16 14" />
        </svg>
        <span>
          <strong style={{
    fontWeight: 600
  }}>{label}</strong> 
          <time dateTime={date}>{date}</time>
        </span>
      </div>
    </>;
};

### What is GAM Demand Mediation?

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  Earn incremental revenue from banner impressions that would otherwise go
  unfilled - without changing your existing Topsort setup.
</div>

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  When Topsort has no demand for a banner slot, we automatically return a
  Google Ad Manager (GAM) ad instead. You simply render it.
</div>

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/topsort/images/knowledge-base/gam-fallback-flow.png" alt="GAM mediation flow diagram showing the auction returning a GAM tag when no Topsort demand exists" />
</Frame>

### Benefits

* **Monetize unsold inventory:** Marketplaces can earn revenue from banner ad slots even when there is no Topsort demand
* **Flexible demand sources:** Topsort can configure GAM placements to pull in demand from either open auction (non-endemic advertisers linking to other websites) or direct deals

### Who is it For?

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  Any Topsort marketplace worldwide with banner ad slots.
</div>

### Onboarding Process

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  If your marketplace is interested in GAM demand mediation, reach out to your
  Topsort account team.
</div>

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  A typical integration takes <strong>only a few hours of a marketplace
  engineer's time</strong> to set up and can be done live on a single call with
  a Topsort integration engineer. The process follows these steps:
</div>

<Steps>
  <Step title="Align on pilot scope">
    Select 2-3 banner ad slots and agree on content moderation policies.
  </Step>

  <Step title="Set up GAM MCM connection">
    Link Topsort and retailer accounts, and update <code>ads.txt</code> and{" "}
    <code>sellers.json</code>. Topsort uses GAM's Multiple Customer Management
    (MCM), which allows the Topsort GAM account to control other accounts (e.g.,
    retailer accounts).
  </Step>

  <Step title="Implement passback flow">
    Simply add a very small code snippet to each ad slot to render either a
    Topsort ad or a GAM ad.
  </Step>

  <Step title="Testing">
    Topsort will validate the integration.
  </Step>
</Steps>

### Example Response

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  When no Topsort demand is available for a banner slot enabled for GAM demand mediation,
  the{" "}
  <a href="/en/api-reference/auctions/create-auctions">auction endpoint</a>{" "}
  returns a GAM snippet in the winner's <code>asset</code> field. The retailer
  renders this snippet to display a GAM banner ad.
</div>

```json theme={null}
{
  "results": [
    {
      "resultType": "banners",
      "winners": [
        {
          "asset": [
            {
              "content": "{\"type\": \"gam_snippet\", \"content\": \"<div id=\\\"gam-ad\\\"><script>googletag.cmd.push(function() { googletag.display(\\\"div-gpt-ad-12345\\\"); });</script></div>\"}"
            }
          ],
          "type": "url",
          "id": "https://www.example.com",
          "resolvedBidId": "PHRSCwoQBpvFL1sveOSZBCyVii_LCRIQAAAAAAAAAAAAAAAAAAAAABoQAAAAAAAAAAAAAAAAAAAAACIbChdodHRwczovL3d3dy5leGFtcGxlLmNvbRAFUIDQzO7O7_H__wFyEAAAAAAAAAAAAAAAAAAAAAA",
          "rank": 1
        }
      ],
      "error": false
    }
  ]
}
```

<div style={{ textAlign: "justify", marginBottom: "1.5rem" }}>
  Each entry in the <code>asset</code> array contains a{" "}
  <code>content</code> field with a JSON string of type{" "}
  <code>gam\_snippet</code>. The retailer should parse this content and render
  the embedded HTML/JavaScript to display the GAM banner.
</div>

## Passback flow

<Note>
  The only development required by the marketplace is to add a small code
  snippet to each ad slot they want to enable for GAM demand, so the page
  renders a GAM tag if one is returned; otherwise, it renders the Topsort ad.
</Note>

```javascript theme={null}
// response is response from Topsort auction endpoint
const { results } = await response.json();
const passback = results?.[0]?.winners?.[0]?.metadata?.passbacktag;

if (passback) {
  const iframe = document.createElement("iframe");
  document.getElementById("banner-slot-3")?.appendChild(iframe);
  iframe.contentDocument.write(passback);
  iframe.contentDocument.close();
} else {
  // render normal Topsort ad
}
```

***

<LastUpdated date="2026-03-19" />
