使用 AppMeasurement 安裝外掛程式

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");

版本記錄

4.0 (2021 年 3 月 19 日)

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

3.2 (2019 年 9 月 25 日)

  • 修正與 apl 呼叫之間的相容性問題,該呼叫使用舊版外掛程式
  • 移除主控台警告以縮減大小
  • 新增 inList 2.1

3.1 (2018 年 4 月 22 日)

  • 如果 d2 引數未設定,其預設值現在為 d1 引數的值

3.0 (2018 年 4 月 16 日)

  • 外掛程式全面重新分析/重寫
  • 新增進階錯誤檢查
  • vta 引數現在能一次接受多個值
  • 新增 d2 引數以將傳回值格式化
  • 將 cc 引數變更為布林值

2.5(2016 年 2 月 18 日)

  • 現在會使用 inList 函數來處理比較作業

2.0(2016 年 1 月 26 日)

  • d (分隔字元) 引數現在為選用項目 (預設值為逗號)
  • u (區分大小寫標幟) 引數現在為選用項目 (預設值為不區分大小寫)
  • 不論 u (區分大小寫標幟) 引數為何,如果值已存在於清單中,外掛程式就不會再將值附加至清單
自動翻譯
使用「語言選取器」檢視此頁面的英文版。
翻譯是否有幫助?

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.