使用外掛程式

getTimeBetweenEvents 函數會使用以下引數:

  • ste (必要,字串):啟動計時器事件。 用於「啟動計時器」的 Analytics 事件字串 (以逗號分隔)。

  • rt (必要,布林值):重新啟動計時器選項。 如果每次 events 變數包含啟動計時器事件時都需重新啟動計時器,則設為 true。 如果您不希望計時器在看到啟動計時器事件時重新啟動,則設為 false。

  • stp (必要,字串):停止計時器事件。 用於「停止計時器」的 Analytics 事件字串 (以逗號分隔)。

  • res (必要,布林值):重設計時器選項。 如果要記錄計時器啟動後的時間,並在計時器停止後重設計時器,請設為 true。 如果要記錄時間但不要停止計時器,請設為 false。 如果設為 false,則計時器會在事件變數記錄停止事件後繼續執行。

    秘訣
    如果將此引數設為 false,強烈建議設定下方的 rte 引數。
  • cn (選用,字串):儲存第一個事件時間的 Cookie 名稱。 預設為 "s_tbe"。

  • etd (選用,整數):Cookie 的期限時間 (以天為單位)。 設為 0,在瀏覽器作業階段結束時到期。 若未設定,則預設為 1 天。

  • fmt (選用,字串):傳回秒數的時間格式 (無預設值)

    • "s" 代表秒數

    • "m" 代表分鐘

    • "h" 代表小時

    • "d" 代表天數

    • 若未設定,傳回值的格式會依據以下規則:

      • 不到一分鐘的任何時間,都會捨入至最接近的 5 秒基準。 例如 10 秒、15 秒。
      • 一分鐘到一小時之間的任何時間,都會捨入至最接近的 1/2 分鐘基準。 例如 30.5 分鐘、31分鐘
      • 一小時到一天之間的任何時間,都會捨入至最接近的四分之一小時基準。 例如 2.25 小時、3.5 小時
      • 大於一天的任何時間,都會捨入至最接近的天數基準。 例如 1 天、3 天、9 天
  • bml (選用,數字):根據 fmt 引數格式的捨入基準長度。 例如,如果 fmt 引數為 "s" 且此引數為 2,則傳回值會捨入至最接近的 2 秒基準。 如果 fmt 引數為 "m" 且此引數為 0.5,則傳回值會捨入至最接近的半分鐘基準。

  • rte (選用,字串):移除或刪除計時器的 Analytics 事件字串 (以逗號分隔)。 無預設值。

呼叫此函數會傳回一個整數,該整數代表啟動計時器事件和停止計時器事件之間的時間長度 (以所需格式表示)。

呼叫範例

// The timer starts or restarts when the events variable contains event1
// The timer stops and resets when the events variable contains event2
// The timer resets when the events variable contains event3 or the visitor closes their browser
// Sets eVar1 to the number of seconds between event1 and event2, rounded to the nearest 2-second benchmark
s.eVar1 = getTimeBetweenEvents("event1", true, "event2", true, "", 0, "s", 2, "event3");

// The timer starts when the events variable contains event1. It does NOT restart with subsequent hits that also contain event1
// The timer records a "lap" when the events variable contains event2. It does not stop the timer.
// The timer resets when the events variable contains event3 or if more than 20 days pass since the timer started
// The timer is stored in a cookie labeled "s_20"
// Sets eVar4 to the number of hours between event1 and event2, rounded to the nearest 90-minute benchmark
s.eVar4 = getTimeBetweenEvents("event1", false, "event2", false, "s_20", 20, "h", 1.5, "event3");

// Similar to the above timer in eVar4, except the return value is returned in seconds/minutes/hours/days depending on the timer length.
// The timer expires after 1 day.
s.eVar4 = getTimeBetweenEvents("event1", true, "event2", true);

版本記錄

3.0 (2021 年 3 月 19 日)

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

2.1 (2018 年 5 月 26 日)

  • 因應新版 formatTime 外掛程式的變更進行調整。

2.0 (2018 年 4 月 6 日)

  • 外掛程式全面重寫/重新分析。
自動翻譯
使用「語言選取器」檢視此頁面的英文版。
翻譯是否有幫助?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.