Update your UET tags to the new syntax

Learn why you should update your UET tags to our new syntax, and how to do it.
Note

Don't know what UET is? Check out What is UET and how can it help me?

We have updated the syntax of JavaScript UET tags. We recommend that you update any existing UET tags in your website's code to take advantage of the new syntax.

Benefits of using the new syntax

The new syntax:

  • Automatically URL-encodes (percent encoding) your parameter values, ensuring your URLs are not mistranslated.
  • Supports single-page application (SPA) websites.
  • Lets you set page-level parameters for any compatible UET event on your webpage.
  • Has parameter names that are easy to understand, helping you organize and manage them.

What's different in the updated tags?

  1. The event action parameter is now required in both custom event and variable revenue UET tags, and this parameter appears first in both cases.
  2. The JavaScript parameter names for custom events and variable revenue are now easier to understand:
Old syntax New syntax
ea event
ec event_category
el event_label
ev event_value
gv revenue_value
gc currency

Comparing the syntaxes

Old syntax (custom event):

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ({'ec': 'Replace_with_Event_Category', 'ea': 'Replace_with_Event_Action', 'el': 'Replace_with_Event_Label', 'ev': 'Replace_with_Event_Value'});
</script>

New syntax (custom event):

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ('event', 'Replace_with_Event_Action', {'event_category': 'Replace_with_Event_Category', 'event_label': 'Replace_with_Event_Label', 'event_value': 'Replace_with_Event_Value'});
</script>


Old syntax (variable revenue):

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ({'gv': 'Replace_with_Revenue_Value', 'gc': 'Replace_with_Currency_Code'});
</script>

New syntax (variable revenue):

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ('event', '', {'revenue_value': 'Replace_with_Revenue_Value', 'currency': 'Replace_with_Currency_Code'});
</script>

Examples

Tracking all four custom event types:

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ('event', 'Contoso_Event_Action', {'event_category': 'Contoso_Event_Category', 'event_label': 'Contoso_Event_Label', 'event_value': 'Contoso_Event_Value'});
</script>

Not tracking event action, but tracking the other three event types (note that 'event' remains with its value empty):

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ('event', '', {'event_category': 'Contoso_Event_Category', 'event_label': 'Contoso_Event_Label', 'event_value': 'Contoso_Event_Value'});
</script>

Only tracking event action (note that the other, unnecessary event types have been removed):

<script>  
   window.uetq = window.uetq || [];
   window.uetq.push ('event', 'Contoso_Event_Action', {});
</script>

Get more info

See more videos...