includesNone β GTM Variable Template for Array
includesNone CORE Array
Checks if none of the specified terms are found in the source array or string.
When to Use This
Section titled βWhen to Use ThisβArray Processing
Iterate, filter, map, and reshape arrays of items for batch data operations.
Comparison
Test equality, containment, and ordering between values.
Examples
Section titled βExamplesβNo terms found
INPUT
Source Content: The quick brown fox jumps over the lazy dog
Search Terms: ["cat", "mouse", "bird"]
Search Terms: ["cat", "mouse", "bird"]
OUTPUT
true
Term found returns false
INPUT
Source Content: The quick brown fox jumps over the lazy dog
Search Terms: ["cat", "fox", "bird"]
Search Terms: ["cat", "fox", "bird"]
OUTPUT
false
Live Sandbox
Section titled βLive SandboxβThis is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
includesNone
Source Content
πΎ The value to search within.
Supported formats:
β String: "hello world"
β Array: ["a", "b", "c"]
β Comma-separated string: "a,b,c"
β JSON-stringified array or object: '["a","b"]'
Supported formats:
β String: "hello world"
β Array: ["a", "b", "c"]
β Comma-separated string: "a,b,c"
β JSON-stringified array or object: '["a","b"]'
Search Terms
π Search terms (one or more) to find within the data.
Supported formats:
β String: "hello world"
β Array: ["a", "b", "c"]
β Comma-separated string: "a,b,c"
Supported formats:
β String: "hello world"
β Array: ["a", "b", "c"]
β Comma-separated string: "a,b,c"
Input Setup
Input Function (optional)
βοΈ Optional pre-processing function applied to the input before internal logic (e.g., convert object to string, normalize case). Internal transformations such as case handling will still apply afterward.
Result Handling
Output Function (optional)
βοΈ Optional function to apply to the result before returning it (e.g., str => str + ' β¬', val => val !== undefined for boolean conversion). Useful for chaining transformations on the output.
Source Content array
π‘ Type any text to see the result update live
π― Using special value β click input to type instead
Test with:
Falsy
Truthy
Search Terms array
π Result Handling β Chain Variables
Chain apply-mode variables to the output. Each variable receives the result of the previous one.
includesNone()
Related Variables
Section titled βRelated VariablesβSame category: Array
Under the Hood
Section titled βUnder the Hoodβπ View Implementation Code
/** * Checks if the source contains **none** of the provided search terms. * * @param {*} data.src - The data to search within (string, number, object, etc.). * @param {Array<string>|string} data.tms - Term, array or comma-separated string of terms to search for. * @param {string|Function} [data.out] - Output handler: function to transform result or string with format. * * Direct-mode specific parameters: * @param {Function} [data.pre] - Optional function to transform `src` before searching. * * @returns {boolean} True if none of the terms are found, false otherwise. * * @framework ggLowCodeGTMKit */const includesNone = function(searchData, searchTerms) { if (searchData == null || searchTerms == null) { return false; } const searchString = searchData.toString(); const safeSplit = value => typeof value === 'string' ? value.split(',') : value; searchTerms = safeSplit(searchTerms); return searchTerms.every(term => term != null && searchString.indexOf(term) === -1);};const safeFunction = fn => typeof fn === 'function' ? fn : x => x;const out = safeFunction(data.out);// ===============================================================================// includesNone - Direct mode// ===============================================================================const applyCast = (castFn, value) => safeFunction(castFn)(value);const searchData = applyCast(data.pre, data.src);return out(includesNone(searchData, data.tms));
// ===============================================================================// includesNone(...) β Apply Mode// ===============================================================================/* return function(searchData, searchTerms) { searchTerms = data.rp1 ? searchTerms : data.tms; return out(includesNone(searchData, searchTerms));};*/π§ͺ View Test Scenarios (10 tests)
β
'[example] No terms found'β
'[example] Term found returns false'β
String with all matching terms - should return falseβ
Comma-separated terms with no matches - should return trueβ
Null source - should return falseβ
Null terms - should return falseβ
Number source with no matching terms - should return trueβ
Number source with matching terms - should return falseβ
Empty string with search terms - should return trueβ
JSON string with no matching terms - should return true