Official help documentation: https://help.ads.microsoft.com/#apex/ads/en/56913/2-500
1. Add what?
1) Global Code: basic code
2) Assigned amount Code: tracks the order amount and currency. If there is no need to track specific revenue, just add the global code
2. Where?
1) UET basic code needs to be added to every page of the website
2) The assigned amount code needs to be added to the page of accounting conversion effect (according to the needs of advertisers, usually the order completion page)
3. Code text and installation steps
1) Global Code:
The global code is added at the head or body level on each page of the website or the master page. That is, add anywhere between < head > and < / head >, or between < body > and < / body >.
The Tag ID needs to be replaced in the following code text. The ID is the unique identification of the code. View the location: Tools > uet tags > view the corresponding code line.
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"replace 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) Assignment code:
On the order completion page, in addition to the above codes, assignment statistics codes need to be added. The page completion codes are as follows (Global + assignment):
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"XXXXXXtagID"};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> <script> window.uetq = window.uetq || []; window.uetq.push({ 'gv' : {{ subtotal_price | money_without_currency }}, 'gc' : '{{ shop.currency }}' }); </script>
The above is a general template. Most websites can directly copy and paste the code segment, and the detection can be successfully returned.
However, the situation of each website is different. If necessary, please define variables one by one according to the actual situation of your website and the template officially given by Microsoft. The variables to be defined are the order amount and currency. The order amount can be obtained through JS function methods or directly reading HTML element values.
The initial template is as follows:
<head>Your page title </head> <body> // Let's say this is where you pasted the UET tag. <script>Global code</script> // The assignment code template is as follows: <script> window.uetq = window.uetq || []; window.uetq.push('event', '', {'revenue_value': Replace_with_Variable_Revenue_Function(), 'currency': 'Replace_with_Currency_Code'}); </script> ... </body>
Example:
1) Ensure that there is a code segment defining revenue in the website code. Example: function named GetRevenueValue:
<script> function GetRevenueValue() { return 6; } </script>
2) Replace in the code template_ with_ Variable_ Revenue_ Replace function() with GetRevenueValue:
<script> window.uetq = window.uetq || []; window.uetq.push('event', '', {'revenue_value': GetRevenueValue(), 'currency': 'Replace_with_Currency_Code'}); </script>
3) Currency: you can use variables or write them directly, such as' currency ':' USD '; View currency abbreviations supported by Bing
<script> window.uetq = window.uetq || []; window.uetq.push('event', '', {'revenue_value': GetRevenueValue(), 'currency': 'USD'}); </script>
After modification, the completion code of the payment completion page is as follows:
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"XXXXXXtagID"};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> <script> window.uetq = window.uetq || []; window.uetq.push('event', '', {'revenue_value': GetRevenueValue(), 'currency': 'USD'}); </script>