Skip to content

updateKeywords

The updateKeywords method allows you to update the static keywords used for ad targeting

updateKeywords(fn, priority?)
  • fn (function): A callback function that receives the current keywords and should return the updated keywords
  • priority (boolean, optional): When true, updates priority keywords that override regular and semantiq keywords. Defaults to false
window.htag.api('1').updateKeywords((currentKeywords) => ({
...currentKeywords,
// Add or modify new keywords
category: ['sports', 'football'],
premium: 'true',
articleId: '12345',
}));
window.htag.api('1').updateKeywords((currentKeywords) => ({
...currentKeywords,
// These keywords will override any conflicting regular or semantiq keywords
category: ['premium-sports'],
vip: 'true',
}), true);

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.