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

Integrate option to pass clickThrough urls to renderAd method #5796

Merged
merged 5 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function emitAdRenderFail({ reason, message, bid, id }) {
* @param {string} id bid id to locate the ad
* @alias module:pbjs.renderAd
*/
$$PREBID_GLOBAL$$.renderAd = function (doc, id) {
$$PREBID_GLOBAL$$.renderAd = function (doc, id, options) {
utils.logInfo('Invoking $$PREBID_GLOBAL$$.renderAd', arguments);
utils.logMessage('Calling renderAd with adId :' + id);

Expand All @@ -354,6 +354,12 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
// replace macros according to openRTB with price paid = bid.cpm
bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm);
bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm);

// replacing clickthrough if submitted
const { clickThrough } = options;
renebaudisch marked this conversation as resolved.
Show resolved Hide resolved
bid.ad = utils.replaceClickThrough(bid.ad, clickThrough);
bid.adUrl = utils.replaceClickThrough(bid.adUrl, clickThrough);

// save winning bids
auctionManager.addWinningBid(bid);

Expand Down
5 changes: 5 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ export function replaceAuctionPrice(str, cpm) {
return str.replace(/\$\{AUCTION_PRICE\}/g, cpm);
}

export function replaceClickThrough(str, clicktag) {
if (!str) return;
return str.replace(/\$\{CLICKTHROUGH\}/g, clicktag);
renebaudisch marked this conversation as resolved.
Show resolved Hide resolved
}

export function timestamp() {
return new Date().getTime();
}
Expand Down