Bing/Microsoft Ads UET not working with new Shopify Web Pixels API

All scripts which are included as “web pixels” via the new Shopify Web Pixels API are running in a sandboxed environment in an iFrame.

Unfortunately, this causes, that the UET tag from Microsoft Ads (formerly Bing Ads) does not track conversions correctly. I assume, that the tag is unable to get the correct URL parameters (including the MSCLKID), which is responsible for the conversion tracking.

One way would be to extract the parameter and send it along with the tag, but unfortunately the documentation from Microsoft is awful about the UET tag and does not state how to overwrite the parameters.

Is there any workaround for this? How do you guys track conversion from Microsoft Ads with the new Web Pixels API?

2 Likes

I just turned off my old “additional script” and updated the Microsoft Channel app. It looks like they are handling this completely. See the attached screenshot.

My prior reply wasn’t quite right. The app is using the scripts api to inject that.

However, I got this all to work.

Create a custom pixel with the following code:

(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||,f=function(){var o={ti:“PUT YOUR ID HERE”, 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”);

analytics.subscribe(“checkout_completed”, (event) => {
uetq = uetq || ;
uetq.push(‘event’,‘’,
{
‘revenue_value’: event.data.checkout.totalPrice.amount,
‘currency’ : event.data.checkout.currencyCode
});

});

Then in your Microsoft ads conversion, change it to track the destination URL to:
Contains: processing?completed=true

The sandbox fires on this, not the “thank-you” so that’s how you can get it to track. I tested this with the UET testing tool in Microsoft ads, it works beautifully.

3 Likes

I don’t really understand your reply, because your uetq event does not event have an event name.

Also, the problem on our side is not that the event and the value are not sent, they are and Microsoft receives them with correct values. But the problem is, it can’t match it to the conversions. So I think the msclkid parameter is somehow missing.

If I use the UET chrome plugin to test conversions, I get a valid test when my goal conversion has the destination URL set to “contains:thank_you” and when I set it to “contains:processing?completed=true” the conversion no longer gets recorded.

However, regardless of whether or not my conversion is getting recorded in the UET chrome plugin helper, my tracking status is “no recent conversions”

Do you know if this will remain as “no recent conversions” until I have an actual conversion from Bing OR will any conversions on my site cause the tracking status to be set to “recording conversions”

(Also replying to @wearebandb here)

If you are getting a valid test on “contains:thank_you” are you testing on the new checkout with extensibliity or still the old? That’s the final url of the old checkout, if you make the new one active you’ll notice it ends on “thank-you” which is subtly different.

Everything I put above is assuming you’ve already switched. There’s no way to test this side-by-side that I know of, because it’s so completely different. The good news is that the new checkout extensibility will let you revert; just make sure you save off your code in “additional scripts” because it makes you delete that before you can upgrade.

When you set up the conversion event with Microsoft of the destination url type, then it gives you the code to insert on the page, you only get a recorded conversion if that event pushes on the page you defined.

In the new shopify pixels model you need to subscribe to the events in the javascript as a more reliable trigger and to access certain data. There’s a checkout complete event, and that’s where you put the code Microsoft provides for conversion, which in my script above is the call to uetq.push() passing in the dollar amounts. Note, that’s code I’ve cleaned up to work in the scope of Shopify’s pixel sandbox.

I specifically found that this Shopify event fires in the scope of a dynamic URL but has “processing?completed=true” in the query string.

If microsoft code fires && url = destination url configured in ads, conversion happens. @wearebandb It doesn’t matter that it doesn’t have an event name. Their logic is taking care of that and when you push it the revenue fields it sees that as the conversion. That’s why they give you this block of code to record it.

So here’s how you can test it:

  • Create a new conversion event, based on a destination URL of containing “processing?completed=true”
  • Activate the new checkout pages in your checkout in settings.
  • Create a new custom pixel, pop that code from above in, making sure you are putting in your UET tag id
  • Test it with the UET test browser extension. Conversions don’t populate instantly in the ads portal

It’s working perfectly for me; if it’s not working for you, it’s most likely something you’ve done wrong / don’t understand about the eventing model.

1 Like

I guess I must be testing on the old checkout. Do you know if we have to switch over to the new checkout for UET to work properly?

I tried following the implementation directions here: https://help.ads.microsoft.com/apex/index/3/en/56901

But my revenue information wasn’t getting passed through when testing with the UET chrome plugin. Shopify was suggesting I set up tracking with pixels, which is what led me to this thread. When I use your pixel code to pass the revenue information, I see the revenue information appear in my UET plugin when testing. HOWEVER, I still get the following error message:

Website missing variable revenue code snippet
Variable revenue goals require you to add a custom code snippet to report revenue value. For Destination URL goals, this custom implementation should not contain Event parameters – Category, Action, Label, Value.

Any help would be appreciated.

Also, can you confirm if the “tracking status” on my conversion goal dashboard will only be set to "Recording conversions" when I have a purchase that comes through Bing, or will it read “Recording conversions” once I have my tracking set up properly (even if my Bing ads are on pause)?

What I’m outlining is undocumented and unsupported. Microsoft has yet to publish guidance on UET conversion tracking with the new pixels api. It’s all just javascript, I figured out how and where to make it work just as it does today. In the future, I’m sure Microsoft will back this into their Shopify Channel app, in which case I’ll have to quickly disable this in order to not record conversions more than once.

So, as I mentioned above, yes you would have to be on the new checkout for my steps above to work. It’s all specific to the changes that happen as a result of the new checkout.

As far as your last question, I do not know for certain but I’d say it only shows “Recording conversions” if it’s actively recording a conversion, which requires a purchase that was influenced by an ad.

This is why the UET tag helper is your friend. It mocks a conversion. If it completes, then you can rest assured that conversions will record when you are running successful ads.

Understood, thanks for the quick replies!

Thanks for your reply.

We had Bing conversion goal of the type “Product” and category “Purchase” set up, as you can see here:

Now I’ve set up a second one which doesn’t listen on the “Purchase” event, instead as you said on the URL. I don’t know why this should be the problem, but it’s possible that this is the solution.

Will keep you updated.

It’s the solution, because the documented and preferred method from Microsoft currently is to set up a destination URL conversion event using the code the wizard gives you to record the conversion and dollar amount.

What they have not accounted for in their docs (or official app) is the changes due to the new checkout, which are:

  • The event model for pixels, and the sandbox that they run in (my code above works, taking into account these minor changes)
  • The URL which fires the pixel is no longer on the “thank you” page, it comes on another page in a process of redirects shopify uses to check out the cart.

That said, you can absolutely use some other means of doing it. Depending on the type of conversion set up, they will give you different javascript snippets, which fire different types of events in their API. You can make those work, but you will have to modify to work in the new pixel sandbox. Specifically they have an “event” type conversion which is not dependent on the URL. It’s an explicit “this is a conversion” type event. Whenever you fire it, that’s it, that’s your conversion. Similarly, you’ll have to take the starter code that Microsoft gives you and modify to work in the new pixels sandbox. Subscribe to the checkout complete event and find the values you need in the data that’s passed to the event.

Again, it will only work if you’ve turned the new extensibility on.

Thanks for this info @jtaylormatchles . Did not realize how simple creating your own pixel was.

Only thing different I did was instead of using the URL as the conversion destination, I changed that to a purchase event and then send the data to that purchase event inside the checkout_completed event Shopify subscription.

Appreciate it!

Glad you found it helpful!

Hey @jtaylormatchles

We still have problems with our conversions. The strange thing is, that they are sent correctly, but not attributed correctly to a campaign (campaign is showing 0 conversions).

The tag setup is correct, as you can see on these screenshots (tested with Bing UET helper extension):

Also, the MSCLKID, which is responsible for matching the conversion to an ad campaign (which I set to 12345 in this test) is sent.

In Microsoft Ads, we can see that the event is received:

Exported data (you can see the same transaction ID):

Is there anything we forgot? Any campaign-related setting? Any help is appreciated.

With the UET helper, is it triggering an actual conversion? Or just an event? If it’s not triggering the conversion then you haven’t set it up properly. Depends on what your conversion event is. (URL, event, etc)

1 Like

Also keep in mind that conversions aren’t going to show real time. That’s what the helper is for, to validate that the criteria have been met for it to record.

@wearebandb Another thing to check is the Scope of your UET tag and scope of your conversion goals are matching.

The scope of the conversion goal is adjusted when setting up the goal.

1 Like

It triggers a “custom event”. But what is the correct event name for a conversion? We already tried multiple names, i.e. “purchase” and now “PRODUCT_PURCHASE”, which is shown by Microsoft Ads in the setup:

The tag setup:

The scope of my UET and the goal are not matching, yet when I get to the Edit Event Goal screen, I can only choose the one it’s set to (not matching) or all accounts. I’ve set it to all accounts now, but is this right? Is there something different I should be doing?

Hey @Timed_Ecom ! Any possibilites to share your created pixel using the purchase event? Need to setup conversion tracking for Microsoft Ads with a custom pixel.