|
65 | 65 | */ |
66 | 66 | setOptions = function (options) { |
67 | 67 |
|
68 | | - // Get URL Targeting |
69 | | - var URLTargets = getURLTargets(); |
70 | | - |
71 | 68 | // Set default options |
72 | 69 | dfpOptions = { |
73 | | - setTargeting: { |
74 | | - inURL: URLTargets.inURL, |
75 | | - URLIs: URLTargets.URLIs, |
76 | | - Query: URLTargets.Query, |
77 | | - Domain: window.location.host |
78 | | - }, |
| 70 | + setTargeting: {}, |
79 | 71 | setCategoryExclusion: '', |
80 | 72 | enableSingleRequest: true, |
81 | 73 | collapseEmptyDivs: 'original', |
82 | | - targetPlatform: 'web', |
83 | | - enableSyncRendering: false, |
84 | | - refreshExisting: true |
| 74 | + refreshExisting: true, |
| 75 | + disablePublisherConsole: false, |
| 76 | + disableInitialLoad: false, |
| 77 | + noFetch: false, |
85 | 78 | }; |
86 | 79 |
|
| 80 | + if (typeof (options.setUrlTargeting) == 'undefined' || options.setUrlTargeting) |
| 81 | + { |
| 82 | + // Get URL Targeting |
| 83 | + var urlTargeting = getUrlTargeting(); |
| 84 | + $.extend(true, dfpOptions.setTargeting, { inURL: urlTargeting.inURL, URLIs: urlTargeting.URLIs, Query: urlTargeting.Query, Domain: window.location.host }); |
| 85 | + } |
| 86 | + |
87 | 87 | // Merge options objects |
88 | 88 | $.extend(true, dfpOptions, options); |
89 | 89 |
|
|
93 | 93 | $.extend(true, window.googletag, dfpOptions.googletag); |
94 | 94 | }); |
95 | 95 | } |
96 | | - |
97 | 96 | }, |
98 | 97 |
|
99 | 98 | /** |
|
228 | 227 | if (dfpOptions.collapseEmptyDivs === true || dfpOptions.collapseEmptyDivs === 'original') { |
229 | 228 | window.googletag.pubads().collapseEmptyDivs(); |
230 | 229 | } |
| 230 | + |
| 231 | + if (dfpOptions.disablePublisherConsole === true) { |
| 232 | + window.googletag.pubads().disablePublisherConsole(); |
| 233 | + } |
| 234 | + |
| 235 | + if (dfpOptions.disableInitialLoad === true) { |
| 236 | + window.googletag.pubads().disableInitialLoad(); |
| 237 | + } |
| 238 | + |
| 239 | + if (dfpOptions.noFetch === true) { |
| 240 | + window.googletag.pubads().noFetch(); |
| 241 | + } |
| 242 | + |
231 | 243 | window.googletag.enableServices(); |
232 | 244 |
|
233 | 245 | }); |
|
263 | 275 | * Create an array of paths so that we can target DFP ads to Page URI's |
264 | 276 | * @return Array an array of URL parts that can be targeted. |
265 | 277 | */ |
266 | | - getURLTargets = function () { |
| 278 | + getUrlTargeting = function () { |
267 | 279 |
|
268 | 280 | // Get the paths for targeting against |
269 | 281 | var paths = window.location.pathname.replace(/\/$/, ''), |
|
417 | 429 | // SetTimeout is a bit dirty but the script does not execute in the correct order without it |
418 | 430 | setTimeout(function () { |
419 | 431 |
|
| 432 | + var _defineSlot = function(name, dimensions, id, oop) { |
| 433 | + window.googletag.ads.push(id); |
| 434 | + window.googletag.ads[id] = { |
| 435 | + renderEnded: function() { }, |
| 436 | + addService: function() { return this; } |
| 437 | + }; |
| 438 | + return window.googletag.ads[id]; |
| 439 | + }; |
| 440 | + |
420 | 441 | // overwrite the dfp object - replacing the command array with a function and defining missing functions |
421 | 442 | window.googletag = { |
422 | 443 | cmd: { |
|
426 | 447 | }, |
427 | 448 | ads: [], |
428 | 449 | pubads: function () { return this; }, |
| 450 | + noFetch:function () { return this; }, |
| 451 | + disableInitialLoad: function () { return this; }, |
| 452 | + disablePublisherConsole: function () { return this; }, |
429 | 453 | enableSingleRequest: function () { return this; }, |
430 | 454 | setTargeting: function () { return this; }, |
431 | 455 | collapseEmptyDivs: function () { return this; }, |
432 | 456 | enableServices: function () { return this; }, |
433 | | - defineSlot: function (name, dimensions, id) { |
434 | | - window.googletag.ads.push(id); |
435 | | - window.googletag.ads[id] = { |
436 | | - renderEnded: function () {}, |
437 | | - addService: function () { return this; } |
438 | | - }; |
439 | | - return window.googletag.ads[id]; |
| 457 | + defineSlot: function(name, dimensions, id) { |
| 458 | + return _defineSlot(name, dimensions, id, false); |
440 | 459 | }, |
441 | 460 | defineOutOfPageSlot: function (name, id) { |
442 | | - window.googletag.ads.push(id); |
443 | | - window.googletag.ads[id] = { |
444 | | - renderEnded: function () {}, |
445 | | - addService: function () { return this; } |
446 | | - }; |
447 | | - return window.googletag.ads[id]; |
| 461 | + return _defineSlot(name, [], id, true); |
448 | 462 | }, |
449 | 463 | display: function (id) { |
450 | 464 | window.googletag.ads[id].renderEnded.call(dfpScript); |
|
0 commit comments