Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubMatic to execute tracker pixel in iframe. #937

Merged
merged 10 commits into from
Feb 1, 2017
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