將您的 UET 標籤更新成使用新語法

了解為何您應將 UET 標籤更新成使用新語法,以及如何更新。
注意

不知道 UET 是什麼?請查看 什麼是 UET?它能為我提供哪些幫助?

我們更新了 JavaScript UET 標籤的語法。建議您更新自己網站程式碼中任何現有的 UET 標籤來使用新語法。

使用新語法的優點

新語法:

  • 自動對您的參數值進行 URL 編碼 (百分比符號編碼),確保您的網址不會被錯誤轉譯。
  • 支援單頁應用程式 (SPA) 網站。
  • 可讓您為自己網頁上任何相容的 UET 事件設定頁面層級參數。
  • 具有易懂的參數名稱,方便您進行組織和管理。

更新的標籤有何不同?

  1. 現在,自訂事件與變動收入的 UET 標籤中都必須有事件動作參數,而且都要先出現。
  2. 自訂事件與變動收入的 JavaScript 參數名稱現在更好懂了:
舊語法 新語法
ea event
ec event_category
el event_label
ev event_value
gv revenue_value
gc currency

比較語法

舊語法 (自訂事件)

<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>

新語法 (自訂事件)

<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>


舊語法 (變動收入)

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

新語法 (變動收入)

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

範例

追蹤所有四個自訂事件類型

<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>

不追蹤事件動作,但追蹤其餘三種事件類型 (請注意,'event' 會保留,只是值的部分是空的):

<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>

只追蹤事件動作 (請注意,其餘不必要的事件類型都已移除):

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

取得詳細資訊

See more videos...