Adobe 外掛程式:getVisitDuration

IMPORTANT
此外掛程式由 Adobe Consulting 提供,協助您從 Adobe Analytics 中獲得更多價值。Adobe 客戶服務不提供此外掛程式的支援,包括安裝或疑難排解在內。如果您需要與此外掛程式有關的協助,請聯絡貴組織的 Adobe 客戶團隊。他們可幫您安排顧問會議,以尋求協助。

getVisitDuration 外掛程式會追蹤訪客截至該時間點為止在網站上逗留的時間長度,以分鐘為單位。如果您想要追蹤網站上截至該時間點的累計時間,或追蹤執行活動所花費的時間,Adobe 建議使用此外掛程式。此外掛程式不會追蹤事件之間的時間長度;如果需要此功能,請使 getTimeBetweenEvents 用外掛程式。

使用Web SDK擴充功能安裝外掛程式

Adobe提供擴充功能,可讓您搭配Web SDK使用最常用的外掛程式。

  1. 使用您的 AdobeID 認證登入 Adobe Experience Platform 資料彙集

  2. 按一下 標籤 然後,按一下所需的標籤屬性。

  3. 按一下 擴充功能 然後按一下左側的 目錄 標籤

  4. 找到並安裝 常見Web SDK外掛程式 副檔名。

  5. 按一下 資料元素 然後按一下所需的資料元素。

  6. 使用下列設定來設定所需的資料元素名稱:

    • 擴充功能:常見Web SDK外掛程式
    • 資料元素: getVisitDuration
  7. 儲存並發佈資料元素的變更。

手動實作Web SDK安裝外掛程式

此外掛程式尚不支援在Web SDK的手動實作中使用。

使用Adobe Analytics擴充功能安裝外掛程式

Adobe提供擴充功能,可讓您搭配Adobe Analytics使用最常用的外掛程式。

  1. 使用您的 AdobeID 認證登入 Adobe Experience Platform 資料彙集

  2. 按一下所需的標籤屬性。

  3. 前往擴充功能標記,然後按一下「目錄」按鈕

  4. 安裝並發佈常用 Analytics 外掛程式擴充功能

  5. 如果您尚未執行上述步驟,請使用下列設定建立標示為「初始化外掛程式」的規則:

    • 條件:無
    • 事件:核心 - 已載入資料庫 (頁面頂端)
  6. 使用下列設定將動作新增至上述規則:

    • 擴充功能:常用 Analytics 外掛程式
    • 動作類型:初始化 getVisitDuration
  7. 儲存並發佈規則的變更。

使用自訂程式碼編輯器安裝外掛程式

如果您不想使用常見Analytics外掛程式擴充功能,可以使用自訂程式碼編輯器。

  1. 使用您的 AdobeID 認證登入 Adobe Experience Platform 資料彙集
  2. 按一下所需的屬性。
  3. 前往擴充功能索引標籤,然後按一下 Adobe Analytics 擴充功能底下的​ 「設定」 ​按鈕。
  4. 展開使用自訂程式碼設定追蹤摺疊式功能表,便會顯示「開啟編輯器」按鈕。
  5. 開啟自訂程式碼編輯器,並將下方提供的外掛程式程式碼貼入編輯視窗中。
  6. 儲存並發佈 Analytics 擴充功能的變更。

使用 AppMeasurement 安裝外掛程式

Analytics 追蹤物件實例化 (使用 s_gi) 後,將下列程式碼複製並貼到 AppMeasurement 檔案中的任何位置。保留您實作中的程式碼備註和版本號碼,有助於 Adobe 疑難排解任何可能問題。

/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getVisitDuration v2.1 */
function getVisitDuration(){if(arguments&&"-v"===arguments[0])return{plugin:"getVisitDuration",version:"2.1"};var d=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 d&&(d.contextData.getVisitDuration="2.1");window.cookieWrite=window.cookieWrite||function(c,b,f){if("string"===typeof c){var h=window.location.hostname,a=window.location.hostname.split(".").length-1;if(h&&!/^[0-9.]+$/.test(h)){a=2<a?a:2;var e=h.lastIndexOf(".");if(0<=e){for(;0<=e&&1<a;)e=h.lastIndexOf(".",e-1),a--;e=0<e?h.substring(e):h}}g=e;b="undefined"!==typeof b?""+b:"";if(f||""===b)if(""===b&&(f=-60),"number"===typeof f){var d=new Date;d.setTime(d.getTime()\+6E4*f)}else d=f;return c&&(document.cookie=encodeURIComponent(c)+"="+encodeURIComponent(b)+"; path=/;"+(f?" expires="+d.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,a=b.indexOf(" "+c+"="),d=0>a?a:b.indexOf(";",a);return(c=0>a?"":decodeURIComponent(b.substring(a+2+c.length,0>d?b.length:d)))?c:""};d=(new Date).getTime();var k=cookieRead("s_dur"),a=0;if(isNaN(k)||18E5<d-k)k=d;a=d-k;cookieWrite("s_dur",k+"",30);if(0===a)return"first hit of visit";a=Math.floor(a/6E4);return 0===a?"less than a minute":1===a?"1 minute":a+" minutes"};
/******************************************** END CODE TO DEPLOY ********************************************/

使用外掛程式

getVisitDuration 函數不使用任何引數。 它會傳回以下其中一個值:

  • "first hit of visit"
  • "less than a minute"
  • "1 minute"
  • "[x] minutes" (其中 [x] 是訪客進到網站以來經過的分鐘數)

此外掛程式會建立名為 "s_dur" 的第一方 Cookie,這是訪客進到網站以來經過的毫秒數。閒置 30 分鐘後,Cookie 便會到期。

範例

// Always sets eVar10 to the number of minutes passed since the visitor first landed on the site
s.eVar10 = getVisitDuration();

// Checks if the events variable contains the purchase event.
// If it does, sets eVar56 to the number of minutes between the start of the visit and the time of purchase
if(inList(s.events, "purchase")) s.eVar56 = getVisitDuration();

版本記錄

2.1 (2021 年 3 月 19 日)

  • 將版本編號加入為內容資料。

2.0 (2018 年 5 月 2 日)

  • 單點發行 (外掛程式全面重新分析/重寫)。
recommendation-more-help
b4f6d761-4a8b-4322-b801-c85b9e3be690