updateKeywords
Overview
Section titled “Overview”The updateKeywords method allows you to update the static keywords used for ad targeting
Syntax
Section titled “Syntax”updateKeywords(fn, priority?)Parameters
Section titled “Parameters”fn(function): A callback function that receives the current keywords and should return the updated keywordspriority(boolean, optional): Whentrue, updates priority keywords that override regular and semantiq keywords. Defaults tofalse
Examples
Section titled “Examples”Update regular keywords
Section titled “Update regular keywords”window.htag.api('1').updateKeywords((currentKeywords) => ({ ...currentKeywords, // Add or modify new keywords category: ['sports', 'football'], premium: 'true', articleId: '12345',}));Update priority keywords
Section titled “Update priority keywords”window.htag.api('1').updateKeywords((currentKeywords) => ({ ...currentKeywords, // These keywords will override any conflicting regular or semantiq keywords category: ['premium-sports'], vip: 'true',}), true);How It Works
Section titled “How It Works”The updateKeywords method takes a callback function that receives the current keywords and should return the updated keywords.
When priority is set to true, the keywords are stored as priority keywords, which take precedence over regular static keywords and semantiq-generated keywords during targeting. This is useful when you need to ensure certain keyword values are used regardless of other keyword sources.
Related Methods
Section titled “Related Methods”- getKeywords: Get the current keywords
- refreshAds: Refresh ads with the updated keywords
- Semantiq concept: Learn more about contextual keywords