Skip to content

Commit 35f07be

Browse files
committed
chore: re-add docs
1 parent c5fa893 commit 35f07be

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎docs/carbon-ads.md‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Carbon Ads
2+
3+
The Website shows [Carbon Ads](https://www.carbonads.net/) through the OpenJS Foundation's Carbon Ads project for Node.js. Ads are rendered from Carbon's JSON API, directly in the visitor's browser, without any third-party script.
4+
5+
## Placements
6+
7+
| Format | Zone key | Where |
8+
| ------- | ---------- | ----------------------------------------------------------- |
9+
| Banner | `CWBI6KJY` | Full width, above page content, on the layouts listed below |
10+
| Sidebar | `CWBI6KJU` | Below the table of contents, from the `xl` breakpoint |
11+
12+
| Layout | Banner | Sidebar |
13+
| ------------------------ | ------ | ------------------------- |
14+
| `about`, `article` | Yes | From the `xl` breakpoint |
15+
| `blog-post` | Yes | From the `xl` breakpoint |
16+
| `blog-category` | Yes | No (no right-hand column) |
17+
| `download` | **No** | **No** |
18+
| `download-archive` | **No** | **No** |
19+
| `home`, error/404 pages | **No** | **No** |
20+
| `page` (fallback layout) | No | No |
21+
22+
The homepage never renders any ad markup, reserves no space and makes no ad requests. Layouts opt in explicitly through `<CarbonTopBar />` before their main content. The Sidebar is rendered inside `<MetaBar />` (`apps/site/components/MetaBar.tsx`), so every layout that uses it shows the Sidebar.
23+
24+
On narrower screens the Sidebar is neither shown nor requested (the Top Bar covers those views). Its breakpoint is hard-coded as `(min-width: 1280px)` in `apps/site/components/CarbonAds/Sidebar.tsx` and must match the layout grids. Resizing the window back above the breakpoint requests a new Sidebar ad, which records another impression.
25+
26+
Learn (`/learn`) and the API docs (`/api`, `/docs`) are separate applications and are not affected by this integration.
27+
28+
## How it works
29+
30+
- `apps/site/hooks/useCarbonAd.ts` requests the ad for the current page view and sends its view beacon. A page view changes with the pathname or locale (not with hashes or query strings), so a revisited page always gets a fresh ad.
31+
- `apps/site/components/CarbonAds/TopBar.tsx` and `apps/site/components/CarbonAds/Sidebar.tsx` render each format. No space is reserved while loading; when there is no ad (empty response, invalid data, network error or ad blocker) nothing is shown.
32+
- The ad request itself records the impression. The `statview` beacon is sent once per page view after at least 50% of the ad was visible for one continuous second. Clicks go through `statlink`.
33+
34+
## Staging and production
35+
36+
By default, every request is sent with `ignore=yes`, which returns a real ad **without counting the impression**. This applies to local development, tests and all preview deployments (which are production builds too).
37+
38+
Impressions are only counted when the build has:
39+
40+
```bash
41+
NEXT_PUBLIC_CARBON_ADS_PRODUCTION=true
42+
```
43+
44+
As with any `NEXT_PUBLIC_` variable, this value is embedded at build time, so it must be set in the environment of the **production deployment build only** (e.g. the Vercel "Production" environment, or the Cloudflare production build), never for previews. Changing it requires a new build. It is listed in `apps/site/turbo.json` so that it is part of the build cache key; without that, a cached preview build could be reused for production (or vice versa).
45+
46+
There is no Content Security Policy on the Website at the moment. If one is added, it must allow `srv.carbonads.net` (ad requests), `srv.buysellads.com` (view beacons) and the creative image host (e.g. `cdn4.buysellads.net`).
47+
48+
### Launch sequence
49+
50+
1. Deploy the integration to a staging/preview URL (impressions are not counted there).
51+
2. Send the staging URL to Carbon for review. They serve a test creative and check requests, view beacons and click links.
52+
3. Set `NEXT_PUBLIC_CARBON_ADS_PRODUCTION=true` for the production build and deploy.
53+
4. For the first seven days Carbon counts traffic but serves no ads: responses are empty and the slots render nothing.
54+
5. Paid ads then start appearing in the same slots, without code changes.
55+
56+
## Testing
57+
58+
There are no unit tests for the integration yet. When testing manually, avoid clicking real ads repeatedly; prefer intercepting `https://srv.carbonads.net/ads/*.json` with fixtures (e.g. in Playwright or the browser's developer tools).

0 commit comments

Comments
 (0)