Ads
AdSense Integration
Per-tenant AdSense provider switch and component behavior.
AdSense Integration
Tenants can use Google AdSense instead of GAM (AdX) for ad serving.
Entry: lib/utils/adProvider.js, components/ads/*
Provider switch
Set on tenant document:
adConfig: {
adProvider: "adsense", // or "adx" (default)
adsensePublisherId: "ca-pub-XXXXX",
adsenseChannelId: "optional-channel",
adsenseDefaultDisplaySlotId: "slot-id",
adsenseDefaultStickySlotId: "slot-id",
}Architecture
Script loading
| Provider | Script | Loaded in |
|---|---|---|
| AdX | gpt.js with cmpNetworkCode | app/layout.js |
| AdSense | adsbygoogle.js?client={publisherId} | app/layout.js |
PageLevelTargeting (GAM utm_source KV) runs only when adProvider === "adx".
Component mapping
| Placement | AdSense component | Config |
|---|---|---|
| Display | AdSenseDisplay | publisherId + adSlot |
| Interstitial | AdSenseInterstitial | publisherId only |
| Rewarded | AdSenseRewarded | publisherId only |
| Sticky | AdSenseSticky | publisherId + adSlot |
| Skyscraper | AdSenseSkyscrapper | publisherId + adSlot |
Key differences from AdX
| Feature | AdX | AdSense |
|---|---|---|
| KV waterfall | Yes | No |
| Interstitial timing | Theme-based | Wait for onLoad |
| Rewarded trigger | CTA / auto | showAd() on CTA |
| KV2 fallback | KV2 popup | Auto showAd() on mount |
| Conversion pixel | onAdReceived | onAdReceived via handleAdReceived(null) |
Gotchas
- Interstitial/rewarded must wait for AdBreak
onLoadbeforeshowAd() - KV2 starts only when theme passes
shouldStartKv2: trueinonClosepayload - Display/sticky wrappers use
key+ synchronoususeScreenSizeinit to prevent TagError on resize @unib0ts/ad-managerno-fill statuses remapped inlib/utils/adSenseAdBreak.js