setTargeting
API调用在调用Google Publisher Tag .setTargeting
方法之前,添加if语句以检查Audience Managercookie。
IF
语句检查Audience ManagerCookie.setTargeting
方法从Audience Manager目标cookie和唯一用户ID cookie(aam_uuid
)获取数据。 但是,如果.setTargeting
在[!UICONTROL 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"));
};
根据您希望如何与Google Ad Manager集成,您只需要上面代码示例中的一些行:
aam_uuid
cookie的值插入日志中,以便能够摄取它们以进行报告。AamGpt
函数和数据类型定义if
语句中使用的关键变量。
函数 | 类型 | 描述 |
---|---|---|
|
字符串 |
返回键值段对中的键。 例如,如果键值对由 |
|
字符串数组 |
返回数组中的值,例如 |
|
Int |
返回Audience Manager用户ID,例如 |