帮助文档:https://help.ads.microsoft.com/#apex/ads/en/56684/2-500
1、加什么?
1)全局代码:基础代码
2)事件代码:自定义事件
2、在哪儿加?
1)UET基础代码需要添加在网站的每一个页面
2)事件代码需要加在事件发生页面
3、 代码文本及安装步骤
1) 全局代码:
全局代码添加在网站的每一个页面或者master page上的head或body层级。也就是说,添加在<head>和</head>之间、或<body>和</body>之间的任意位置。
以下代码文本中均需要替换Tag ID,ID为代码的唯一标识,查看位置:Tools > UET Tags > 相应代码行查看。
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"替换tagID"};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");</script>
2)事件代码:
微软官方帮助文档已经详细介绍了添加步骤,本文档作为中文补充,如在安装过程中有任何问题,请联系责任AM。
① 事件代码模板:
<script>
window.uetq = window.uetq || [];
window.uetq.push ('event', 'Replace_with_Event_Action', {'event_category': 'Replace_with_Event_Category', 'event_label': 'Replace_with_Event_Label', 'event_value': 'Replace_with_Event_Value'});
</script>
其中变量:
Category:事件类型,如 “Purchase”
Action:事件动作,如 “Purchasebuttonclick”
Label:事件标签,自定义
Value:与事件关联的数值,如果是追踪支付,可回传订单金额
用户在点击广告进入网站后,完成相应动作(如点击某个按钮)触发代码,当代码中以上任意字段和转化目标中设置的字段能够匹配上,会记为一次转化。
② 安装步骤
示例:
需求:客户需要用event代码追踪加购。
安装位置:事件发生页面
Ⅰ. 为代码命名,任意没有在网站上被用过的名字都可以,示例命名为GetCustomEvent():
<script>
function GetCustomEvent() {
window.uetq = window.uetq || [];
window.uetq.push ('event', 'Replace_with_Event_Action', {'event_category': 'Replace_with_Event_Category', 'event_label': 'Replace_with_Event_Label', 'event_value': 'Replace_with_Event_Value'});
}
</script>
Ⅱ. 编辑网站代码,示例中,用户点击确认加购按钮时需要触发代码,因此需要调整按钮本身的代码:
<script>
function GetCustomEvent() {
window.uetq = window.uetq || [];
window.uetq.push ('event', 'Replace_with_Event_Action', {'event_category': 'Replace_with_Event_Category', 'event_label': 'Replace_with_Event_Label', 'event_value': 'Replace_with_Event_Value'});
}
</script>
...
<button OnClick="GetCustomEvent()">Add to cart</button>
Ⅲ. 自定义变量,完成代码如下:
<head>Your page title
</head>
<body>
<script>Your UET tag is here.</script>
<script>
function GetCustomEvent() {
window.uetq = window.uetq || [];
window.uetq.push ('event', 'addtocart', {});
}
</script>
...
<button OnClick="GetCustomEvent()>Add to cart</button>
...
</body>