此外掛程式由 Adobe Consulting 提供,協助您從 Adobe Analytics 中獲得更多價值。Adobe 客戶服務不提供此外掛程式的支援,包括安裝或疑難排解在內。如果您需要與此外掛程式有關的協助,請聯絡貴組織的 Adobe 客戶團隊。他們可幫您安排顧問會議,以尋求協助。
apl
外掛程式可讓您安全地將新值新增至以清單分隔的變數,如 events
、linkTrackVars
、list
等。
如果您想要將新值新增至現有變數,而且該變數包含由分隔值組成的字串,Adobe 建議您使用此外掛程式。如果您偏好將包含分隔值之變數的字串串連起來,則不需要使用此外掛程式。
Web SDK尚不支援此外掛程式。
Adobe提供的擴充功能可讓您搭配Adobe Analytics使用最常用的外掛程式。
如果您不想使用常見Analytics外掛程式擴充功能,可以使用自訂程式碼編輯器。
Analytics 追蹤物件實例化 (使用 s_gi
) 後,將下列程式碼複製並貼到 AppMeasurement 檔案中的任何位置。保留您實作中的程式碼備註和版本號碼,有助於 Adobe 疑難排解任何可能問題。
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: apl (appendToList) v4.0 */
function apl(lv,va,d1,d2,cc){var b=lv,d=va,e=d1,c=d2,g=cc;if("-v"===b)return{plugin:"apl",version:"4.0"};var h=function(){if("undefined"!==typeof window.s_c_il)for(var k=0,b;k<window.s_c_il.length;k++)if(b=window.s_c_il[k],b._c&&"s_c"===b._c)return b}();"undefined"!==typeof h&&(h.contextData.apl="4.0");window.inList=window.inList||function(b,d,c,e){if("string"!==typeof d)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==e&&d===b[c]||d.toLowerCase()===b[c].toLowerCase())return!0;return!1};if(!b||"string"===typeof b){if("string"!==typeof d||""===d)return b;e=e||",";c=c||e;1==c&&(c=e,g||(g=1));2==c&&1!=g&&(c=e);d=d.split(",");h=d.length;for(var f=0;f<h;f++)window.inList(b,d[f],e,g)||(b=b?b+c+d[f]:d[f])}return b};
/******************************************** END CODE TO DEPLOY ********************************************/
apl
函數會使用以下引數:
lv
(必要,字串):為變數,其中包含要新增新值的目的地項目分隔清單vta
(必要,字串):為逗號分隔的新值清單,可新增至 lv
引數的值。d1
(可選,字串):用來分隔各個值的分隔字元已包含在 lv
引數中。若未設定,則預設為逗號 (,
)。d2
(可選,字串):輸出分隔字元。若未設定,預設值與 d1
相同。cc
(可選,布林):指出是否使用區分大小寫檢查的標幟。如果是 true
,複製檢查會區分大小寫。如果是 false
或未設定,複製檢查將不區分大小寫。預設為 false
。apl
函數會傳回 lv
引數的值,再加上 vta
引數中任何非重複的值。
// Set the events variable to "event22,event24,event23".
s.events = "event22,event24";
s.events = apl(s.events,"event23");
// The events variable remains unchanged because the apl function does not add duplicate values
s.events = "event22,event23";
s.events = apl(s.events,"event23");
// Set the events variable to "event23" if the events variable is blank
s.events = "";
s.events = apl(s.events,"event23");
// Append a value to eVar5. The value of prop4 remains unchanged.
// The value of eVar5 is "hello|people|today".
s.prop4 = "hello|people";
s.eVar5 = apl(s.prop4, "today", "|");
// Sets prop4 to "hello|people,today". Be mindful of correct delimiters!
s.prop4 = "hello|people";
s.prop4 = apl(s.prop4, "today");
// Sets the events variable to "event22,event23,EVentT23". Be mindful of capitalization when using the cc argument!
s.events = "event22,event23";
s.events = apl(s.events,"EVenT23", ",", ",", true);
// Sets the events variable to "event22,event23,event24,event25".
s.events = "event22,event23";
s.events = apl(s.events, "event23,event24,event25");
// Sets linkTrackVars to "events,eVar1,campaign".
// The last three arguments at the end of this apl call are not necessary because they match the default argument values.
s.linkTrackVars = "events,eVar1";
s.linkTrackVars = apl(s.linkTrackVars, "campaign", ",", ",", false);
// This apl call does not do anything because the code does not assign the returned value to a variable.
s.events = "event22,event24";
apl(s.events, "event23");
// Sets the list2 variable to "apple-APPLE-Apple".
// Since the two delimiter arguments are different, the value passed in is delimited by "|", then joined together by "-".
s.list2 = "apple|APPLE";
s.list2 = apl(s.list2, "Apple", "|", "-", true);
// Sets the list3 variable to "value1,value1,value1" (unchanged).
// Only new values are deduplicated. Existing duplicate values remain.
s.list3 = "value1,value1,value1";
s.list3 = apl(s.list3,"value1");
apl
呼叫之間的相容性問題,該呼叫使用舊版外掛程式inList 2.1
d2
引數未設定,其預設值現在為 d1
引數的值vta
引數現在能一次接受多個值d2
引數以將傳回值格式化cc
引數變更為布林值inList
函數來處理比較作業d
(分隔字元) 引數現在為選用項目 (預設值為逗號)u
(區分大小寫標幟) 引數現在為選用項目 (預設值為不區分大小寫)u
(區分大小寫標幟) 引數為何,如果值已存在於清單中,外掛程式就不會再將值附加至清單