# Cross-promo embed for static sites

The `<parchar-promo>` element renders weighted cross-promotion slots for the
Parchar network on any static site. The bundle is self-contained (5 KB
gzipped), requires no build step, and makes no network requests other than
Google Analytics measurement.

## Snippet

Pick the pinned version from the size manifest (`embed/iife.js.size.json`)
and paste one placeholder per slot plus the loader once per page, right
before `</body>`:

```html
<!-- soypolkadot.com: homepage band -->
<parchar-promo host="soypolkadot-com" slot-id="home-band" format="band" locale="es">
  <!-- Static fallback (no-JS / blocked script): keep exactly one link -->
  <a href="https://becas.parchar.ai/?utm_source=soypolkadot-com&amp;utm_medium=cross-promo&amp;utm_campaign=parchar-network">
    Becas verificadas, sin rumores — Explorar becas
  </a>
</parchar-promo>

<!-- soypolkadot.com: end of guide -->
<parchar-promo host="soypolkadot-com" slot-id="end-of-guide" format="card" locale="es">
  <a href="https://parchar.ai/?utm_source=soypolkadot-com&amp;utm_medium=cross-promo&amp;utm_campaign=parchar-network">
    Eventos culturales verificados — Ver planes
  </a>
</parchar-promo>

<script
  src="https://cdn.jsdelivr.net/npm/@parchar/cross-promo@<VERSION>/embed/iife.js"
  data-cp-ga-id="G-XXXXXXXXXX"
  integrity="sha384-<HASH-FROM-size.json>"
  crossorigin="anonymous"
  defer
></script>
```

For artmax.club use `host="artmax-club"` and the slots `home-band` (format
`band`) and `end-of-page` (format `card`), with `locale="en"` if the page is
in English.

## Attributes

| Attribute | Purpose |
|---|---|
| `host` | Host site id from `packages/cross-promo/src/config/network.json` — drives self-exclusion and `location_id` in analytics. |
| `slot-id` | Placement id declared for that host in the network config (becomes `creative_slot`). |
| `format` | `band`, `card`, or `strip`. |
| `locale` | Creative language: `es` or `en` (falls back to `es`). |

## Loader attributes

| Attribute | Purpose |
|---|---|
| `data-cp-ga-id` | Network GA4 measurement id. Omit to render promos without measurement. |
| `data-cp-consent` | `gate` to defer to the host's consent state via `window.__parcharCpConsent()` (return `'granted'`, `'denied'`, `true`, or `false`). Omit for permissive first-party behavior. |

soypolkadot.com (cookie banner with opt-in analytics) should use
`data-cp-consent="gate"` and expose:

```html
<script>
  window.__parcharCpConsent = function () {
    // Return the host cookie-preference state for analytics.
    return document.cookie.includes('analytics=granted') ? 'granted' : 'denied';
  };
</script>
```

When consent is denied (or unreadable) promos still render and rotate but
send no GA requests.

## Theming

Slots adapt to the host's design tokens through CSS custom properties; set
them on the element or any ancestor:

```css
parchar-promo {
  --cp-bg: rgba(127, 127, 127, 0.06);
  --cp-border: rgba(127, 127, 127, 0.22);
  --cp-fg: #16161d;
  --cp-muted: #5b5b66;
  --cp-radius: 14px;
  --cp-font: "Playfair Display", serif;
}
```

## Operations

- Weights, destinations, and creatives live in
  `packages/cross-promo/src/config/network.json`; re-run
  `pnpm --filter @parchar/cross-promo build:embed`, publish a new package
  version, and bump the pinned URL + integrity hash on each host.
- The build fails if the bundle exceeds 20 KB gzipped.
- `embed/iife.js.size.json` records byte size, gzipped size, and the SRI
  hash for the current build.
