Adobe 外掛程式:getTimeToComplete
IMPORTANT
此外掛程式由 Adobe Consulting 提供,協助您從 Adobe Analytics 中獲得更多價值。Adobe 客戶服務不提供此外掛程式的支援,包括安裝或疑難排解在內。如果您需要與此外掛程式有關的協助,請聯絡貴組織的 Adobe 客戶團隊。他們可幫您安排顧問會議,以尋求協助。
getTimeToComplete
外掛程式會追蹤使用者在網站上完成程序所花的時間。「時鐘」從呼叫 start
動作時開始,在呼叫 stop
動作時結束。如果網站上有工作流程需要一些時間才能完成,而且您想瞭解訪客完成該工作流程所花的時間,Adobe 建議您使用此外掛程式。如果您網站上的工作流程耗時較短 (少於 3 秒),就不需要使用此外掛程式,因為精細度只會降至完整秒。
使用Web SDK或Web SDK擴充功能安裝外掛程式
此外掛程式尚不支援在Web SDK中使用。
使用Adobe Analytics擴充功能安裝外掛程式
Adobe提供擴充功能,可讓您搭配Adobe Analytics使用最常用的外掛程式。
-
使用您的 AdobeID 認證登入 Adobe Experience Platform 資料彙集。
-
按一下所需的標籤屬性。
-
前往擴充功能標記,然後按一下「目錄」按鈕
-
安裝並發佈常用 Analytics 外掛程式擴充功能
-
如果您尚未執行上述步驟,請使用下列設定建立標示為「初始化外掛程式」的規則:
- 條件:無
- 事件:核心 - 已載入資料庫 (頁面頂端)
-
使用下列設定將動作新增至上述規則:
- 擴充功能:常用 Analytics 外掛程式
- 動作類型:初始化 getTimeToComplete
-
儲存並發佈規則的變更。
使用自訂程式碼編輯器安裝外掛程式
如果您不想使用常見Analytics外掛程式擴充功能,可以使用自訂程式碼編輯器。
- 使用您的 AdobeID 認證登入 Adobe Experience Platform 資料彙集。
- 按一下所需的屬性。
- 前往擴充功能索引標籤,然後按一下 Adobe Analytics 擴充功能底下的 「設定」 按鈕。
- 展開使用自訂程式碼設定追蹤摺疊式功能表,便會顯示「開啟編輯器」按鈕。
- 開啟自訂程式碼編輯器,並將下方提供的外掛程式程式碼貼入編輯視窗中。
- 儲存並發佈 Analytics 擴充功能的變更。
使用 AppMeasurement 安裝外掛程式
Analytics 追蹤物件實例化 (使用 s_gi
) 後,將下列程式碼複製並貼到 AppMeasurement 檔案中的任何位置。保留您實作中的程式碼備註和版本號碼,有助於 Adobe 疑難排解任何可能問題。
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getTimeToComplete v4.0 */
function getTimeToComplete(sos,cn,exp,tp){var f=sos,m=cn,l=exp,e=tp;if("-v"===f)return{plugin:"getTimeToComplete",version:"4.0"};var k=function(){if("undefined"!==typeof window.s_c_il)for(var c=0,b;c<window.s_c_il.length;c++)if(b=window.s_c_il[c],b._c&&"s_c"===b._c)return b}();"undefined"!==typeof k&&(k.contextData.getTimeToComplete="4.0");window.formatTime=window.formatTime||function(c,b,d){function e(b,d,c,e){if("string"!==typeof d)return!1;if("string"===typeof b)b=b.split(c||",");else if("object"!==typeof b)return!1;c=0;for(a=b.length;c<a;c++)if(1==e&&d===b[c]||d.toLowerCase()===b[c].toLowerCase())return!0;return!1}if(!("undefined"===typeof c||isNaN(c)||0>Number(c))){var h="";"string"===typeof b&&"d"===b||("string"!==typeof b\||!e("h,m,s",b))&&86400<=c?(b=86400,h="days",d=isNaN(d)?1:b/(d*b)):"string"===typeof b&&"h"===b||("string"!==typeof b||!e("m,s",b))&&3600<=c?(b=3600,h="hours",d=isNaN(d)?4:b/(d*b)):"string"===typeof b&&"m"===b||("string"!==typeof b||!e("s",b))&&60<=c?(b=60,h="minutes",d=isNaN(d)?2:b/(d*b)):(b=1,h="seconds",d=isNaN(d)?.2:b/d);h=Math.round(c*d/b)/d+" "+h;0===h.indexOf("1 ")&&(h=h.substring(0,h.length-1));return h}};window.cookieWrite=window.cookieWrite||function(c,b,d){if("string"===typeof c){var e=window.location.hostname,h=window.location.hostname.split(".").length-1;if(e&&!/^[0-9.]+$/.test(e)){h=2<h?h:2;var f=e.lastIndexOf(".");if(0<=f){for(;0<=f&&1<h;)f=e.lastIndexOf(".",f-1),h--;f=0<f?e.substring(f):e}}g=f;b="undefined"!==typeof b?""+b:"";if(d||""===b)if(""===b&&(d=-60),"number"===typeof d){var k=new Date;k.setTime(k.getTime()+6E4*d)}else k=d;return c&&(document.cookie=encodeURIComponent(c)+"="+encodeURIComponent(b)+"; path=/;"+(d?" expires="+k.toUTCString()+";":"")+(g?" domain="+g+";":""),"undefined"!==typeof cookieRead)?cookieRead(c)===b:!1}};window.cookieRead=window.cookieRead||function(c){if("string"===typeof c)c=encodeURIComponent(c);else return"";var b=" "+document.cookie,d=b.indexOf(" "+c+"="),e=0>d?d:b.indexOf(";",d);return(c=0>d?"":decodeURIComponent(b.substring(d+2+c.length,0>e?b.length:e)))?c:""};f=f?f.toLowerCase():"start";if("stop"===f||"start"===f){m=m?m:"s_gttc";e?e="d"===e?864E5:"h"===e?36E5:"s"===e?1E3:6E4:(l=30,e=6E4);l=isNaN(l)?30:l;l*=e;k=cookieRead(m);e=new Date;if("stop"===f&&k)return l=Math.round((e.getTime()-k)/1E3),cookieWrite(m,"",0),formatTime(l);"start"!==f||k?k&&Number(k)<e.getTime()+18E5&&cookieWrite(m,k,30):(f=String(e.getTime()),e.setTime(e.getTime()+l),cookieWrite(m,f,e))}};
/******************************************** END CODE TO DEPLOY ********************************************/
使用外掛程式
getTimeToComplete
函數會使用以下引數:
sos
(選用,字串):要啟動計時器時請設為"start"
。要停止計時器時設為"stop"
。預設為"start"
。cn
(選用,字串):儲存開始時間的 Cookie 名稱。預設為"s_gttc"
。exp
(選項,整數):cookie (和和計時器) 過期的秒數、小時數或天數 (取決於tp
時間分段引數)。 預設為 30 分鐘。tp
(選項,字串):cookie (和計時器) 過期的時間分段字串,與exp
一起使用。 設定為 "d" 表示天數、“h” 表示小時數,或 “s” 表示秒數。 如果未設定,無論exp
引數如何設定,cookie (和計時器) 過期預設為 30 分鐘。
呼叫此函數會傳回一個字串,其中包含 "start"
和 "stop"
動作之間所花費的天數、小時數、分鐘數和/或秒數。
範例
// Start the timer when the visitor starts the checkout
if(s.events.indexOf("scCheckout") > -1) getTimeToComplete("start");
// Stop the timer when the visitor makes the purchase and set prop1 to the time difference between stop and start
// Sets prop1 to the amount of time it took to complete the purchase process
if(s.events.indexOf("purchase") > -1) s.prop1 = getTimeToComplete("stop");
// Simultaneously track the time it takes to complete a purchase and to fill out a registration form
// Stores each timer in their own respective cookies so they run independently
if(inList(s.events, "scCheckout")) getTimeToComplete("start", "gttcpurchase");
if(inList(s.events, "purchase")) s.prop1 = getTimeToComplete("start", "gttcpurchase");
if(inList(s.events, "event1")) getTimeToComplete("start", "gttcregister", 7, "d");
if(inList(s.events, "event2")) s.prop2 = getTimeToComplete("stop", "gttcregister", 7, "d");
版本記錄
4.0 (2021 年 3 月 19 日)
- 將版本編號加入為內容資料。
3.1 (2019 年 9 月 30 日)
- 新增第一個引數中需要「start」或「stop」值的邏輯。傳入的其他所有值都會讓外掛程式停止執行。
- 將
inList 2.0
外掛程式更新至inList 2.1
。
3.0 (2018 年 8 月 23 日)
- 將
formatTime v1.0
外掛程式更新至formatTime v1.1
。
3.0 (2018 年 4 月 17 日)
- 單點發行 (重新編譯,程式碼大小較小)。
- 微幅錯誤修正。
2.0 2016 年 6 月 21 日)
- 消除對
p_fo
外掛程式的相依性。 - 新增與 H-Code 和 AppMeasurement 的相容性。
- 新增主控台記錄。
recommendation-more-help
b4f6d761-4a8b-4322-b801-c85b9e3be690