Skip to main content

Ad Slot Settings

1. Ad slot settings

When define an ad slot by using gladsdk.defineAdSlot(), the settings for the ad slot can be passed on.

2. Ad slot settings property

adUnitId (required)

Ad unit ID issued for the media when requesting advertisements.

adSlotElementId

Ad container element ID (HTML Element)

Used to identify the ad container and must be defined as a unique identification value within the page.

contentInfo

Content information for content targeting.

{
"sourceType": "0001",
"sourceSubType": "menu",
"sourceId": "30907206:7"
}

2-1. Custom parameter

  • When define an ad slot by using gladsdk.defineAdSlot(), custom parameters can be used to target ads more granularly.

    window.gladsdk.cmd.push(function () {
    var adSlot = window.gladsdk.defineAdSlot({
    adUnitId: 'adUnitId',
    customParam: {
    category: 'entertainment',
    hobby: ['music', 'sports'],
    },
    });
    });
  • Use gladsdk.setCustomParam() to set custom parameters in an existing ad slot.

    window.gladsdk.cmd.push(function () {
    adSlot.setCustomParam('category', 'entertainment');
    });

2-2. Set custom parameters for all ad slots

  • Use gladsdk.setCustomParam() to apply custom parameters to all ad slots by setting global custom parameters.

    window.gladsdk.cmd.push(function () {
    gladsdk.setCustomParam('category', 'entertainment');
    var adSlot = window.gladsdk.defineAdSlot({
    adUnitId: 'adUnitId',
    });
    // apply 'category: entertainment'
    });
  • If both the global custom parameters and slot custom parameters are applied to the same key, the slot settings take priority.

    window.gladsdk.cmd.push(function () {
    gladsdk.setCustomParam('category', 'entertainment');
    var adSlot = window.gladsdk.defineAdSlot({
    adUnitId: 'adUnitId',
    customParam: {
    category: 'news',
    },
    });
    // apply 'category: news'
    });

3. Setting example

window.gladsdk.cmd.push(function () {
var adSlotInfo = {
adUnitId: 'adUnitId',
adSlotElementId: 'division',
customParam: {
category: 'entertainment',
hobby: ['music', 'sports'],
},
contentInfo: {
sourceType: '0001',
sourceSubType: 'menu',
sourceId: '30907206:7',
},
};

window.gladsdk.defineAdSlot(adSlotInfo);
});