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

Taboola Bid Adapter: implement Iframe user sync #10789

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 8 additions & 0 deletions modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const GVLID = 42;
const CURRENCY = 'USD';
export const END_POINT_URL = 'https://display.bidder.taboola.com/OpenRTB/TaboolaHB/auction';
export const USER_SYNC_IMG_URL = 'https://trc.taboola.com/sg/prebidJS/1/cm';
export const USER_SYNC_IFRAME_URL = 'https://cdn.taboola.com/scripts/prebid_iframe_sync.html';
const USER_ID = 'user-id';
const STORAGE_KEY = `taboola global:${USER_ID}`;
const COOKIE_KEY = 'trc_cookie_storage';
Expand Down Expand Up @@ -182,6 +183,13 @@ export const spec = {
queryParams.push('gpp=' + encodeURIComponent(gppConsent));
}

if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
url: USER_SYNC_IFRAME_URL + (queryParams.length ? '?' + queryParams.join('&') : '')
});
}

if (syncOptions.pixelEnabled) {
syncs.push({
type: 'image',
Expand Down
17 changes: 14 additions & 3 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,17 +771,28 @@ describe('Taboola Adapter', function () {

describe('getUserSyncs', function () {
const usersyncUrl = 'https://trc.taboola.com/sg/prebidJS/1/cm';
const iframeUrl = 'https://cdn.taboola.com/scripts/prebid_iframe_sync.html';

it('should not return user sync if pixelEnabled is false', function () {
const res = spec.getUserSyncs({pixelEnabled: false});
it('should not return user sync if pixelEnabled is false and iframe disabled', function () {
const res = spec.getUserSyncs({pixelEnabled: false, iframeEnabled: false});
expect(res).to.be.an('array').that.is.empty;
});

it('should return user sync if pixelEnabled is true', function () {
const res = spec.getUserSyncs({pixelEnabled: true});
const res = spec.getUserSyncs({pixelEnabled: true, iframeEnabled: false});
expect(res).to.deep.equal([{type: 'image', url: usersyncUrl}]);
});

it('should return user sync if iframeEnabled is true', function () {
const res = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false});
expect(res).to.deep.equal([{type: 'iframe', url: iframeUrl}]);
});

it('should return both user syncs if iframeEnabled is true and pixelEnabled is true', function () {
const res = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true});
expect(res).to.deep.equal([{type: 'iframe', url: iframeUrl}, {type: 'image', url: usersyncUrl}]);
});

it('should pass consent tokens values', function() {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'GDPR_CONSENT'}, 'USP_CONSENT')).to.deep.equal([{
type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=GDPR_CONSENT&us_privacy=USP_CONSENT`
Expand Down