select_ad database function powers ad selection in Orbit Audience Engine. It runs entirely inside the database and returns no result unless the user is on an ad-supported plan and has allowed personalized or non-personalized advertising.
Eligibility filters
Before ranking,select_ad applies these filters in order:
- Plan and consent: user must be on an ad-supported plan with appropriate consent (personalized for segment targeting, non-personalized for contextual)
- Campaign approval and schedule: campaign and creatives must be approved, and the current date must fall within the campaign schedule
- Budget and balance: remaining daily and total budgets must be positive, and the organization balance must be sufficient
- Country, device, and placement: must match the campaign targeting rules
- Frequency caps: user must not have exceeded daily or weekly impression limits
- Segment qualification (for segment-targeted campaigns): user must have a qualifying non-sensitive interest score
Ranking
Eligible creatives rank by:Rendering
Impressions render usingSponsoredCard (or its placement variants). Every rendered ad must display the label “Sponsored”.
Charge timing
- CPM: charged at impression creation
- CPC: charged on an eligible unique click via the Advertising API
- CPA: charged on an eligible idempotent conversion via the Advertising API