使用 AppMeasurement 安装此插件

在实例化(使用 s_gi)Analytics 跟踪对象后,将以下代码复制并粘贴到 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.