How to track custom events with UET

How to track custom events with UET

Learn how to create custom events that allow you to track more than one type of conversion for a single webpage.

Bing Ads allows you to track custom events on your website, such as when people subscribe to a newsletter or download a white paper, as conversions. To learn more, see Why track custom events.

Requirements

Before you start setting up custom events, make sure you have:

How to set up custom events

Step 1: Create a custom event conversion goal in Bing Ads expando image
  1. Click the Campaigns tab, and then on the left pane, click Conversion Tracking.
  2. Under Conversion Tracking, click Conversion goals.
  3. Click Create conversion goal.
  4. Give your conversion goal a name, select Event, and then click Next.
  5. Choose the parameters to report when logging custom events by assigning each one you want to use a text string or numeric value. The possible parameters are:
    • Category: The category of the event you want to track. Let's say you want to track views of a certain video on your site. For this example, the category could be "video".
    • Action: The type of user interaction you want to track. For our example, "play".
    • Label: The name of the element that caused the action. For our example, "behindthescenes".
    • Value: A numerical value associated with that event. For our example, the length of the video played: "112".
      The event value can be any value from 0 to 9999999 to 3 decimal places.

    Note

    You'll customize your UET tag tracking code to match the values defined here (this is discussed in the next section of this article). This will allow Bing Ads to match these values with the custom events being logged via UET to count them as conversions.

  6. Select the Revenue value, Count, and Conversion window for this custom event goal.
  7. For UET tag, select the JavaScript UET tag you'll be using.
  8. Click Save.
Step 2: Modify your UET tag for this custom event expando image

You now need to add the custom event JavaScript to your UET tag tracking code. If you haven't already added the UET tag tracking code to your website, take a look at How do I add a UET tag to my website?

The standard custom event JavaScript is:

          <script>
   window.uetq = window.uetq || []; 
   window.uetq.push ('event', 'Event action', {event_category: 'Event category', event_label: 'Event label', event_value: 123 }); 
</script>

You will need to change 'Event action', 'Event category', 'Event label', and 'Event value' to match the values you defined in the above section. So, using the example values from the above section, this JavaScript would be:

          <script>
   window.uetq = window.uetq || []; 
   window.uetq.push ('event', 'play', {event_category: 'video', event_label: 'behindthescenes', event_value: '112'});  
</script>

To see an example of a custom event UET tag tracking code installed in the body of a webpage, visit this webpage (English only), right-click in the webpage, and then click View source or View page source depending on your browser. On this page, you'll also see some buttons. Clicking each button will trigger a custom event. If you use a third-party monitoring tool like Fiddler, you can see the HTTP request generated to bat.bing.com to report each custom event.

Notes
  • As your webpage loads, it triggers the UET tag, resulting in a number of HTTP requests. The most important request is to "bat.bing" (the one that looks like "http://bat.bing.com/action/0?ti=..."). This request tells Bing Ads about the user visits to your webpage. You can use third-party tools such as Fiddler to monitor all the requests that your browser is making when your webpage loads.
  • For custom events, an additional HTTP request is triggered to report the same to Bing Ads. The request is similar to the bat.bing but it has different parameters to report custom event (as opposed to just page visit).
Tips for working with custom events expando image
  • uetq is a JavaScript object instantiated by the UET tracking code when the page is loaded.
  • The code inside the <script></script> tag should be instantiated when the user action (for example, a button click) is complete. It could be wired up directly to an onclick event or wrapped inside a JavaScript function that is wired to the onclick event.
  • The command 'event' is always required, even if you're not reporting any Event action. If that's the case, you can set Event action either as:
    • Empty. For example:
      <script>
         window.uetq = window.uetq || []; 
         window.uetq.push('event', '', {event_category: 'Event category', event_label: 'Event label', 'event_value': 'Event value'});  
      </script>
    • One of the following actions that might help you identify the event action in the future:
      add_payment_info, add_to_cart, add_to_wishlist, begin_checkout, checkout_progress, exception, generate_lead, login, page_view, purchase, refund, remove_from_cart, screen_view, search, select_content, set_checkout_option, share, sign_up, timing_complete, view_item, view_item_list, view_promotion, view_search_results
      For example:
      <script>
         window.uetq = window.uetq || []; 
         window.uetq.push('event', 'add_payment_info', {event_category: 'Event category', event_label: 'Event label', 'event_value': 'Event value'});  
      </script>
  • If you're only tracking Event action, you can remove the other parameters from the code. For example:
    <script>
       window.uetq = window.uetq || []; 
       window.uetq.push('event', 'Event action', {});  
    </script>
  • You can use any string value for Event category, Event action, and Event label.
  • You can send the event value without quotes given that it's a numerical value. For example, <button onclick="window.uetq = window.uetq || []; window.uetq.push({ 'event_category':'Video', 'event':'Play', 'event_label':'Product Demo', 'event_value':5 });">Play</button>. Event value 5 is passed without quotes.
  • You can also pass variable revenue with the custom events. To learn more, see How to report variable revenue with UET.
Note

You can validate that your custom events are working using the UET Tag Helper.

See more videos...