getKeywords
Retrieve keywords used for ad targeting. Optional options argument selects which sources to include.
Syntax
Section titled “Syntax”getKeywords(options?)Options
Section titled “Options”Every flag defaults to false except manual, semantiq, priority which default to true.
| Field | Type | Source |
|---|---|---|
manual | boolean | page-level keywords set via updateKeywords(fn) |
semantiq | boolean | Semantiq keywords (fetch is skipped when false) |
priority | boolean | priority keywords set via updateKeywords(fn, true) |
url | boolean | URL-derived keywords (adnz_domain, adnz_url, adnz_* from query) |
window | boolean | window.audienzz.keywords |
placement | { elementId } | placement-level keywords for one ad slot |
bid | { elementId } | Xandr/winning-bid keywords for one ad slot |
Returns Promise<Keywords> where Keywords = Record<string, string | string[] | undefined>.
Merge order
Section titled “Merge order”Last write wins: manual → semantiq → url → window → placement → bid → priority.
Examples
Section titled “Examples”// Default — backward compatible: manual + semantiq + priorityawait window.htag.api('1').getKeywords();
// Skip the Semantiq fetchawait window.htag.api('1').getKeywords({ semantiq: false });
// Include URL + window sourcesawait window.htag.api('1').getKeywords({ url: true, window: true });
// Scope to a slotawait window.htag.api('1').getKeywords({ placement: { elementId: 'div-1' }, bid: { elementId: 'div-1' },});- Semantiq result is cached per URL; repeated calls reuse the cache until the URL changes.
bidreads from Prebid — beforestart()finishes, the bid source resolves to{}instead of throwing.placement/bidreturn{}for unknownelementId.
Related Methods
Section titled “Related Methods”- updateKeywords: Set static or priority keywords
- refreshAds: Refresh ads with updated keywords