Kameleoon.API object, pass commands and functions to the kameleoonQueue object. If the engine has loaded, it executes these commands immediately. Otherwise, it queues them for execution when it’s ready.
Usage and description of the command queue object
To use thekameleoonQueue object, execute the following initialization code first. The Kameleoon installation tag typically includes this code at the top of the HTML file, after the opening <head> tag. In this case, you don’t need to take any further action. However, if using a custom setup (for example, loading Kameleoon via a Tag Manager), initialize the queue before adding custom code.
kameleoonQueue acts as a standard JavaScript array that accepts commands via the push() method. After loading, the engine processes the array and executes commands in order. The engine then replaces the array with a custom object whose push() method executes commands immediately.
Syntax
Pass either an array or an anonymous function to thepush() method.
Use either the full method name (for example,
Kameleoon.API.Core.enableLegalConsent) or the short name (for example, Core.enableLegalConsent). Additional arguments are optional.kameleoonQueue before the browser encounters the targeted HTML element to ensure click tracking, even if the engine hasn’t loaded.
By default, Kameleoon executes queued commands when the configuration (campaigns, goals, segments, and so on) is ready and after the global custom script runs.Use the In this example, the
level: "IMMEDIATE" argument when pushing a command to execute it immediately, without waiting for configuration processing. This option is useful for code that must run before Kameleoon instantiates functions.Here’s an example of how to use the level: "IMMEDIATE" argument:callback function executes immediately, regardless of configuration processing.Use the level: "IMMEDIATE" argument to override internal Kameleoon functions. Standard function redefinition fails if the engine loads and executes the original version first. The IMMEDIATE level ensures the custom function executes before the engine loads its own version.