Quick Start

Deploy an edge endpoint that serves monetization snippets for publisher pages.

What you need

  • Cloudflare account with Workers enabled
  • npm access (npx wrangler ...)
  • Publisher metadata: site_id, optional section, optional brand

Install in one line

printf '%s' "$HMAC_SECRET" | npx wrangler secret put HMAC_SECRET && npx wrangler deploy --name publisher-edge --compatibility-date 2026-03-16 --var AD_RESPONSE_URL:https://api.example.com --var API_KEY:key_live_xxx

Validate in one curl

curl "https://ads.yourmedia.com/serve?partner_id=pub_1&site_id=yourmedia_main&placement_id=home_top_native&section=sport&brand=yourmedia&page_url=https%3A%2F%2Fwww.yourmedia.com%2Fsport%2Farticle-123"

Expected result: HTML snippet content is returned for publisher placement rendering, or a controlled No ad response.

In production, always use a publisher-owned delivery domain (for example ads.yourmedia.com).

Publisher parameters

  • site_id (required): site identifier
  • section (optional): editorial context from CMS (example: sport)
  • brand (optional): brand/network context
  • placement_id (required): publisher slot identifier (example: home_top_native)
  • page_url (optional): full publisher page URL; request URL is used if omitted

Targeting mode (hybrid)

  1. Use explicit key-values first (site_id, section, brand) when provided.
  2. Fallback to URL-derived context from page_url when key-values are missing.

This model matches publisher integrations: CMS metadata when available, URL fallback when metadata is missing.