Skip to main content

Kameleoon.API.Core

Dieses Modul enthält Funktionen für die Implementierung von Frontend-A/B-Test-Variationen ohne Flackern. Verwenden Sie diese Methoden in der vorgeschriebenen Reihenfolge für optimale Ergebnisse. Das Modul umfasst auch Methoden zur Engine-Initialisierung, einschließlich derjenigen für Datenschutzgesetze und die Erfassung der rechtlichen Einwilligung. Bevor Sie aufrufen das JavaScript-Objekt der Activation API, stellen Sie sicher, dass die Kameleoon-Engine geladen wurde. Verwenden Sie die Kameleoon Command Queue für die verzögerte Befehlsausführung, wenn Sie Tracking-Daten senden, Experimente auslösen oder Besucherattribute aktualisieren. Wenn die Engine geladen ist, werden übergebene Befehle und Funktionen sofort ausgeführt; andernfalls werden sie für die spätere Ausführung in eine Warteschlange gestellt. Weitere Informationen finden Sie im Command queue Dokumentation.

enableLegalConsent

Rufen Sie die enableLegalConsent() method nachdem Sie die rechtliche Einwilligung des Besuchers zur Aktivierung von Kameleoon erhalten haben. Diese Methode aktiviert den normalen Betriebsmodus von Kameleoon. Weitere Informationen finden Sie im Consent management Artikel.
Arguments
A custom option is also available that allows separate management of Product Recommendation consent. Wenn this option is active, explicitly call enableLegalConsent("PRODUCT_RECOMMENDATION") to activate the module. Contact the Customer Success Manager to enable this feature.

disableLegalConsent

Rufen Sie die disableLegalConsent() method wenn a visitor declines the use of Kameleoon. Diese Methode disables normal operation mode. Weitere Informationen finden Sie im Consent management article.
Arguments
A custom option is also available that allows separate management of Product Recommendation consent. Wenn this option is active, explicitly call disableLegalConsent("PRODUCT_RECOMMENDATION") to disable the module. Contact the Customer Success Manager to enable this feature.

enableSinglePageSupport

The enableSinglePageSupport() method reloads die Kameleoon-Engine wenn the active URL changes, regardless of browser page loads. Verwenden Sie diese Methode for Single Page Applications (SPAs) with multiple URLs and a single initial load. Kameleoon treats each URL change as a new page, enabling URL targeting and accurate tracking of metrics like page views.
Kameleoon will also automatically remove all elements that have been added on die Seite that use HTML IDs that begin with “kameleoonElement” or “kameleoonStyleSheet” wenn the SPA reloads.

enableDynamicRefresh

The enableDynamicRefresh() method detects element changes and reapplies Graphic Editor modifications. Diese Methode supports SPAs that dynamically modify the DOM without URL changes or page reloads, preventing dynamic updates from removing experiments. Siehe enableSinglePageSupport() for other SPA types.

getConfiguration

The getConfiguration() method gibt ein reference to the Configuration object, which contains global constant values for the site’s Kameleoon configuration.
Rückgabewert

load

The load() method initializes die Kameleoon-Engine. While initialization typically occurs automatically during application file loading, you might need to make manual calls. The example demonstrates how to implement reloads after each URL change, similar to enableSinglePageSupport().
Kameleoon will also automatically remove all elements that have been added on die Seite that use HTML IDs that begin with “kameleoonElement” or “kameleoonStyleSheet” wenn the SPA reloads.

processRedirect

The processRedirect() method redirects the browser to another URL, typically for split A/B experiments. Verwenden Sie diese Methode anstelle von window.location.href = redirectionURL; to ensure accurate background tracking.
Wenn das redirection URL is on a domain other than the base URL and the Kameleoon installation omits unified session data, die Engine adds a kameleoonRedirect-{experimentID} parameter to the target URL to ensure accurate tracking.
Arguments

runWhenConditionTrue

The runWhenConditionTrue() method executes the callback function wenn the conditionFunction gibt zurück true. Die Methode uses a polling mechanism, which might cause flickering. Use runWhenElementPresent() instead for improved performance. Siehe the runWhenElementPresent() description for details.
Arguments

runWhenElementPresent

The runWhenElementPresent() method executes the callback function wenn a specific element appears in the DOM. Diese Methode uses mutation observers to power antiflickering technology. Identify the key elements for eine Variation and call runWhenElementPresent() with the element as the first argument and the implementation code as the callback. This ensures that modifications execute as soon as the element appears, before the browser initiates a display refresh cycle. To act on multiple elements, call runWhenElementPresent() separately for each element rather than targeting only the expected final element. A single call may result in flickering if a refresh cycle occurs between the appearance of different elements.
Providing this value disables Mutation Observers and Anti-Flickering, reverting to legacy polling. Use this argument only in specific cases, wie etwa complex selector queries with high CPU impact.
Arguments

runWhenShadowRootElementPresent

The runWhenShadowRootElementPresent() method executes the callback function wenn a specific element appears in a shadow DOM set to mode: open.

Arguments

Kameleoon.API.Goals

This module manages goal triggering and conversion data, including purchase confirmations and revenue registration.

cancelConversion

The cancelConversion() method cancels a conversion that you ausgelöst during the current visit. Diese Methode cannot cancel conversions from previous visits.
Arguments

processConversion

Before implementing the processConversion, review the Custom Code for Custom Goal feature, which simplifies customization by removing the requirement for ein Ziel ID.
The processConversion() method löst aus a conversion. Metadata must be configured in the Kameleoon App before setting them with processConversion().
Wenn Sie initiate conversions from a Tag Management System, wie etwa Google Tag Manager, use the Kameleoon Command Queue to delay execution until die Engine loads. The engine processes queued commands in order after initialization. Example:
Arguments
Metadata values are accessible through raw data exports and the results page.Wenn Sie provide the metadata parameter, Kameleoon uses those values für den conversion anstelle von the values you previously collected through setCustomData(). Wenn Sie omit the parameter, Kameleoon uses the last tracked customData values before the conversion in the same visit.Kameleoon only considers the metadata values you pass directly to the processConversion() method; it ignores previously set custom data. In the following example, the conversion associates only with the provided metadata (for example, index 5 with ‘Amex Credit Card’).

triggerGoal (Custom Code for Custom Goal)

To trigger custom goals, inject custom code by creating a new goal and adding the code to the Trigger my goal panel.
The triggerGoal() function löst aus das Ziel von der code panel without requiring ein Ziel ID.
Arguments
Metadata values are accessible through raw data exports and the results page.Wenn Sie provide the metadata parameter, Kameleoon uses those values für den conversion anstelle von the values you previously collected through setCustomData(). Wenn Sie omit the parameter, Kameleoon uses the last tracked customData values before the conversion in the same visit.Kameleoon only considers the metadata values you pass directly to the triggerGoal() method; it ignores previously set custom data. In the following example, the conversion associates only with the provided metadata (for example, index 5 with ‘Amex Credit Card’).

Kameleoon.API.Data

This module provides methods to set custom data for tracking customer or visit characteristics. It also includes data management methods to retrieve and write data in Kameleoon’s unified LocalStorage.

readLocalData

The readLocalData() method reads local data you previously stored through writeLocalData(). The engine retrieves this data from unified Local Storage, which bypasses standard storage limitations.
Arguments
Rückgabewert

performRemoteSynchronization

The performRemoteSynchronization() method löst aus a Server Synchronization Call (SSC) to the Data API. This call retrieves visit history stored on Kameleoon backend servers for der aktuelle Besucher and writes it to LocalStorage. This ensures that the data is accessible through the Activation API and available for targeting. Diese Methode typically runs automatically for cross-device reconciliation or Safari ITP; it does not require manual invocation.
Arguments

resetCustomData

The resetCustomData() method resets a custom data value.
Arguments

retrieveDataFromRemoteSource

The retrieveDataFromRemoteSource() method retrieves data stored on a remote Kameleoon server with the specified key. Diese Methode supports retrieving data previously stored through the Data API. Use this for quick storage and retrieval of large data volumes for visitors. This asynchronous mechanism requires a callback function wenn the server call completes.
Arguments

setCustomData

The setCustomData() method sets a custom data value.
Arguments

writeLocalData

The writeLocalData() method records local data in der Besucher’s browser for later retrieval through readLocalData(). The engine stores this as unified session data in Local Storage, bypassing standard storage limitations. Data becomes available immediately for retrieval in the same tab through RAM caching, while the physical write occurs asynchronously.
Arguments

Kameleoon.API.Events

This module löst aus custom events for experiment and personalization targeting. Review the Activation API events documentation for standard DOM events.

trigger

The trigger() method löst aus a custom event for targeting segments.
Arguments

Kameleoon.API.Tracking

This module integrates Kameleoon results with third-party tracking and analytics platforms, wie etwa Adobe Analytics (Omniture).

processOmniture

Kameleoon provides a native integration with Adobe Analytics (Omniture). Follow the example to modify the file containing the s_doPlugins() code. Complete these steps within the function:
  • Add a call to Kameleoon.API.Tracking.processOmniture().
  • Set the window.kameleoonOmnitureCallSent global variable to true to track initial call transmission. Although you can set this variable elsewhere, you should set it within s_doPlugins().
The integration minimizes the number of Adobe Analytics hits to help you manage costs. Kameleoon sends an additional hit only if ein Experiment or personalization löst aus after the main tracking call. This results from asynchronous loading (in which Kameleoon loads after the analytics code) or “late” triggers, wie etwa those that occur after page load, for example button clicks. If Kameleoon loads first and identifies active experiments at page load, the global tracking call includes all additional data.
Arguments

Kameleoon.API.Products

This module provides access to the product catalog. Use it to register product views or purchases, add products to a cart, retrieve recommendations, or obtain product statistics, wie etwa hourly or daily view and purchase counts.
This module verfügbar ist wenn subscribed to the Product Recommendation module or Product Targeting add-on.

obtainRecommendedProducts

The obtainRecommendedProducts() method retrieves recommended products computed by the specified algorithm through an asynchronous server call.
Diese Methode requires correct product tracking, wie trackProductView() or trackCategoryView(), to return meaningful results.
Arguments

Parameters to control the data returned by the recommendation platform

API response

The callback function receives the API response object with the following values.

trackAddToCart

The trackAddToCart() method löst aus wenn a visitor adds a product to the shopping cart.
Arguments

Parameters for the recommendation platform

trackAddToWishList

The trackAddToWishList() method executes wenn a visitor adds or removes a product von der wish list or favorites.

trackCategoryView

The trackCategoryView() method executes for each category page view during a session.
Arguments

trackProductView

The trackProductView() method executes for each product view during a session. Diese Methode allows Kameleoon to build an automated product catalog without an XML feed integration, which simplifies the setup of product recommendation projects.
Arguments

trackSearchQuery

The trackSearchQuery() method records user search queries.
Arguments

trackTransaction

The trackTransaction() method executes wenn a transaction or purchase occurs.
Arguments
Additional parameters for trackTransaction

obtainInstantSearchProducts

The obtainInstantSearchProducts() method retrieves personalized instant search results from Kameleoon Search through an asynchronous server call.
Arguments

API response

The callback function receives the API response object with the following values.

obtainFullSearchProducts

Verwenden Sie den obtainFullSearchProducts() method to retrieve full search results von der Kameleoon Search solution with filtering options.
Arguments
Parameters to filter results

API response

The callback function receives the API response object with the following values.

obtainProductInteractions

The obtainProductInteractions() method retrieves interaction metrics for products tracked via trackProductView(), trackTransaction(), or trackAddToCart().
Arguments
API Response

obtainProductData

The obtainProductData() method retrieves product information for items sent via trackProductView().
Arguments
API Response

obtainRecommendedCollections

The obtainRecommendedCollections() method retrieves products von der specified collection.
Arguments

API response

Products
API gibt ein array of objects. Each object in the products array contains the following:

Kameleoon.API.Experiments

This module provides methods to access live experiments.
This module is only available with Kameleoon Web Experimentation solution.

assignVariation

The assignVariation() method forces the association of a specific variation for ein Experiment, which overrides the standard allocation algorithm. Wenn Sie call this before das Experiment triggers, die Engine pre-allocates die Variation for later activation. If das Experiment has already triggered, set the override argument to true to replace the existing association.
Arguments

block

The block() method prevents ein Experiment from triggering or activating, including manual calls through trigger(). The block applies to the current page by default until the next Kameleoon.API.Core.load(). Set the visit argument to true to block das Experiment for the entire visit.
Arguments

getAll

The getAll() method gibt zurück all live experiments (running, not draft/paused/stopped).
Rückgabewert

getActive

The getActive() method gibt zurück active experiments für den visit and page. An experiment is active if its variation code has executed in the current session context. To retrieve experiments that you activated on other URLs during the visit, use getActivatedInVisit().
Rückgabewert

getById

The getById() method gibt zurück das Experiment for the specified ID.
Arguments
Rückgabewert

getByName

The getByName() method gibt zurück das Experiment for the specified name.
Arguments
Rückgabewert

getTriggeredInVisit

The getTriggeredInVisit() method gibt zurück all experiments ausgelöst during the current visit.
Rückgabewert

getActivatedInVisit

The getActivatedInVisit() method gibt zurück all experiments activated during the current visit.
Rückgabewert

trigger

The trigger() method forces ein Experiment to trigger, bypassing targeting segment conditions. This action initiates das Experiment but might not activate it.
Arguments

Kameleoon.API.Personalizations

This module provides methods to access live personalizations.

disable

The disable() method marks eine Personalisierung as disabled. Use this for interactive elements like pop-ins. Wenn a user closes the element, call disable() to update die Personalisierung status. Kameleoon automatically implements this call for native, non-custom interface elements.
Arguments

getActive

The getActive() method gibt zurück active personalizations für den visit and page. A personalization is active if its variation code has executed and the associated action remains visible. To retrieve personalizations that ausgelöst on other URLs or that are now closed, wie etwa pop-ins, use getTriggeredInVisit().
Rückgabewert

getAll

The getAll() method gibt zurück all live personalizations (running, not draft/paused/stopped).
Rückgabewert

getById

The getById() method gibt zurück die Personalisierung for the specified ID.
Arguments
Rückgabewert

getByName

The getByName() method gibt zurück die Personalisierung for the specified name.
Arguments
Rückgabewert

getTriggeredInVisit

The getTriggeredInVisit() method gibt zurück all personalizations ausgelöst during the current visit.
Rückgabewert

getActivatedInVisit

The getActivatedInVisit() method gibt zurück all personalizations activated during the current visit.
Rückgabewert

trigger

The trigger() method forces eine Personalisierung to trigger, bypassing targeting segment conditions. This action initiates die Personalisierung but might not activate it.
Arguments

Kameleoon.API.Variations

This module provides methods to manage variations.

execute

The execute() method executes JavaScript and applies CSS for the specified variation ID.

Kameleoon.API.Segments

This module provides methods to manage segments and targeting.

getAll

The getAll() method gibt zurück all live segments, including those verknüpft mit experiments, personalizations, or Audience tracking.
Rückgabewert

getById

The getById() method gibt zurück das Segment for the specified ID.
Arguments
Rückgabewert

getByName

The getByName() method gibt zurück das Segment for the specified name.
Arguments
Rückgabewert

reevaluate

The reevaluate() method forces an immediate re-evaluation of the Targeting-Bedingungen for the specified segment. Evaluation typically occurs at page load, resulting in statuses of true, false, or undefined. Diese Methode restarts the evaluation process as if die Engine just initialized.
Arguments

trigger

The trigger() method forces ein Segment trigger for der aktuelle Besucher and bypasses Targeting-Bedingungen.
Arguments

Kameleoon.API.Triggers

This module provides methods to manage löst aus and targeting.

getAll

The getAll() method gibt zurück all live triggers, including those verknüpft mit experiments, personalizations, or Audience tracking.
Rückgabewert

getById

The getById() method gibt den trigger for the specified ID.
Arguments
Rückgabewert

getByName

The getByName() method gibt den trigger for the specified name.
Arguments
Rückgabewert

reevaluate

The reevaluate() method forces an immediate re-evaluation of the Targeting-Bedingungen for the specified trigger. Evaluation typically occurs at page load, resulting in statuses of true, false, or undefined. Diese Methode restarts the evaluation process as if die Engine just initialized.
Arguments

trigger

The trigger() method forces a trigger to fire for der aktuelle Besucher and bypasses Targeting-Bedingungen.
Arguments

Kameleoon.API.Utils

This module provides utility methods for common operations.

addEventListener

The addEventListener() method attaches ein Ereignis handler to the specified element.
Kameleoon resets all event listeners created via this API during engine reloads. Verwenden Sie diese Methode to add listeners in SPAs to ensure proper cleanup.
Arguments

addUniversalClickListener

The addUniversalClickListener() method attaches a click handler that listens for mouse clicks on desktop and touchdown events on mobile devices and tablets. For mobile devices, a touchdown occurs if die Engine detects a touchstart event followed by a touchend event without an intermediate touchmove.
Kameleoon resets all listeners created via this API during engine reloads, facilitating cleanup in SPAs.
On desktop devices, right-clicks trigger this method (e.g., wenn opening a link in a new tab).
Arguments

clearInterval

The clearInterval() method clears a timer you set through setInterval().
Arguments

clearTimeout

The clearTimeout() method clears a timer you set through setTimeout().
Arguments

computeHash

The computeHash() method computes a hash from a string. Use this to process unique data without manipulating sensitive personal information directly.
Arguments
Rückgabewert

getURLParameters

The getURLParameters() method parses the current URL and gibt zurück all detected parameters. Diese Methode supports both search (?) and hash (#) parameters.
Rückgabewert

performRequest

The performRequest() method initiates a call to a remote web server.
Arguments

querySelectorAll

The querySelectorAll() method gibt zurück all document elements matching the specified CSS selectors as a static NodeList object.
Diese Methode supports selectors with :contains and :eq.
Arguments
Rückgabewert

setInterval

The setInterval() method executes a function or expression at the specified interval in milliseconds. Kameleoon resets all intervals created via this API during engine reloads. Verwenden Sie diese Methode in SPAs to ensure proper cleanup.
Arguments
Rückgabewert

setTimeout

The setTimeout() method executes a function or expression after the specified number of milliseconds. Kameleoon resets all timeouts created via this API during engine reloads. Verwenden Sie diese Methode in SPAs to ensure proper cleanup.
Arguments
Rückgabewert

Kameleoon.API.Visitor

This module provides a shortcut to obtain a reference to the current Visitor object. The Activation API contains a single, unique Visitor object. This module also allows you to override der Besucher code.

setVisitorCode

The setVisitorCode() method overrides the Kameleoon VisitorCode, which is a unique identifier randomly generated for every visitor. Ensure that your ID is unique and does not exceed 255 characters. Rufen Sie diese method as early as possible, specifically before Kameleoon löst aus any experiments. Wenn Sie update the VisitorCode after die Engine assigns eine Variation, die Engine reassigns die Variation.

Kameleoon.API.CurrentVisit

This module provides a shortcut to obtain a reference to the current, in-progress Visit object. It references the same object as Kameleoon.API.Visitor.visits[Kameleoon.API.Visitor.visits.length - 1].

Configuration

A Configuration object holds global constant values related to the current configuration of Kameleoon on this site.

Properties

Visitor

A Visitor object contains visitor-scoped data independent of specific visits. This object includes a list of all Visit objects for der Besucher.

Properties

Visit

A Visit object represents a single visit and contains real-time information that Kameleoon gathers. Data points include visit context (device, location), observed behavior (duration, page views), and Kameleoon operations, wie etwa ausgelöst experiments or personalizations.

Properties

The kameleoonConversionScores property is only available with the AI Predictive Targeting add-on.

Device

A Device object contains data about the device for a given visit.

Properties

Geolocation

A Geolocation object contains data about the physical location of der Besucher for a given visit.

Properties

Weather

A Weather object contains data about the weather conditions occurring at the time of the visit.

Properties

Experiment

An Experiment object represents a Kameleoon A/B test. Core properties include das Segment and associated variations. Variations contain the JavaScript and CSS code that implements the changes.

Properties

Personalization

A Personalization object represents a Kameleoon personalization action for a specific segment. Core properties include das Segment and the associated single variation. The Variation object contains the JavaScript and CSS code that implements die Personalisierung action.

Properties

ExperimentActivation

An ExperimentActivation object represents ein Experiment activated during a specific visit. Because visits can be historical, the associated experiment might have stopped. In such cases, die Engine does not inject experiment metadata (name, launch date, segment) into the application file, which makes it unavailable through the API. Allerdings, IDs remaining available.

Properties

PersonalizationActivation

A PersonalizationActivation object represents eine Personalisierung activated during a specific visit. As with experiments, metadata is unavailable if die Personalisierung has stopped, although IDs remain accessible.

Properties

Variation

A Variation object represents a component of an Experiment. An A/B test contains multiple variations, wie etwa an A/B test with one variation plus reference or an A/B/C test with two plus reference. Personalizations associate with a single Variation object.
During variation code execution, the this keyword references the corresponding Variation object. Use this reference to navigate the object hierarchy (for example, through the associatedCampaign property).

Properties

Template

A Template object represents an instantiated Widget template. Use templates to generate variations from a common codebase through the Kameleoon app interface. A Template object contains predefined fields and their values for the associated variation.

Properties

Goal

A Goal object represents a Key Performance Indicator (KPI) defined in the Kameleoon app.

Properties

Segment

A Segment object contains criteria that a visit must fulfill to belong to das Segment. On the Kameleoon platform, segments include constant conditions, wie etwa age or location, and triggering conditions, wie etwa time on page or cart contents.

Properties

Trigger

A Trigger object contains criteria that a visit must fulfill to fire the trigger. On the Kameleoon platform, löst aus include constant conditions, wie etwa age or location, and triggering conditions, wie etwa time on page or cart contents.

Properties

Product

A Product object describes items in a catalog. Most properties are optional and might be null.

Properties

Category

Properties

Param

An optional generic field that allows you to upload custom information about a product that does not fit in other fields. Beispielsweise this information could be the membership status required to buy a product or departure and return dates for a travel circuit.

Properties

Fashion

An optional generic field that allows you to upload custom information about the product.

Properties

Color

Properties

Auto

An optional generic field that allows you to upload custom information about the product.

Properties

Compatible

Properties