此插件由 Adobe Consulting 团队提供,旨在帮助您从 Adobe Analytics 中获取更多的价值。Adobe 客户关怀团队不提供对此插件的支持,包括安装或疑难解答。如果您需要关于此插件的帮助,请与您组织的 Adobe 客户团队联系。他们可为您安排与顾问会面以寻求帮助。
cleanStr
插件可删除或替换字符串中所有不必要的字符,包括 HTML 标记字符、额外的空格、制表符和换行符/回车符。它还会将左/右单引号替换为直单引号('
)。 如果您要从变量值中删除不必要的字符,并且Adobe Experience Platform数据收集中的“清理文本”功能无法满足您的实施需求,则Adobe建议使用此插件。 如果收集的数据不包含不必要的字符,或者Adobe Experience Platform数据收集中的“清理文本”功能足够,则无需使用此插件。
尚不支持在Web SDK中使用此插件。
Adobe提供了一个扩展,允许您将最常用的插件与Adobe Analytics一起使用。
如果您不想使用“常用Analytics插件”插件扩展,则可以使用自定义代码编辑器。
在实例化(使用 s_gi
)Analytics 跟踪对象后,将以下代码复制并粘贴到 AppMeasurement 文件中的任意位置。在您的实施中保留代码的注释和版本号可帮助 Adobe 对任何潜在问题进行疑难解答。
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: cleanStr v2.0 (No Prerequisites Required) */
function cleanStr(str){var a=str;if("-v"===a)return{plugin:"cleanStr",version:"2.0"};a:{if("undefined"!==typeof window.s_c_il){var b=0;for(var c;b<window.s_c_il.length;b++)if(c=window.s_c_il[b],c._c&&"s_c"===c._c){b=c;break a}}b=void 0}"undefined"!==typeof b&&(b.contextData.cleanStr="2.0");if("string"===typeof a){a=a.replace(/<\/?[^>]+(>|$)/g,"");a=a.trim();a=a.replace(/[\u2018\u2019\u201A]/g,"'");a=a.replace(/\t+/g,"");for(a=a.replace(/[\n\r]/g," ");-1<a.indexOf(" ");)a=a.replace(/\s\s/g," ");return a}return""}
/******************************************** END CODE TO DEPLOY ********************************************/
cleanStr
函数使用以下参数:
str
(必需,字符串):用于清理 HTML 编码、额外空格、制表符或其他不必要字符的值。该函数会返回 str
参数的值,并删除所有不必要的字符。
// Returns the value "this is a messystring". Note that both tabs and extra spaces are present in the original string.
// Multiple spaces are reduced to one, while tabs are omitted entirely.
s.eVar1 = " this is a messy string ";
s.eVar1 = cleanStr(s.eVar1)
// This function call does not do anything because the code does not assign the returned value to a variable.
s.eVar1 = " this is a messy string ";
cleanStr(s.eVar1);