Fix Microsoft Ads Conversion Tracking in Shopify

Published on Jun 21, 2024

By Liam Gallagher

#E-commerce#Digital Marketing#Shopify
Man in Black Jacket Standing Beside Woman in White Shirt

In the ever-evolving landscape of e-commerce, tracking conversions accurately is crucial for measuring the success of your advertising campaigns. However, recent changes in Shopify’s checkout process and the introduction of the Web Pixels API have caused some headaches for store owners using Microsoft Ads (formerly Bing Ads) for their marketing efforts. This comprehensive guide will walk you through the issues and provide a solution to ensure your Microsoft Ads conversion tracking works seamlessly with Shopify’s new system.

Understanding the Problem

The Root Cause

Shopify’s introduction of the Web Pixels API and changes to the checkout process have inadvertently affected how third-party scripts, including Microsoft’s UET (Universal Event Tracking) tag, function on Shopify stores. The main issue stems from these scripts now running in a sandboxed environment within an iFrame, which limits their ability to access certain page elements and URL parameters crucial for conversion tracking.

Impact on Microsoft Ads Tracking

The primary consequence of this change is that the UET tag from Microsoft Ads cannot accurately track conversions. This is likely due to the tag’s inability to access the correct URL parameters, particularly the MSCLKID (Microsoft Click ID), which is essential for attributing conversions to specific ad campaigns.

The Importance of Accurate Tracking

Without proper conversion tracking:

  1. You can’t accurately measure the ROI of your Microsoft Ads campaigns
  2. Automated bidding strategies may not function optimally
  3. You lose valuable insights into which ads and keywords are driving sales

The Solution: Custom Implementation

Overview of the Fix

The most effective solution involves creating a custom pixel using Shopify’s Web Pixels API and modifying how the UET tag is implemented. This approach allows you to bypass the limitations imposed by the sandboxed environment while still capturing the necessary conversion data.

Step-by-Step Implementation

1. Create a Custom Pixel

First, you’ll need to create a custom pixel in your Shopify admin panel. This pixel will use the Web Pixels API to capture checkout events and pass them to the UET tag.

2. Implement the Custom Code

Replace YOUR_UET_TAG_ID with your actual UET tag ID from Microsoft Ads in the following code:

(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"YOUR_UET_TAG_ID", 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','purchase', {
    'revenue_value': event.data.checkout.totalPrice.amount,
    'currency': event.data.checkout.currencyCode
  });
});

This code initializes the UET tag and sets up an event listener for the checkout_completed event. When a purchase is made, it sends the conversion data to Microsoft Ads.

3. Configure Microsoft Ads Conversion Goal

In your Microsoft Ads account:

  1. Create a new conversion goal
  2. Set the goal type to “Event”
  3. Configure the event action to match the event name in your code (in this case, “purchase”)

Testing the Implementation

To ensure your new setup is working correctly:

  1. Use the UET Tag Helper Chrome extension provided by Microsoft
  2. Complete a test purchase on your store
  3. Verify that the conversion event is being fired and captured correctly

Troubleshooting Common Issues

No Conversions Showing in Microsoft Ads

If you’re not seeing conversions in your Microsoft Ads dashboard:

  1. Double-check that your UET tag ID is correct in the custom pixel code
  2. Ensure the conversion goal in Microsoft Ads is set up correctly with the right event name
  3. Verify that the conversion window in your Microsoft Ads settings aligns with your sales cycle

Incorrect Revenue Values

If revenue values are not accurate:

  1. Confirm that the totalPrice.amount is being passed correctly in the event data
  2. Check for any currency conversion issues if you operate in multiple markets

Delayed Conversion Reporting

Remember that there can be a delay between when a conversion occurs and when it appears in your Microsoft Ads dashboard. This is normal and can take up to 24-48 hours in some cases.

Best Practices for Ongoing Management

Regular Monitoring

Set up a routine to regularly check your conversion tracking:

  1. Use the UET Tag Helper to periodically test your setup
  2. Compare conversion data in Microsoft Ads with your Shopify analytics
  3. Stay informed about any updates to Shopify’s Web Pixels API or Microsoft Ads tracking requirements

Keeping Your Implementation Up-to-Date

As both Shopify and Microsoft continue to evolve their platforms:

  1. Subscribe to official update channels for both platforms
  2. Be prepared to adjust your implementation if new features or changes are introduced
  3. Consider working with a certified Shopify or Microsoft Ads partner for complex setups

Leveraging Conversion Data

With accurate conversion tracking in place:

  1. Use the data to optimize your ad campaigns
  2. Experiment with different bidding strategies based on conversion performance
  3. Analyze which products or categories drive the most valuable conversions

By following this guide, you should be able to overcome the challenges posed by Shopify’s Web Pixels API and ensure that your Microsoft Ads conversion tracking functions correctly. Remember, accurate tracking is the foundation of effective digital advertising, allowing you to make data-driven decisions and maximize your return on ad spend.

Take Our Quick Quiz:

Which primary product image do you think has the highest conversion rate?