このプラグインはアドビコンサルティングによって提供されており、Adobe Analytics からより多くの価値を引き出すのに役立ちます。アドビカスタマーケアは、インストールやトラブルシューティングを含め、このプラグインに対するサポートを行いません。このプラグインに関するヘルプが必要な場合は、組織のアドビアカウントチームにお問い合わせください。担当コンサルタントとのミーティングを手配してもらってください。
apl
プラグインを使用すると、リスト区切りの変数(例:events
、linkTrackVars
、list
)に新しい値を安全に追加できます。
区切り文字付きの値の文字列を含む既存の変数に新しい値を追加する場合は、このプラグインを使用することをお勧めします。区切り文字付きの値を含む変数に文字列を連結する場合は、このプラグインは不要です。
このプラグインは、Web SDK 内での使用はまだサポートされていません。
Adobeには、Adobe Analyticsで最もよく使用されるプラグインを使用できる拡張機能が用意されています。
Common Analytics Plugins プラグイン拡張機能を使用しない場合は、カスタムコードエディターを使用できます。
Analytics トラッキングオブジェクトをインスタンス化(s_gi
を使用)した後、AppMeasurement ファイルの任意の場所に次のコードをコピーして貼り付けます。実装時のコードのコメントとバージョン番号を記録しておくと、アドビが潜在的な問題のトラブルシューティングを行う際に役立ちます。
/******************************************* 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
(大文字と小文字の区別のフラグ)引数に関係なく、プラグインは、値がリストに既に存在する場合に、値をリストに追加しなくなりました。