使用 AppMeasurement 安裝外掛程式

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

/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: inList v3.0 */
function inList(lv,vtc,d,cc){var b=lv,e=vtc,c=d,f=cc;if("-v"===b)return{plugin:"inList",version:"3.0"};a:{if("undefined"!==typeof window.s_c_il){var a=0;for(var d;a<window.s_c_il.length;a++)if(d=window.s_c_il[a],d._c&&"s_c"===d._c){a=d;break a}}a=void 0}"undefined"!==typeof a&&(a.contextData.inList="3.0");if("string"!==typeof e)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==f&&e===b[c]||e.toLowerCase()===b[c].toLowerCase())return!0;return!1};
/******************************************** END CODE TO DEPLOY ********************************************/

使用外掛程式

inList 函數會依據其輸入傳回布林值。 它會使用以下引數:

  • lv (必要,字串或陣列):要搜尋的分隔值清單或 JavaScript 陣列物件
  • vtc (必要,字串):要搜尋的值
  • d (選用,字串):用於分隔 lv 引數中個別值的分隔字元。 若未設定,則預設為逗號 (,)。
  • cc (選用,布林值):如果設為 true 或 1,則會進行區分大小寫的檢查。 如果設為 false 或省略,則會進行不區分大小寫的檢查。 預設為 false。

如果找到相符項目,呼叫此函數會傳回 true,若找不到相符項目則會傳回 false。

範例

// Returns true
s.events = "event22,event24";
if(inList(s.events,"event22")) {
    // Code will execute
}

// Returns false because event2 is not an exact match in the string
s.events = "event22,event24";
if(inList(s.events,"event2")) {
    // Code will not execute
}

// Returns true because of the NOT operator
s.events = "event22,event24";
if(!inList(s.events,"event23")) {
    // Code will execute
}

// Returns false because of the case-sensitive check
s.events = "event22,event23";
if(inList(s.events,"EVenT23","",true)) {
    // Code will not execute
}

// Returns false because of a mismatched delimiter, treating "events,eVar1" as a single value
s.linkTrackVars = "events,eVar1";
if(inList(s.linkTrackVars,"eVar1","|")) {
    // Code will not execute
}

版本記錄

3.0 (2021 年 3 月 19 日)

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

v2.1 (2019 年 9 月 26 日)

  • 新增非布林值的 cc 引數選項。 例如,1 是有效的大小寫檢查值。

v2.0 (2018 年 4 月 17 日)

  • 修補版本 (重新編譯,程式碼大小較小)。

v1.01 (2017 年 9 月 27 日)

  • 最佳化程式碼以縮小大小

v1.0 (2009 年)

  • 首次發行。
自動翻譯
使用「語言選取器」檢視此頁面的英文版。
翻譯是否有幫助?

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.