Adobe DTM 自定义规则条件检查 cookie
Adobe DTM Custom rule conditions check for cookies
我在获取特定规则以在 DTM 中触发时遇到了一些问题。 Adobe 关于自定义规则条件的文档非常基础。
应该做什么:
- 检查是否存在特定的 cookie(cookie 的值无关紧要)。
- 当此 cookie 不存在时触发规则。
使用这个脚本应该可以:
var n = document.cookie,
i = "someCookie" + "=",
o = n.indexOf("; " + i);
if (-1 == o) {
if (o = n.indexOf(i), 0 != o) return null
} else {
o += 2;
var r = document.cookie.indexOf(";", o); - 1 == r && (r = n.length)
}
return unescape(n.substring(o + i.length, r))
但恰恰相反。当 cookie 存在时,规则被触发。
如果您想坚持使用 Data > Custom 条件,最终它必须 return (bool) true
如果您想要条件通过,或者 (bool) false
如果您希望条件失败。
简单示例:
仅当 js var foo
等于 "bar":
时触发规则
if ((typeof foo!='undefined')&&(foo=='bar'))
return true;
return false;
我在获取特定规则以在 DTM 中触发时遇到了一些问题。 Adobe 关于自定义规则条件的文档非常基础。 应该做什么:
- 检查是否存在特定的 cookie(cookie 的值无关紧要)。
- 当此 cookie 不存在时触发规则。
使用这个脚本应该可以:
var n = document.cookie,
i = "someCookie" + "=",
o = n.indexOf("; " + i);
if (-1 == o) {
if (o = n.indexOf(i), 0 != o) return null
} else {
o += 2;
var r = document.cookie.indexOf(";", o); - 1 == r && (r = n.length)
}
return unescape(n.substring(o + i.length, r))
但恰恰相反。当 cookie 存在时,规则被触发。
如果您想坚持使用 Data > Custom 条件,最终它必须 return (bool) true
如果您想要条件通过,或者 (bool) false
如果您希望条件失败。
简单示例:
仅当 js var foo
等于 "bar":
if ((typeof foo!='undefined')&&(foo=='bar'))
return true;
return false;