Skip to content

Commit

Permalink
PubMatic to execute tracker pixel in iframe. (prebid#937)
Browse files Browse the repository at this point in the history
* PubMatic: passing pageurl in postbid

added support to pass pageURL to PubMatic adapter in postbid (Safeframe) implementation
please note that we have not added safe frame detection logic

* removed code committed accidently in master

* new function createTrackPixelIframeHtml in util

* minor fix in return statement of createTrackPixelIframeHtml

* PubMatic to execute impression tracker in iframe

will use utils.createTrackPixelIframeHtml instead of
utils.createTrackPixelHtml

* utils.createTrackPixelIframeHtml: using string template literals
  • Loading branch information
pm-harshad-mane authored and Will Alexander committed Mar 6, 2017
1 parent da5632d commit 14e89d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/adapters/pubmatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var PubmaticAdapter = function PubmaticAdapter() {
adResponse.adSlot = bid.adSlot;
adResponse.cpm = Number(adUnitInfo.bid);
adResponse.ad = unescape(adUnit.creative_tag); // jshint ignore:line
adResponse.ad += utils.createTrackPixelHtml(decodeURIComponent(adUnit.tracking_url));
adResponse.ad += utils.createTrackPixelIframeHtml(decodeURIComponent(adUnit.tracking_url));
adResponse.width = dimensions[0];
adResponse.height = dimensions[1];
adResponse.dealId = adUnitInfo.wdeal;
Expand Down
13 changes: 13 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,19 @@ exports.createTrackPixelHtml = function (url) {
return img;
};

/**
* Creates a snippet of Iframe HTML that retrieves the specified `url`
* @param {string} url plain URL to be requested
* @return {string} HTML snippet that contains the iframe src = set to `url`
*/
exports.createTrackPixelIframeHtml = function (url) {
if (!url) {
return '';
}

return `<iframe frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0p;width:0p;display:none;" scrolling="no" src="${encodeURI(url)}"></iframe>`;
};

/**
* Returns iframe document in a browser agnostic way
* @param {object} iframe reference
Expand Down

0 comments on commit 14e89d9

Please sign in to comment.