From 5f78ffff180f7f9f39e0d5be9d917fdbda5c4d62 Mon Sep 17 00:00:00 2001 From: MO Thibault <103271673+MO-Thibault@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:45:18 -0400 Subject: [PATCH] set lmpid only if exists (#111) Co-authored-by: Nikola Milekic --- lib/addons/gpt.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/addons/gpt.ts b/lib/addons/gpt.ts index 16b82199..077ba738 100644 --- a/lib/addons/gpt.ts +++ b/lib/addons/gpt.ts @@ -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); + }, + }); }); - }); + } };