Documentation Index
Fetch the complete documentation index at: https://docs.trygravity.ai/llms.txt
Use this file to discover all available pages before exploring further.
The pre-built React component
GravityAd takes the ad object from your server, renders it, fires the impression pixel on visibility (IntersectionObserver), and routes clicks through the tracked URL. You do not need to manage any of that yourself.
Variants — pick what fits your UI
The component ships 20+ visual treatments out of the box:| Variant | Shape |
|---|---|
card | Bordered card with favicon, title, body, CTA. Most common. |
inline | Compact inline chip. |
minimal | Single-line text with subtle CTA. |
bubble | Chat-bubble-styled. |
pill | Horizontal pill. |
banner | Horizontal banner, full-width. |
hyperlink | Underlined link only. |
text-link | Text with inline link. |
spotlight, accent, side-panel, labeled, embed, split-action, divider, toolbar, tooltip, notification, contextual, native, footnote, quote, suggestion | Additional styles — see playground. |
react-sandbox.trygravity.ai.
Style overrides
PassslotProps to override individual elements:
container, inner, header, favicon, brand, label, body, title, text, cta, plus variant-specific slots (iconWrapper, accentBar, secondaryCta, footer, arrow, contextHeader).
Props reference
| Prop | Type | Description |
|---|---|---|
ad | AdResponse | null | The ad from gravity.getAds(). |
variant | variant name | Visual treatment. |
className, style | CSS props | Applied to the outer wrapper. |
slotProps | object | Targeted style/className overrides (see above). |
showLabel | boolean | Show/hide the “Sponsored” label. Default true. |
labelText | string | Override the label text. Default "Sponsored". |
onClick | () => void | Fires on click. |
onImpression | () => void | Fires when impression pixel fires. |
onClickTracked | () => void | Fires after the click tracking URL hits. |
fallback | ReactNode | What to render when ad is null. Default nothing. |
disableImpressionTracking | boolean | Skip auto impression pixel — you fire it yourself. |
openInNewTab | boolean | Open landing page in new tab. Default true. |
Custom rendering
You don’t have to useGravityAd. The ad object is all you need:
- Use
ad.clickUrlas the href — neverad.urldirectly.clickUrlroutes through Gravity’s tracking and 302s to the landing page, ensuring the click is counted for billing and reporting. - Fire
ad.impUrlexactly once, when the ad first becomes visible. A single pixel request:new Image().src = ad.impUrl.
Multiple placements
ads array is ordered to match the placements array you sent on the request.
Variants for the engine to choose
When experiments are active, the engine assigns a variant per session. Let the engine’s choice win by default:ad.variant is undefined and your 'card' default applies.
Next
Experiments
How the engine optimizes your creative mix.
Pixel
Drop
gr-pix.js on your site — SDK auto-picks up the visitor ID for better attribution.