This plug-in is provided by Adobe Consulting as a courtesy to help you get more value out of Adobe Analytics. Adobe Customer Care does not provide support with this plug-in, including installation or troubleshooting. If you require help with this plug-in, contact your organization’s Account Manager. They can arrange a meeting with a consultant for assistance.
The inList
plug-in allows you to check if a value already exists within either a delimited string or a JavaScript array object. Several other plug-ins depend on the inList
plug-in to work. This plug-in provides a distinct advantage over the JavaScript method indexOf()
where you it does not match partial strings. For example, if you used this plug-in to check for "event2"
, it won’t match with a string containing "event25"
. This plug-in is not necessary if you don’t need to check for values in delimited strings or arrays, or if you want to use your own indexOf()
logic.
Adobe offers an extension that allows you to use most commonly-used plug-ins.
If you do not want to use the plug-in extension, you can use the custom code editor.
Copy and paste the following code anywhere in the AppMeasurement file after the Analytics tracking object is instantiated (using s_gi
). Preserving comments and version numbers of the code in your implementation helps Adobe with troubleshooting any potential issues.
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: inList v2.1 */
s.inList=function(lv,vtc,d,cc){if("string"!==typeof vtc)return!1;if("string"===typeof lv)lv=lv.split(d||",");else if("object"!== typeof lv)return!1;d=0;for(var e=lv.length;d<e;d++)if(1==cc&&vtc===lv[d]||vtc.toLowerCase()===lv[d].toLowerCase())return!0;return!1};
/******************************************** END CODE TO DEPLOY ********************************************/
The inList
method uses the following arguments:
lv
(required, string or array): A delimited list of values or a JavaScript array object to searchvtc
(required, string): The value to search ford
(optional, string): The delimiter used to separate individual values in the lv
argument. Defaults to a comma (,
) when not set.cc
(optional, boolean): If set to true
, a case-sensitive check is made. If set to false
or omitted, then a case-insensitive check is made. Defaults to false
.Calling this method returns true
if it finds a match, and false
if it does not find a match.
If…
s.events="event22,event24";
…and the following code runs…
if(s.inList(s.events,"event22"))
…the conditional if statement will be true
If…
s.events="event22,event24";
…and the following code runs…
if(s.inList(s.events,"event2"))
…the conditional if statement will be false because the inList call did not make an exact match between event2 and either of the delimited-values in s.events
If…
s.events="event22,event24";
…and the following code runs…
if(!s.inList(s.events,"event23"))
…the conditional if statement will be true because the inList call did not make an exact match between event23 and either of the delimited-values in s.events (notice the “NOT” operator at the beginning of the inList variable call).
If…
s.events = "event22,event23";
…and the following code runs…
if(s.inList(s.events,"EVenT23","",1))
…the conditional if statement will be false. Although this example isn’t practical, it demonstrates the need to use caution when using the case sensitive flag.
If…
s.linkTrackVars = "events,eVar1";
…and the following code runs…
if(s.inList(s.linkTrackVars,"eVar1","|"))
…the conditional if statement will be false. The value of the d argument passed into the call (i.e. “|”) assumes that the individual values in s.linkTrackVars are delimited by a pipe character, whereas in reality, the values are delimited by a comma. In this case, the plug-in will try to make a match between the whole value of s.linkTrackVars (i.e. “events,eVar1”) and the value to look for (i.e. “eVar1”).
cc
argument to not be a boolean. For example, 1
is a valid case check value.