Skip to content

handlePriorityCreative

The handlePriorityCreative hook allows you to control the behavior when a priority creative is available. Priority creatives are special ads (typically from Xandr) that are guaranteed to win the auction. This hook lets you customize what happens when such creatives are encountered.

window.htag = window.htag || {};
window.htag.handlePriorityCreative = function (elementId, winnerAdId) {
// Log priority creative usage for analytics
console.log(`Priority creative displayed for element: ${elementId}`);
// Apply custom tracking for priority creatives
if (typeof gtag !== 'undefined') {
gtag('event', 'priority_creative_shown', {
element_id: elementId,
ad_id: winnerAdId || 'unknown',
});
}
// Return the winner ad ID to proceed with default behavior
return winnerAdId;
};
  • elementId (string): The ID of the placement element where the priority creative will be displayed
  • winnerAdId (string): The ID of the winning ad
  • string: The ad ID to use for rendering the priority creative
  • undefined: Skip rendering the priority creative