Show Menu
TOPICS×

appendList

The apl (or appendList) plug-in lets you append a value to any delimited lists, with the option of a case-sensitive or case-insensitive check to ensure that the value does not already exist in the list. The APL plug-in is referenced by several standard plug-ins but can be used directly in a variety of situations.
This plug-in is useful for:
  • Adding an event to the current events variable
  • Adding a value to a list variable without duplicating a value in the list
  • Adding a product to the current products variable based on some page logic
  • Adding values to the parameters linkTrackVars and linkTrackEvents
Use Case 1
Scenario
Add event1 to the current events variable while ensuring the event isn't duplicated.
s.events="scCheckout"
Code
s.events=s.apl(s.events,"event1",",",1)
Results
s.events="scCheckout,event1"
Use Case 2
Scenario
Add the value history to the list variable prop1 , with history and History considered the same value.
s.prop1="Science,History"
Code
s.prop1=s.apl(s.prop1,"history",",",2)
Results
s.prop1="Science,History"
history is not added because History is already in the list.
The following instructions require you to alter the data collection code on your site. This can affect data collection on your site, and should only be done by a developer with experience using and implementing Analytics.

Implementation

Follow these steps to implement the APL plug-in.
  1. Request the plug-in code from Customer Care or your currently assigned Adobe consultant.
  2. Add call(s) to the API function as needed within the s_doPlugins function
Here is how the code might look on your site:
/* Plugin Config */ 
 
s.usePlugins=true 
 
function s_doPlugins(s) { 
 
/* Add calls to plugins here */ 
 
s.events=s.apl(s.events,"event1",",",1) 
 
} 
 
s.doPlugins=s_doPlugins

Supported Browsers
This plug-in requires that the browser supports JavaScript version 1.0.
Plug-in Information
Plug-in Information Description
Parameters
apl((L,v,d,u)
L= source list, empty list is accepted
v = value to append
d = list delimiter
u (optional, defaults to 0) Unique value check. 0=no unique check, value is always appended. 1=case-insensitive check, append only if value isn't in list. 2=case-sensitive check, append only if value isn't in list.
Return Value
original list, with appended value if added
Usage Examples
s.events=s.apl(s.events,"event1",",",1);
The source list L can be an empty list, such as L="" . The returned value will either be an empty list, or a list of one value.
Plug-in Code
/******************************************************************** 
 * 
 * Main Plug-in code (should be in Plug-ins section) 
 * 
 *******************************************************************/ 
/* 
 * Plugin Utility: apl v1.1 
 */ 
s.apl=new Function("l","v","d","u","" 
+"var s=this,m=0;if(!l)l='';if(u){var i,n,a=s.split(l,d);for(i=0;i<a." 
+"length;i++){n=a[i];m=m||(u==1?(n==v):(n.toLowerCase()==v.toLowerCas" 
+"e()));}}if(!m)l=l?l+d+v:v;return l"); 
 
/******************************************************************** 
 * 
 * Commented example of how to use this is doPlugins function 
 * 
 *******************************************************************/ 
  
 Not Applicable - Utility function only 
 
/******************************************************************** 
 * 
 * Config variables (should be above doPlugins section) 
 * 
 *******************************************************************/ 
 
 None 
 
/******************************************************************** 
 * 
 * Utility functions that may be shared between plug-ins (name only) 
 * 
 *******************************************************************/ 
  
 s.split