How to track Shopify conversion events in Microsoft Bing Ads with UET Tag

For a long while I was struggling to track Shopify purchase conversion events in Microsoft Bing Ads using the UET Tag and event scripts. I tried followed all the instructions from Microsoft Support, tried doing my own thing and eventually solved it with the old method of “pressing all the buttons”.

I’ll go through all the steps, but my stumbling block was the type of conversion I was trying to set up. If I tried to set up a “product” conversion, Microsoft Ads point blank refused to acknowledge them. Instead, I set it up as a URL conversion that will only appear on the Shopify order status page – details below.

The first step to get Microsoft Ads conversions tracked in Shopify is to install the MS UET tag so that the account notices website page views are relevant to your ads account. To create or find your MS UET tag, login to your Ads account and choose Tools > UET Tag. Grab the code for the tag. It will look something like this (where “xxxxxxxxxx” is your tag id):

<!-- MS UET Tag -->
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"xxxxxxxxxx", enableAutoSpaTracking: true};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>

You can either insert the MS UET Tag script into Shopify via the theme code directly, or via a GTM container that you might already be using on the site. If inserting directly into the code, put it in your theme.liquid file in the “head” area near the top. If already using GTM, there’s an official MS UET Tag you can search for where all you have to do is insert the tag id and then remember to publish the new container version.

You also need to make sure the MS UET tag fires when Shopify customers complete their order so you can start tracking purchases. Shopify uses dynamically generated “order status” pages. You can see one by clicking into an order and then pressing More Actions > View Order Status Page. To add scripts to this dynamic page, go to Shopify Settings > Checkout and scroll down to Order Status Page / Additional Scripts. If using GTM, make sure your GTM script is there. If using directly inserted code, paste your MS UET tag script here.

The next step is to create MS conversion events that send revenue details to Ads when those Order Status Pages are viewed the first time by the customer. Here’s the code that includes tax and shipping:

<!-- MS variable revenue event tracking script -->
{% if first_time_accessed %}
<script>
   window.uetq = window.uetq || []; 
   window.uetq.push('event', '', { 'revenue_value': {{ total_price | money_without_currency }}, 'currency': '{{ shop.currency }}' }); 
</script>
{% endif %}
<!-- end MS rev -->

Or if you want to exclude tax and shipping, use:

<!-- MS variable revenue event tracking script -->
{% if first_time_accessed %}
<script>
   window.uetq = window.uetq || []; 
   window.uetq.push('event', '', { 'revenue_value': {{ subtotal_price | money_without_currency }}, 'currency': '{{ shop.currency }}' }); 
</script>
{% endif %}
<!-- end MS rev -->

You can’t use GTM for this because of the Shopify Liquid code wrapped around it which ensures the conversion only first once per purchase, so insert your chosen script into the same checkout additional scripts area, underneath MS UET tag (or GTM tag).

Now create a conversion in MS Ads by going to Tools > Conversion Goals and press Create. Choose “Website” as the type of conversion. Then “purchase” as the category. Then some Goal Type options appear and this is where I was stumbling. Choose “Destination URL”:

I was previously trying to use “Product” goal type, but eventually I got bored of failing and decided to try the “Destination URL” goal type instead. Shopify Order Status Pages always have “/orders/” in the URL, so on the next page of the conversion setup, give the conversion a name like “ShopifyPurchase” and choose the destination URL contains “/orders/” and specify the revenue may vary. It will warn you that you need to modify the script for your revenue, but we aren’t going to use the code given to us anyway because we have already set made a Shopify appropriate version in the event tracking script above! It will look something like this:

shopify microsoft conversion goal type

So just save the conversion goal.

If you want to test to see if it works, use Chrome browser and install the UET Tag Helper extension. Then go to your list of Conversion Goals and you’ll see Tracking Status = “No recent conversions”. Hovering the mouse on that will give the TEST option. Before pressing it, open a completed Shopify order and View Order Status Page. When that opens copy the URL. Now, press TEST on the conversion goal in Ads and follow the instructions, part of which will need you to paste the Order Status Page URL in.

If you’ve followed all the steps, you should see a notice saying a conversion was found and you can press a button to see the details, which should include the revenue amount. This never happened when I was using the Product conversion goal type.

Let me know in comments if this helped you!

Leave a Comment

Your email address will not be published. Required fields are marked *

Previous post
Shopify has its own analytics tracking reports which include an…
Scroll to Top