Customize ad click event handler
Set up a click handler to customize click events for the ad slot.
- ex) When an advertisement is clicked, the media logs it
- ex) Change landing conditions (new window landing, current window landing)
clickHandler
may not operate in certain banner ad creatives. (If it is not set a value for href property of a
tag within an ad markup but it is implemented by a click event handler(handling for click through landing page) in a script code of ad creative.)
1. Set up a click handler
Set a click handler on an ad slot using adSlot.setClickHandler.
window.gladsdk.cmd.push(function () {
var adSlotInfo = {
adUnitId: 'WEB_nw_banner-N345765840',
adSlotElementId: 'division',
};
var adSlot = window.gladsdk.defineAdSlot(adSlotInfo);
adSlot.setClickHandler(function (curl, furl, extra) {
// execute on clicking ad
console.debug('curl', curl, 'furl', furl, 'ext', ext, 'type', ext.type);
});
});
-
When the click handler is executed, the default landing of the ad does not work.
The landing logic within the callback function being registered to Click Handler must be implemented.
2. Click handler function
The information passed to adSlot.setClickHandler is as below.
type Extra = {
type: string;
};
type clickHandlerCallback = (curl: string, furl: string | undefined, extra: Extra) => void;
-
curl
: click url -
furl
: fallback url -
extra
: parameter informationtype
: Click type."ad-click"
when clicking on the advertising area;"privacy-click"
when clicking on the privacy button