AdService Quick Integration

AdService Quick Integration Documentation

AdService Integration

Add the following script within the head section. The script must be async and the id value must not be changed.

<script async id="adservice_gpt_script" src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script async id="adservice_script" src="https://ad.medyanetads.com/adservice/adservice.js"></script>

AdService is initialized as shown below. This should be added below the inserted script.

var adservice = adservice || {
	targetings: [],
	adUnits: [],
	oopAdUnits: [],
	interactiveAdUnits: [],
	modules: []
};

Definition of Modules

AdService consists of 9 modules. The modules to be used by the publisher are defined in the modules section of adservice.

var adservice = adservice || {
	...
	modules: ['prebid', 'blueKai', 'adsByGoogle', 'neustar', 'veriSmart', 'pg', 'interstitial', 'scroll', 'pauseroll']
};

Modules with configuration settings are described below.

Definition of GPT Module Settings

Gpt settings are defined as shown below.

Parameter

Description

Type

justDestroySendedAdUnits

If this parameter is set to “true”, only the pushed adUnits will be destroyed on infinite pages.

boolean

var adservice = adservice || {
	...
	modules: ['gpt'],
	gptSettings: {
		justDestroySendedAdUnits: false
	}
};

Definition of Prebid Module Settings

Prebid settings are defined as shown below.

Parameter

Description

Type

bidders

The URL returning JSON is defined

string

var adservice = adservice || {
	...
	modules: ['prebid'],
	prebidSettings: {
		bidders: 'https://ad.medyanetads.com/adservice/prebid/xxx_com_tr.json'
	}
};

Definition of BlueKai Module Settings

BlueKai settings are defined as shown below.

Parameter

Description

Type

id

The publisher’s BlueKai ID is defined

integer

pageType

The type of the page is defined

string

var adservice = adservice || {
	...
	modules: ['blueKai'],
	blueKaiSettings: {
		id: 1453,
		pageType: 'istanbul'
	}
};

Definition of VeriSmart Module Settings

VeriSmart settings are defined as shown below.

Parameter

Description

Type

keywords

Defines the page’s keywords.

array

var adservice = adservice || {
	...
	modules: ['veriSmart'],
	veriSmartSettings: {
		keywords: ['istanbul']
	}
};

Definition of P&G Module Settings

P&G ayarları aşağıdaki gibi tanımlanır.

Parameter

Description

Type

bpId

The value provided by MedyaNet is passed.

string

var adservice = adservice || {
	...
	modules: ['pg'],
	pgSettings: {
		bpId: 'istanbul'
	}
};

Definition of Targeting

Targeting parameters must be added to adservice’s targetings section before the page loads.

adservice.targetings.push({ "kategori": "k123" });
adservice.targetings.push({ "contentid": "c123" });

Definition of Ad Units

Ad units must be added to adservice’s adUnits section before the page loads.

Parameter

Description

Type

path

The ad unit path defined in GAM.

string

size

Defines the sizes of ad units.

array

divId

Defines the div where the ad unit will render

string

sizeMappings

Defines the size mappings for ad units.

array

adservice.adUnits.push({
	path: '/166474567/Medyanet-Backfill-Inventory/Cnnturk',
	size: [[728, 90], [300, 250]],
	divId: 'div-gpt-ad-3683233-1',
	sizeMappings: [[[1000, 100], [[728, 90]]], [[200, 100], [[300, 250]]]]
});

Definition of OOP Ad Units

Out-of-page ad units must be added to adservice’s oopAdUnits section before the page loads.

Parameter

Description

Type

path

The ad unit path defined in GAM.

string

divId

Defines the div where the ad will render

string

adservice.oopAdUnits.push({
	path: '/166474567/Medyanet-Backfill-Inventory/Cnnturk',
	divId: 'div-gpt-ad-3683233-1',
});

Definition of Interactive Ad Units

Interactive ad units must be added to adservice’s interactiveAdUnits section before the page loads

Parameter

Description

Type

path

The ad unit path defined in GAM.

string

size

Defines the sizes of ad units.

array

divId

Defines the div where the ad will render

string

sizeMappings

Defines the size mappings for ad units.

array

type

Defines the ad format type: interstitial, scroll, pauseroll

string

playerId

If the ad format is pauseroll, this is defined. A unique ID must be assigned.

string

adservice.interactiveAdUnits.push({
	path: '/166474567/Medyanet-Backfill-Inventory/Cnnturk',
	size: [[800, 600], [320, 480]],
	divId: 'div-gpt-ad-3683233-1',
	sizeMappings: [[[1000, 100], [800, 600]],[[100, 100], [320, 480]]],
	type: 'interstitial'
});

In the pauseroll ad model, when the pause button is pressed, the following event must be triggered after the publisher’s related business logic runs.

The playerId value mentioned above must be sent in the event details.

document.addEventListener('adservice-pauseroll-paused', (e) => {
	//e.detail.playerId
});

Definition of Interactive Ad Units

Interactive ad units must be added to adservice’s interactiveAdUnits section before the page loads

document.addEventListener('adservice-gpt-slot', function(event) {
	//console.log(event);
});

The information to be sent in the event arguments is specified in the table below.

Parameter

Description

status

When an ad request is made, “adUnitRequested” is logged; when an ad response is received, “adUnitRenderEnded” is logged.

adUnitPath

The path of the ad unit requested or responded is logged.

adUnitDivId

The divId of the ad unit requested or responded is logged.

type

The type of the ad unit requested or responded is logged. Possible values: “interstitial” or “scroll”. If undefined, it is a non-interactive ad unit.

isEmpty

If the status is “adUnitRenderEnded”, this flag is included. False if an ad is present, true if empty.

width

If the status is “adUnitRenderEnded” and isEmpty is false, the ad width is logged. Example: 300.

height

If the status is “adUnitRenderEnded” and isEmpty is false, the ad height is logged. Example: 250.


Usage of Infinite

On infinite pages, first add targetings, adUnits, and oopAdUnits as described above. Then call the method below.

adservice.admanager.reInitAds();