After expanding my advertising efforts with my company OMP Tools from Google AdWords to Bing Ads, I ran into a few difficulties while implementing a functioning Conversion Tracking with the UET Tag.
The difference between UET Tag and AdWords Conversiontracking
The two tracking methods are fundamentally different, as for example FRWD wrote in his excellent article about bing ads UET.
Basically, the UET Tag is more like the Google Analytics tag, so it should be implemented on every single page to allow Microsoft to collect all the datas. In a second step, you have to define the Goals in Bing Ads.
This version of the tracking offers various advantages:
- measuring site-wide statistics as conversions (duration of visit, …)
- easy implementation (one single script)
- Javascript events
But, like always, with increased settings comes increased risk of errors. Just the definition of every single target Url could have users sweating if they entered the values correctly.
Where I ran into an issue
My Problem, on the other hand, was something a little different. On some landingpages that I use, the tracking of conversions is done via AJAX in an Iframe. So i put the UET Tag into the Iframe, and voila – it fired, no problem.
Just a few hours later I realized that there is more to it, because Microsofts bat.js does not track the direct URL if the window.self differs from the window.top:
1 2 3 4 5 6 7 |
if (window.self != window.top) n.hasOwnProperty("r") && (n.p = n.r, n.r = ""); else { var t = window.location.href, r = window.location.hash, f = t.indexOf(r) >= 0 ? t : t + r; n.p = encodeURIComponent(f), n.r = encodeURIComponent(u) } |
This is quite bad for this (I know, not best practise, but hey – it happens all the time) method of tracking, as the targetURL does not get tracked by UET. Therefor I altered the script a little bit to exclude this part and changed it to that:
1 2 3 4 5 6 7 |
//if (window.self != window.top) n.hasOwnProperty("r") && (n.p = n.r, n.r = ""); //else { var t = window.location.href, r = window.location.hash, f = t.indexOf(r) >= 0 ? t : t + r; n.p = encodeURIComponent(f), n.r = encodeURIComponent(u) //} |
The minified version of this script can be found at https://bing.fischi.cc/bat.js
Disclaimer
If you have trouble tracking conversions in an Iframe when unsing Bing UET Tag, you can think about embeding my script instead. It is the same, but without the three lines removed.
Please be sure to validate if this works for you. If so, change your UET Tag from
1 |
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"YOURTRACKERID"};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><noscript><img src="//bat.bing.com/action/0?ti=5822070&Ver=2" height="0" width="0" style="display:none; visibility: hidden;" /></noscript> |
to this:
1 |
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"YOURTRACKERID"};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","//bing.fischi.cc/bat.js","uetq");</script><noscript><img src="//bat.bing.com/action/0?ti=5822070&Ver=2" height="0" width="0" style="display:none; visibility: hidden;" /></noscript> |
It works perfectly for me – the submitted „p“ parameter now shows the URL of the Iframe.
Amazing! Its truly awesome piece of writing, I
have got much clear idea concerning from this piece of writing.