Skip to content

Commit ea0fb57

Browse files
authored
Core: adding ima params to local cache request (prebid#14312)
* Core: adding ima params to local cache request * retrieving ima params * usp data handler
1 parent b1836ae commit ea0fb57

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

integrationExamples/audio/audioGam.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@
115115

116116
const bid = bidResponse.bids[0];
117117

118+
const adUnit = adUnits.find(au => au.code === 'div-gpt-ad-51545-0');
119+
118120
const adXml = await pbjs.adServers.gam.getVastXml({
119121
bid,
120-
adUnit: 'div-gpt-ad-51545-0',
122+
adUnit,
121123
params: {
122124
iu: '/41758329/localcache',
123125
url: "https://pubads.g.doubleclick.net/gampad/ads?iu=/41758329/localcache&sz=640x480&gdfp_req=1&output=vast&env=vp",

integrationExamples/gpt/localCacheGam.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
mediaTypes: {
1414
video: {
1515
playerSize: [640, 360],
16+
playbackmethod: [2, 6],
17+
api: [2, 7, 8],
1618
}
1719
},
1820
video: {
@@ -95,9 +97,11 @@
9597

9698
const bid = bidResponse.bids[0];
9799

100+
const adUnit = adUnits.find(au => au.code === 'div-gpt-ad-51545-0');
101+
98102
const vastXml = await pbjs.adServers.gam.getVastXml({
99103
bid,
100-
adUnit: 'div-gpt-ad-51545-0',
104+
adUnit,
101105
params: {
102106
iu: '/41758329/localcache',
103107
url: "https://pubads.g.doubleclick.net/gampad/ads?iu=/41758329/localcache&sz=640x480&gdfp_req=1&output=vast&env=vp",

modules/gamAdServerVideo.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { fetch } from '../src/ajax.js';
2828
import XMLUtil from '../libraries/xmlUtils/xmlUtils.js';
2929

3030
import {getGlobalVarName} from '../src/buildOptions.js';
31+
import { uspDataHandler } from '../src/consentHandler.js';
3132
/**
3233
* @typedef {Object} DfpVideoParams
3334
*
@@ -292,7 +293,28 @@ async function getVastForLocallyCachedBids(gamVastWrapper, localCacheMap) {
292293
};
293294

294295
export async function getVastXml(options, localCacheMap = vastLocalCache) {
295-
const vastUrl = buildGamVideoUrl(options);
296+
let vastUrl = buildGamVideoUrl(options);
297+
298+
const adUnit = options.adUnit;
299+
const video = adUnit?.mediaTypes?.video;
300+
const sdkApis = (video?.api || []).join(',');
301+
const usPrivacy = uspDataHandler.getConsentData?.();
302+
// Adding parameters required by ima
303+
if (config.getConfig('cache.useLocal') && window.google?.ima) {
304+
vastUrl = new URL(vastUrl);
305+
const imaSdkVersion = `h.${window.google.ima.VERSION}`;
306+
vastUrl.searchParams.set('omid_p', `Google1/${imaSdkVersion}`);
307+
vastUrl.searchParams.set('sdkv', imaSdkVersion);
308+
if (sdkApis) {
309+
vastUrl.searchParams.set('sdk_apis', sdkApis);
310+
}
311+
if (usPrivacy) {
312+
vastUrl.searchParams.set('us_privacy', usPrivacy);
313+
}
314+
315+
vastUrl = vastUrl.toString();
316+
}
317+
296318
const response = await fetch(vastUrl);
297319
if (!response.ok) {
298320
throw new Error('Unable to fetch GAM VAST wrapper');

0 commit comments

Comments
 (0)