Kameleoon.API object, pass commands and functions to the kameleoonQueue object. The engine executes these commands immediately if loaded; otherwise, it queues them for execution when 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, no further action is required. 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 (e.g.,
Kameleoon.API.Core.enableLegalConsent) or the short name (e.g., Core.enableLegalConsent). Additional arguments are optional.kameleoonQueue before the browser encounters the targeted HTML element to ensure click tracking, even if the engine has not loaded.
By default, Kameleoon executes queued commands when the configuration (campaigns, goals, segments, etc.) 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 is useful for code required 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.