修改GPT setTargeting API調用 modify-the-gpt-settargeting-api-call

在調用Audience ManagerCookie之前,添加if語句以檢查 Google Publisher Tag .setTargeting 的雙曲餘切值。

檢查Audience ManagerCookie IF 語句

.setTargeting 方法從Audience Manager目標cookie和唯一用戶ID cookie獲取資料( aam_uuid)。 但是,如果 .setTargeting 在 DIL 寫入這些cookie或cookie為空,在載入頁面時可能會出現錯誤。 為避免此情況,請包裝 .setTargeting 方法 if 用於檢查這些cookie的語句。 如果未設定,則此語句將阻止 .setTargeting 從呼叫 AamGpt 的子菜單。

IF 語句代碼示例

在此示例中,Audience Manager目標cookie名稱為 Sample。 在Audience Manager用戶介面中建立目標Cookie時,可設定此名稱。 DIL 設定 aam_uuid cookie和名稱無法更改。

if(typeof AamGpt.getCookie("Sample") != "undefined"){
  googletag.pubads().setTargeting(AamGpt.getKey("Sample"),AamGpt.getValues("Sample"));
};
if(typeof AamGpt.getCookie("aam_uuid") != "undefined" ){
   googletag.pubads().setTargeting("aamId", AamGpt.getCookie("aam_uuid"));
};
IMPORTANT
取決於您希望與 Google Ad Manager,您只需要上面代碼示例中的一些行:
  • 客戶端整合:僅使用第1-3行。
  • 伺服器端整合:不需要這些線。
  • 英格斯特 Google Ad Manager 用於報告的日誌檔案 Audience Manager:僅使用第4-6行。 此代碼插入 aam_uuid 將餅乾放入日誌中,以便可以攝取報告。

AamGpt 函式和資料類型

定義在 if 的雙曲餘切值。

函數
類型
說明
AamGpt.getKey
字串
返回鍵值段對中的鍵。 例如,如果鍵值對由 color=blue ,返回 color
AamGpt.getValues
字串陣列
返回陣列中的值,例如 ["value1","value2"]
AamGpt.getCookie
整型
返回Audience Manager用戶ID,例如 12345
recommendation-more-help
de293fbf-b489-49b0-8daa-51ed303af695