Skip to content

Commit

Permalink
set lmpid only if exists (#111)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikola Milekic <[email protected]>
  • Loading branch information
MO-Thibault and Nikola-Milekic authored Apr 23, 2024
1 parent a6a75ad commit 5f78fff
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/addons/gpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@ OptableSDK.prototype.installGPTEventListeners = function () {
* installGPTSecureSignals() sets up loblaw media private ID secure signals on GPT from targeting.
*/
OptableSDK.prototype.installGPTSecureSignals = function () {
// Next time we get called is a no-op:
const sdk = this;
sdk.installGPTSecureSignals = function () {};

window.googletag = window.googletag || { cmd: [], secureSignalProviders: [] };
const gpt = window.googletag;

gpt.cmd.push(function () {
// Install lmpid secure signal
gpt.secureSignalProviders.push({
id: lmpidProvider,
collectorFunction: function () {
return Promise.resolve(sdk.lmpidFromCache() ?? "");
},
const lmpid = sdk.lmpidFromCache();
if (lmpid) {
gpt.cmd.push(function () {
gpt.secureSignalProviders.push({
id: lmpidProvider,
collectorFunction: function () {
return Promise.resolve(lmpid);
},
});
});
});
}
};

0 comments on commit 5f78fff

Please sign in to comment.