Documentation
NAV Navbar
  • Activation API Reference
  • Activation API Reference

    Introduction

    The Activation API is a JavaScript API provided directly by the Kameleoon application file installed on your website. You can call the methods of this API directly via JavaScript code. You can also read useful information from a variety of data structures available via this API. For instance, we provide geolocation and weather data of the current visitor, as well as the KCS (Kameleoon Conversion Score), our real-time, customer-centric, machine-learning computed score (note that the KCS is only available if you activated our A.I. Personalization module).

    This is the reference documentation for version 1.0 of the Activation API. Code samples are on the right section. It details both the API entry points (modules containing static methods) as well as the objects (data structures). The methods in the modules can be called directly (for instance Kameleoon.API.Core.enableLegalConsent()), while of course data in the objects can be read only after you've obtained a reference to the desired object.

    Note that not all modules, objects or methods are available to every customer. Some of them depend on specific commercial subscriptions. For example, obviously Kameleoon.API.Experiments is only available with an active subscription to the A/B testing module, and Kameleoon.API.Personalizations is only available with an active subscription to the Personalization module. When it is the case, this is clearly mentionned in this reference documentation.

    Overview of the different modules and objects

    Modules

    Kameleoon.API.Core

    This module contains essential functions for the implementation of front-end based A/B testing variations that won't result in any flickering effect. It is extremely important to use these methods in order to correctly operate the Kameleoon platform and leverage our Anti-Flickering technology. Any Front-End developer working with Kameleoon should be familiar with those.

    It also contains several methods dealing with the initialization of the engine, for instance related to privacy laws and legal consent collection.

    Kameleoon.API.Goals

    This module deals with the triggering of goals and conversion data. For instance, a confirmed purchase with a generated revenue would have to be registered and implemented with this module.

    Kameleoon.API.Data

    This module contains mainly methods to set custom datas, which are the preferred way to provide additional customer or visit characteristics. Other methods are also related to data management (obtain and write).

    Kameleoon.API.Events

    This module allows developers to trigger custom events that can be used in the targeting of your experiments and personalizations. Note that our API also offers standard DOM events which are documented here.

    Kameleoon.API.Tracking

    This module allows the integration of Kameleoon results with 3rd party tracking & analytics platform (such as Adobe Omniture).

    Kameleoon.API.Products

    This module is an entry point to interact with your product catalog. For instance, it can be used to register a product view or purchase, add a product to the cart, obtain a set of automatic product recommendations, or obtain statistics about a given product (how many times it was bought or viewed in the last hour or day).

    Kameleoon.API.Experiments

    This module provides a collection of entry points to access the current live experiments ran by Kameleoon.

    Kameleoon.API.Personalizations

    This module provides a collection of entry points to access the current live personalizations ran by Kameleoon.

    Kameleoon.API.Variations

    This module contains methods to deal with variations.

    Kameleoon.API.Utils

    This module contains several helper methods that can be useful for various operations.

    Kameleoon.API.Visitor

    This module is a shortcut to obtain a reference to the current Visitor object. There is only a single, unique Visitor object within the Activation API.

    Kameleoon.API.CurrentVisit

    This module is just a shortcut to obtain a reference to the current (in-progress) Visit object. It is the reference to the same object that you would obtain by calling Kameleoon.API.Visitor.visits[Kameleoon.API.Visitor.visits.length - 1].

    Objects

    Configuration Object

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

    Visitor Object

    A Visitor object contains data scoped to the visitor, that is not dependent of a given visit. Note that this object contains a list of all the Visit objects related to this visitor.

    Visit Object

    A Visit object represents a single visit. It contains all the information gathered by Kameleoon, which is updated in real-time. Data can be related to the context of the visit (device used, location...), to the behavior observed during the visit (duration, number of pages viewed...) or to Kameleoon operations (triggered experiments or personalizations).

    Device Object

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

    Geolocation Object

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

    Weather Object

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

    Experiment Object

    An Experiment object represents a Kameleoon A/B test. Its main properties are its segment (defining the conditions under which the experiment will be triggered) and the associated variations. Variations contain the JavaScript and CSS code that implement the changes needed to produce the desired end-result.

    Personalization Object

    A Personalization object represents a Kameleoon personalization action for a given segment. Its main properties are its segment (defining the conditions under which the personalization will be triggered and displayed) and the associated single variation. Technically, the Variation object is the same used by an Experiment. It contains the JavaScript and CSS code that implement the actual displayed personalization action.

    Variation Object

    A Variation object represents one of the main components of an Experiment. An A/B test experiment contains a list of variations (if the test contains 1 variation in addition to the original, it is usually called an A/B test, if it has 2 variations, an A/B/C test, and so on). Note that while an Experiment contains a list of variations, a Personalization has a reference and is associated to a single Variation object.

    Goal Object

    A Goal object represents a given KPI (Key Performance Indicator) that is tracked on the website. Goals are defined via Kameleoon's Back-Office.

    Segment Object

    A Segment object contains a list of criteria that must be fulfilled for the visit to belong to the segment. Note that on the Kameleoon platform, a Segment contains both "constant" conditions (such as age, location) and "triggering" conditions (such as the number of seconds ellapsed since the load of the page or the visit, or the total amount of items in the shopping cart).

    Product Object

    A Product object describes a product in your catalog, with many attached information. Most properties of a Product can be null.

    Kameleoon.API.Core

    This module contains essential functions for the implementation of front-end based A/B testing variations that won't result in any flickering effect. It is extremely important to use these methods in order to correctly operate the Kameleoon platform and leverage our Anti-Flickering technology. Any Front-End developer working with Kameleoon should be familiar with those.

    It also contains several methods dealing with the initialization of the engine, for instance related to privacy laws and legal consent collection.

    enableLegalConsent

    var agreedButton = Kameleoon.API.Utils.querySelectorAll("#agreed")[0];
    
    Kameleoon.API.Utils.addEventListener(agreedButton, "mousedown", function(event) {
        Kameleoon.API.Core.enableLegalConsent();
    });
    

    The enableLegalConsent() method should be called once you have obtained legal consent from the visitor to activate Kameleoon. It triggers the activation of Kameleoon's normal mode. For more information, please refer to this article.

    enableSinglePageSupport

    if (location.href.indexOf("mySPAWebsitePart") != -1)
    {
        Kameleoon.API.Core.enableSinglePageSupport();
    }
    

    The enableSinglePageSupport() method triggers a reload of the Kameleoon engine when the URL changes. If your website is a Single Page Application with "virtual URLs" (fragments change only after the hash symbol #), the use of this method is recommended, as every virtual URL change will be seen as a new page by Kameleoon. This will enable URL targeting to work, as well as the correct gathering of some information, such as the number of page views.

    getConfiguration

    var configuration = Kameleoon.API.Core.getConfiguration();
    
    if (configuration.siteCode == "abcde12345")
    {
        document.cookie = "MyMainSite=true;";
    }
    else if (configuration.siteCode == "12345abcdef")
    {
        document.cookie = "MySubSite=true;";
    }
    

    The getConfiguration() method returns a reference to the Configuration object. This objects holds global, constant values related to the current configuration of Kameleoon on this site.

    Return value
    NameTypeDescription
    configurationObjectConfiguration object.

    load

    var href = location.href;
    
    var intervalId = Kameleoon.Utils.Interval.setInterval(function () {
        if (location.href != href)
        {
            Kameleoon.API.Core.load();
        }
    }, 2000);
    

    The load() method initalizes the Kameleoon engine. It is normally called automatically when the Kameleoon application file loads, at each page load. However, sometimes it is useful to call it manually. The example on the right shows for instance how you could implement reloading after each hash URL change (similar to what the enableSinglePageSupport() method does).

    processRedirect

    var experiment = Kameleoon.API.Experiments.getByName("RedirectExperiment");
    
    if (experiment.associatedVariation.id == 123456)
    {
        Kameleoon.API.Core.processRedirect("https://www.mywebsite.com?variation=A");
    }
    else
    {
        Kameleoon.API.Core.processRedirect("https://www.mywebsite2.com", true);
    }
    

    The processRedirect() method sends the browser to another URL. It is generally used in split A/B experiments. Note: do not write code such as window.location.href = redirectionURL; for your split experiments. Always use this method as it takes care of some important details (like ensuring proper tracking) in the background.

    Arguments
    NameTypeDescription
    redirectionURLStringURL of the new page where the visitor will be redirected. This field is mandatory.

    runWhenConditionTrue

    Kameleoon.API.Core.runWhenConditionTrue(function(){
        return typeof jQuery != "undefined"; 
     }, function(){
        jQuery("#bloc-2345").text("Mon nouveau texte");
     }, 200);
    

    The runWhenConditionTrue() method will execute a JavaScript function (callback) as soon as the conditionFunction function returns true. It periodically calls the conditionFunction with a polling mechanism, so its use can result in flickering. For this reason, we strongly recommend the use of the next method, runWhenElementPresent(), over the use of this method. See the description of runWhenElementPresent() for more details.

    Arguments
    NameTypeDescription
    conditionFunctionFunctionJavaScript function to execute, which must return true or false. This field is mandatory.
    callbackFunctionJavaScript function to execute when the conditionFunction function returns true. This field is mandatory.
    pollingIntervalNumberPolling interval, in milliseconds. Kameleoon will execute the conditionFunction function periodically with this interval. If you cannot use runWhenElementPresent(), and are forced to rely on runWhenConditionTrue(), providing a lower number for the pollingInterval argument can reduce flickering (at the expense of CPU browser usage). This field is optional, if not provided, the method will use the default value of 200 milliseconds.

    runWhenElementPresent

    Kameleoon.API.Core.runWhenElementPresent("#bloc-2345", function(elements) {
        elements[0].innerText = "My new Text";
     }, 200);
    

    The runWhenElementPresent() method will execute a JavaScript function (callback) as soon as a specific element appears in the DOM. Technically, it uses Mutation Observers underneath, and is the core method enabling the use of our Anti-Flickering technology. Thus when implementing front-end A/B experiments, you should try to determine which are the main element you need to act on for your variation. Then always call runWhenElementPresent() with the given element as first argument and the variation implementation code in a callback as the second argument. Our system will then ensure all your modification code runs as soon as the desired HTML element appears in the DOM, before any display refresh cycle is initiated by the browser.

    In case your code needs to act on several elements, which is often the case, it is better to call runWhenElementPresent() several times with different arguments rather than trying to guess which element will appear last and use runWhenElementPresent() once with this element. If called a single time, flickering can appear if a refresh cycle happens between the apparition of a "first" element that needs to be visually modified and the "last" one (given as argument to the method).

    Important note: a third argument, pollingInterval, can optionally be given to this method. If present, mutation observers / anti-flickering will be disabled and our previous, legacy mechanism relying on pollers will be used instead (with the given polling interval). Since it can result in noticable flickering, we do not recommend providing this argument except in very special cases (complex selector queries that would have a huge impact on the CPU browser usage, for instance).

    Arguments
    NameTypeDescription
    selectorStringCSS selector of the element. This field is mandatory.
    callbackFunctionJavaScript function to execute when the element appears in the DOM. This field is mandatory.
    pollingIntervalNumberPolling interval, in milliseconds. Providing this argument is not recommended as it will disable Kameleoon's use of Mutation Observers. Instead, the polling legacy implementation will be used: the engine will periodically issue selector queries to determine if the element is present on the DOM or not. It can result in flickering. This field is optional.

    Kameleoon.API.Goals

    This module deals with the triggering of goals and conversion data. For instance, a confirmed purchase with a generated revenue would have to be registered and implemented with this module.

    cancelConversion

    var buttons = Kameleoon.API.Utils.querySelectorAll(".btnRemoveFromCart");
    
    buttons.forEach(function (button) {
        Kameleoon.API.Utils.addEventListener(button, "mousedown", function(event) {
            Kameleoon.API.Goals.cancelConversion(event.target.id);
        });
    });
    

    The cancelConversion() method allows you to cancel a conversion that was previously triggered during the same visit. It cannot cancel conversions registered in previous visits.

    Arguments
    NameTypeDescription
    goalNameOrIDString or NumberName (String) or ID (Number) of the goal as it is defined in Kameleoon's Back-Office (in the Goals configuration section). This field is mandatory.

    processConversion

    var buyButton = Kameleoon.API.Utils.querySelectorAll("#buyButton")[0];
    
    Kameleoon.API.Utils.addEventListener(buyButton, "mousedown", function() {
        Kameleoon.API.Goals.processConversion("buy", 19.99);
    });
    

    The processConversion() method allows you to trigger a conversion.

    Arguments
    NameTypeDescription
    goalNameOrIDString or NumberName (String) or ID (Number) of the goal as it is defined in Kameleoon's Back-Office (in the Goals configuration section). This field is mandatory.
    revenueNumberAmount of the transaction. If you provide this number, Kameleoon will register the amount of the purchase / transaction (allowing the reporting of metrics such as generated revenue, average cart amount, etc). This field is optional.

    Kameleoon.API.Data

    This module contains mainly methods to set custom datas, which are the preferred way to provide additional customer or visit characteristics. Other methods are also related to data management (obtain and write).

    checkInterest

    var imagesToCheck = [
        "http://developers.kameleoon.com/logo.png",
        "http://developers.kameleoon.com/background.jpg",
        "http://developers.kameleoon.com/icon-api.png"
    ];
    
    Kameleoon.API.Data.checkInterest(imagesToCheck, "Interest Kameleooon", function (isFound) {
        if (isFound)
        {
            Kameleoon.API.Event.trigger("My Custom Event");
        }
    });
    

    The checkInterest() method allows you to manually check if some images (with provided URLs) are present in the visitor's browser cache, which means their hosting site was visited recently. It also automatically updates an associated interest (passed as argument) with the result of the check.

    Arguments
    NameTypeDescription
    imageURLsArrayList of image URLs to check. This field is mandatory.
    interestNameStringName of the interest related to the sites. This interest will be set to true if at least one of the provided images was found in the browser cache. This field is optional, if not provided (or if null is passed as argument), the image check is performed, but no associated interest is updated as a result.
    callbackFunctionCallback function that will be called once the check has been performed, since the check happens asynchronously. The function will be called with a Boolean argument indicating the result of the check (true if at least one image was found, false otherwise). This field is optional, if not provided, no callback function will be executed.

    readLocalData

    var userId = Kameleoon.API.Data.readLocalData("myUserId");
    
    if (userId)
    {
        Kameleoon.API.Data.retrieveDataFromRemoteSource(userId, function (data) {
            console.log(data.returningVisitor);
        });
    }
    

    The readLocalData() method allows you to read local data previously stored on the visitor's web browser via the writeLocalData() method. Underneath, our engine will read this data on our cross-domain Local Storage. You don't have to worry about the usual limitations of the Local Storage - our implementation removes them.

    Arguments
    NameTypeDescription
    keyStringKey (name) of the data to return. This field is mandatory.
    Return value
    NameTypeDescription
    valueStringValue of the data.

    resetCustomData

    Kameleoon.API.Data.resetCustomData("MyCustomDataName");
    

    The resetCustomData() method allows you to reset a custom data.

    Arguments
    NameTypeDescription
    nameStringName of the custom data as it is defined in Kameleoon's Back-Office (in the Custom Data configuration section). This field is mandatory.

    retrieveDataFromRemoteSource

    if (location.href.indexOf("loginPage") != -1)
    {
        Kameleoon.API.Core.runWhenConditionTrue(function () {
            return typeof dataLayer != null;
        }, function () {
            dataLayer.forEach(function (map) {
                if (map.userId)
                {
                    Kameleoon.API.Data.retrieveDataFromRemoteSource(userId, function(data) {
                        Kameleoon.API.Data.setCustomData("known_user", data.knownUser);
                    });
                }
            });
        }, 200);
    }
    

    The retrieveDataFromRemoteSource() method allows you to retrieve data (according to a key passed as argument) stored on a remote Kameleoon server. Usually data will be stored on our remote servers via the use of our Data API. This method, along with the availability of our highly scalable servers for this purpose, provides a convenient way to quickly store massive amounts of data that can be later retrieved for each of your visitors / users.

    Note that since a server call is required, this mechanism is asynchronous, and you must pass a callback as argument to the method.

    Arguments
    NameTypeDescription
    keyStringkey. This field is mandatory.
    callbackFunctionFunction called when data has been retrieved. It is called with a *data argument that is a JS Object. This field is mandatory.

    setCustomData

    Kameleoon.API.Data.setCustomData("myCustomDataName", "myNewValue");
    

    The setCustomData() method allows you to set a custom data value.

    Arguments
    NameTypeDescription
    nameStringName of the custom data as it is defined in Kameleoon's Back-Office (in the Custom Data configuration section). This field is mandatory.
    valueStringNumber
    overwriteIfCollectionBooleanIf the custom data is of type List, by default the value provided is added as new element to the existing list. If this boolean is set, the list will be reset first, and the argument will then be added as the first element of the list. Note that if you just want to empty the list, you should use the resetCustomData() method instead. This field is optional, if not provided, the method will use the default value of false.

    writeLocalData

    Kameleoon.API.Data.writeLocalData("myData", "myDataValue", true);
    

    The writeLocalData() method allows you to write local data on the visitor's web browser and later retrieve it via the readLocalData() method. Underneath, our engine will write this data on our cross-domain Local Storage. You don't have to worry about the usual limitations of the Local Storage - our implementation removes them. The data passed will be available immediately for retrieval (in the same browser tab), as it is cached in RAM, but please note that the actual associated write happens asynchronously.

    Arguments
    NameTypeDescription
    keyStringKey (name) of the data to write. This field is mandatory.
    valueStringValue of the data to write. This field is mandatory.
    persistentBooleanSet the data as persistent or not. If not persistent, this data will be only saved for 1 hour, after which it won't be available. If persistent, this data will be saved for 30 days. This field is optional, if not provided, the method will use the default value of false.

    Kameleoon.API.Events

    This module allows developers to trigger custom events that can be used in the targeting of your experiments and personalizations. Note that our API also offers standard DOM events which are documented here.

    trigger

    Kameleoon.API.Events.trigger("myTriggerEventName");
    

    The trigger() method allows you to trigger a custom event. Custom events are used in targeting segments.

    Arguments
    NameTypeDescription
    eventNameStringName of the event to trigger. This field is mandatory.

    Kameleoon.API.Tracking

    This module allows the integration of Kameleoon results with 3rd party tracking & analytics platform (such as Adobe Omniture).

    processOmniture

    function s_doPlugins(s)
    {
        /* Kameleoon Integration */
    
        if (window.Kameleoon)
        {
            Kameleoon.API.Tracking.processOmniture(s);
        }
        window.kameleoonOmnitureCallSent = true;
    
        // Add your other doPlugins code below
    }
    
    s.doPlugins = s_doPlugins;
    
    

    We provide a native integration with Adobe Omniture if you wish to track results of your experiments and personalizations on Omniture. To use this bridge, you must modify the file containing the s_doPlugins() code as shown in the example on the right. Two important things need to be done inside the s_doPlugins() function:

    With our integration, Kameleoon will try to minimize the number of overall Omniture hits sent (which is important, since the number of hits directly affects Omniture pricing). It will only send an additional hit if an experiment or personalization triggers after the main Omniture call has already been processed and sent. This can happen either if Kameleoon loads after the Omniture code (not recommended and should not be the case, but possible since Kameleoon's application file usually loads asynchronously) OR if there is an experiment or personalization triggering "late" (ie, not at page load, but for instance after a click on a button).

    In the normal case, where Kameleoon loads first and all active experiments can be known at page load, all the additional data is sent along the global, standard Omniture tracking call.

    Arguments
    NameTypeDescription
    omnitureObjectObjectReference to your Omniture object. Usually, the global "s" variable (window.s) represents the Omniture object. It is also passed as an argument (named "s" as well) to the s_doPlugins() method. This field is mandatory.

    Kameleoon.API.Products

    This module is an entry point to interact with your product catalog. For instance, it can be used to register a product view or purchase, add a product to the cart, obtain a set of automatic product recommendations, or obtain statistics about a given product (how many times it was bought or viewed in the last hour or day).

    obtainRecommendedProducts

    Kameleoon.API.Products.obtainRecommendedProducts("popular", {
        limit: 6,
        format: "object",
        categoryId: 123456
    }, function(result) {
        if (result.length > 0)
        {
            var recommendationContainer = Kameleoon.API.Utils.querySelector("#recommendationContainer");
            result.forEach(function (productData) {
                var product = document.createElement("div");
                product.className = "productItem";
                product.innerHTML = "<a href='" + productData.url + "'>" +
                    "<img src='" + productData.mainImageURL + "' alt='" + productData.name + "'>" +
                "</a>";
                recommendationContainer.appendChild(product);
            });
        }
    });
    

    The obtainRecommendedProducts() method will retrieve a list of recommended products as computed by the specified algorithm. They are retrieved by an asynchronous server call.

    Arguments
    NameTypeDescription
    typeStringType of recommendation algorithm used. Available choices are: similar, also_bought, see_also, interesting, recently_viewed, popular, buying_now.
    parametersObjectParameters to control the data returned by the recommendation platform. You should provide a JavaScript object with the following keys:
    • productId: Product id corresponding to the current product (or the product for which we want to obtain recommendations). Mandatory key for the similar or also_bought algorithms, else optional.
    • categoryId: Category id corresponding to the category for which we want to obtain recommendations. Mandatory key for the popular algorithm, else optional.
    • limit: Maximum number of returned recommended products. Optional key with a default value of 8.
    • format: Format of the returned data. Possible values are either id (an array of ids will be passed to the callback function) or object (an array of Product objects will be passed to the callback function). Optional key with a default value of id.
    successCallbackFunctionCallback function that will be called when recommended products are successfully returned. Either an array of ids (Strings) or an array of Product objects are passed to this function, depending on the value of the format key within the parameters argument. This field is mandatory.
    errorCallbackFunctionCallback function that will be called in case of error. This field is optional.

    trackAddToCart

    var buyButton = Kameleoon.API.Utils.querySelectorAll("#buyButton")[0];
    
    Kameleoon.API.Utils.addEventListener(buyButton, "mousedown", function() {
        Kameleoon.API.Products.trackAddToCart("myProductId", 19.99, 1);
    });
    

    The trackAddToCart() method should be called when a product is added to the visitor's shopping cart.

    Arguments
    NameTypeDescription
    productIdStringProduct identifier. This can be any unique identifier for this particular product. This field is mandatory.
    unitPriceNumberPrice for a single unit of the product referenced by productId. This field is optional, if not provided, a default value of 0.0 will be used. This means that the cart total amount won't change.
    quantityNumberQuantity of products added to the cart. Note that you can provide a negative value: in this case the product will be considered removed from the cart, not added. This field is optional, if not provided, the method will use the default value of 1.

    trackCategoryView

    if (location.href.indexOf("productPage") != -1)
    {
        Kameleoon.API.Core.runWhenConditionTrue(function () {
            return typeof dataLayer != null;
        }, function () {
            dataLayer.forEach(function (map) {
                if (map.categoryId)
                {
                    Kameleoon.API.Products.trackCategoryView(5);
                }
            });
        }, 200);
    }
    

    The trackCategoryView() method should be called every time a category page is viewed by the visitor during his browsing session.

    Arguments
    NameTypeDescription
    categoryIdStringCategory identifier. This can be any unique identifier for this particular category. This field is mandatory.

    trackProductView

    Kameleoon.API.Products.trackProductView("myPoductId", {
        "name": "productName",
        "categoryId": 13,
        "category": "productCategory",
        "pictureHref": "https://www.mywebsite/productImage.jpg",
        "price": 19.99,
        "available": true,
        "brand": "productBrand",
        "child": false,
        "gender": "F",
        "sizes": ["S", "M"],
        "type": "shirt",
        "feature": "productFeature",
        "sku": "productSKU"
    });
    

    The trackProductView() method should be called every time a product is viewed by the visitor during his browsing session. Note that by ensuring this call is properly made, Kameleoon will be able to build a copy of your product catalog without the need for an explicit integration via a XML feed for instance. This can greatly facilitate the setup and launch of a product recommendations project, since all the integration work can take place only on the front-end.

    Arguments
    NameTypeDescription
    productIdStringProduct identifier. This can be any unique identifier for this particular product. This field is mandatory.
    productDataObjectProduct object. This field is mandatory.

    trackTransaction

    Kameleoon.API.Products.trackTransaction([
        {
            "ean": "myProductId1",
            "quantity": 4
        },
        {
            "ean": "myProductId4564",
            "quantity": 1
        }
    ]);
    

    The trackTransaction() method should be called when a purchase / transaction is actually carried out.

    Arguments
    NameTypeDescription
    productsArrayList of objects that contains the productID and quantity for each product in the transaction. This field is mandatory.

    Kameleoon.API.Experiments

    This module provides a collection of entry points to access the current live experiments ran by Kameleoon.

    assignVariation

    var experimentId = 2468,
        variationId;
    
    if (Kameleoon.API.CurrentVisit.device.type == "Desktop")
    {
        variationId = 123456;
    }
    else if (Kameleoon.API.CurrentVisit.device.type == "Tablet")
    {
        variationId = 654321;
    }
    else
    {
        variationId = 987654;
    }
    
    Kameleoon.API.Experiments.assignVariation(experimentId, variationId);
    
    

    This method forces the association of a given variation for an experiment, instead of relying on the standard allocation algorithm (which usually picks a variation at random according to the configured deviation). Note that this method can be called before the experiment is actually triggered. In this case, the variation will be "pre-allocated", which means that if the experiment later triggered in the current visit (or even a future one), this variation will be the one chosen. If the experiment was already previously triggered, a variation is normally already associated with the experiment. You should set the override argument to true if you want to replace it with the new one - else the method won't do anything.

    Arguments
    NameTypeDescription
    experimentIDNumberID of the experiment. This field is mandatory.
    variationIDNumberID of the variation. This field is mandatory.
    overrideBooleanSpecifies if an existing variation association (for an already triggered experiment) should be forgotten and replaced by the new one provided. This field is optional, if not provided, the method will use the default value of false.

    getAll

    Kameleoon.API.Experiments.getAll().forEach(function (experiment) {
        if (experiment.id == 123456 && experiment.active)
        {
            console.log(experiment.name);
        }
    });
    

    Returns the list of experiments currently live in your website (ie, the experiments that are not in draft, paused or stopped, but actually running).

    Return value
    NameTypeDescription
    experimentsArrayList of Experiment objects.

    getActive

    if (Kameleoon.API.Experiments.getActive().length == 0)
    {
        Kameleoon.API.Events.trigger("No Experiments Events");
    }
    

    Returns the list of active experiments for the current visit and page. An active experiment means that its variation code has been executed in the current browser context (page). If the experiment was triggered on a different URL but is not active in the current URL, it won't be return by this method. You can however retrieve it via the getTriggeredInVisit() method.

    Return value
    NameTypeDescription
    experimentsArrayList of Experiment objects.

    getById

    var experiment = Kameleoon.API.Experiments.getById(123456);
    
    if (experiment && experiment.active)
    {
        console.log(experiment.name);
    }
    

    Returns the experiment with a specific id.

    Arguments
    NameTypeDescription
    idNumberID of the experiment. This field is mandatory.
    Return value
    NameTypeDescription
    experimentObjectExperiment object.

    getByName

    var experiment = Kameleoon.API.Experiments.getByName("MyExperimentName");
    
    if (experiment && experiment.active)
    {
        console.log(experiment.id);
    }
    

    Returns the experiment with a specific name.

    Arguments
    NameTypeDescription
    nameStringName of the experiment. This field is mandatory.
    Return value
    NameTypeDescription
    experimentObjectExperiment objects.

    getTriggeredInVisit

    Kameleoon.API.Experiments.getTriggeredInVisit().forEach(function (experiment) {
        if (experiment.id == 123456)
        {
            console.log(experiment.name);
        }
    });
    

    Returns the list of experiments that were triggered in the current visit.

    Return value
    NameTypeDescription
    experimentsArrayList of Experiment objects.

    Kameleoon.API.Personalizations

    This module provides a collection of entry points to access the current live personalizations ran by Kameleoon.

    disable

    if (Kameleoon.API.Personalizations.getActive().length == 0)
    {
        Kameleoon.API.Events.trigger("No Personalizations Events");
    }
    

    The disable() method should be used to mark that a personalization as disabled. For instance, if you create a personalization that will display a pop-in or similar visual artefact that can be closed, if the user actually closes the pop-in by clicking on the close button, the underlying personalization should be marked disabled, as it is no longer active. Note that pop-ins automatically generated by Kameleoon (ie, not via custom JavaScript code, but via our interface) already implement a call to this method on a click on the close button.

    Arguments
    NameTypeDescription
    idNumberId of the personalization. This field is mandatory.

    getActive

    if (Kameleoon.API.Personalizations.getActive().length == 0)
    {
        Kameleoon.API.Events.trigger("No Personalizations Events");
    }
    

    Returns the list of active personalizations for the current visit and page. An active personalization means that its variation code has been executed in the current browser context (page) and that the associated displayed action is still visible on the page. If the personalization was triggered on a different URL but is not active in the current URL, it won't be return by this method. Similarly a personalization displaying a pop-in that was already closed won't be returned. You can however retrieve such personalizations via the getTriggeredInVisit() method.

    Return value
    NameTypeDescription
    personalizationsArrayList of Personalization objects.

    getAll

    Kameleoon.API.Personalizations.getAll().forEach(function (personalization) {
        if (personalization.id == 123456 && personalization.active)
        {
            console.log(personalization.name);
        }
    });
    

    Returns the list of personalizations currently live in your website (ie, the personalizations that are not in draft, paused or stopped, but actually running).

    Return value
    NameTypeDescription
    personalizationsArrayList of Personalization objects.

    getById

    var personalization = Kameleoon.API.Personalizations.getById(123456);
    
    if (personalization && personalization.active)
    {
        console.log(personalization.name);
    }
    

    Returns the personalization with a specific id.

    Arguments
    NameTypeDescription
    idNumberId of the personalization. This field is mandatory.
    Return value
    NameTypeDescription
    personalizationObjectPersonalization object.

    getByName

    var personalization = Kameleoon.API.Personalizations.getByName("MyPersonalizationName");
    
    if (personalization && personalization.active)
    {
        console.log(personalization.id);
    }
    

    Returns the personalization with a specific name.

    Arguments
    NameTypeDescription
    nameStringName of the personalization. This field is mandatory.
    Return value
    NameTypeDescription
    personalizationObjectPersonalization object.

    getTriggeredInVisit

    Kameleoon.API.Personalizations.getTriggeredInVisit().forEach(function (personalization) {
        if (personalization.id == 123456)
        {
            console.log(personalization.name);
        }
    });
    

    Returns the list of experiments that were triggered in the current visit.

    Return value
    NameTypeDescription
    personalizationsArrayList of Personalization object.

    Kameleoon.API.Variations

    This module contains methods to deal with variations.

    execute

    if (Kameleoon.API.Utils.querySelectorAll("#KameleoonPopin").length == 0)
    {
        Kameleoon.API.Experiments.getById(123456).variations.forEach(function (variation) {
            if (variation.name == "MyVariation")
            {
                Kameleoon.API.Variations.execute(variation.id);
            }
        });
    }
    
    

    Execute JS code and apply CSS for the variation corresponding to the ID passed as argument.

    Kameleoon.API.Utils

    This module contains several helper methods that can be useful for various operations.

    addEventListener

    var popin = document.createElement("div");
    popin.id = "kameleoonPopin";
    popin.innerHTML = "<img src='https://www.mywebsite.com/myImage.jpg'/>";
    document.body.appendChild(popin);
    
    Kameleoon.API.Utils.addEventListener(popin, "mousedown", function(event) {
        document.body.removeChild(popin);
    });
    

    The addEventListener() method attaches an event handler to the specified element.

    Arguments
    NameTypeDescription
    elementObjectThe element on which you want to add a listener. This field is mandatory.
    eventTypeStringA String that specifies the name of the event. This field is mandatory.
    callbackFunctionCallback function that will be called when the event triggers. This field is mandatory.

    clearInterval

    var myInterval = Kameleoon.API.Utils.setInterval(function() {
        if (window.dataLayer != null)
        {
            Kameleoon.API.Utils.clearInterval(myInterval);
        }
    }, 1000);
    

    The clearInterval() method clears a timer set with the setInterval() method.

    Arguments
    NameTypeDescription
    intervalIdNumberThe id of the timer returned by the setInterval() method. This field is mandatory.

    clearTimeout

    var myTimeout = Kameleoon.API.Utils.setTimeout(function () {
        var popin = document.createElement("div");
        popin.id = "kameleoonPopin";
        popin.innerHTML = "<img src='https://www.mywebsite.com/myImage.jpg'/>";
        document.body.appendChild(popin);
    }, 5000);
    
    
    Kameleoon.API.Utils.addEventListener(document.body, "mousedown", function() {
        Kameleoon.API.Utils.clearTimeout(myTimeout);
    });
    

    The clearTimeout() method clears a timer set with the setTimeout() method.

    Arguments
    NameTypeDescription
    timeoutIdNumberThe id of the timer returned by the setTimeout() method. This field is mandatory.

    computeHash

    var emailId = Kameleoon.API.Utils.createHash("myemail@mail.com");
    Kameleoon.API.Data.setCustomData("VisitorEmail", emailId);
    

    The computeHash() method computes a hash from a given string. This is useful if you want to work on unique data, without having to directly manipulate the original data (especially personal data, for legal reasons).

    Arguments
    NameTypeDescription
    stringStringThe source string from which to compute the hash.
    Return value
    NameTypeDescription
    hashStringResulting hash. The algorithm used is the same as the implementation of hashCode() for java.lang.String.

    getURLParameters

    var parameters = Kameleoon.API.Utils.getUrlParameters();
    
    if (parameters.productId != null)
    {
        Kameleoon.API.Events.trigger("ProductPage");
    }
    

    The getURLParameters() method parses the current URL and returns all parameters found. This method works with both search (?) and hash (#) parameters.

    Return value
    NameTypeDescription
    parametersObjectObject with parameter names as keys and parameter values as values.

    performRequest

    Kameleoon.API.Utils.performRequest(
        "https://www.my_web_server_url.com",
        function()
        {
            if (this.readyState == 4 && this.status == 200)
            {
                eval(this.responseText);
            }
        },
        function()
        {
            console.log("Request cancelled");
        },
        2000
    );
    

    The performRequest() method can be used to initiate a call with a remote web server.

    Arguments
    NameTypeDescription
    urlStringThe URL of the remote server. This field is mandatory.
    readyStateHandlerFunctionA callback function that will be executed when a reply is received from the server. The event argument is passed to this function (load event) and the underlying XMLHttpRequest object is bound to the callback. So all properties from XMLHttpRequest are available inside the callback via this. This field is optional.
    errorHandlerFunctionA callback function that will be called in case an error occurs. The event argument is passed to this function (error event or timeout event) and the underlying XMLHttpRequest object is bound to the callback. So all properties from XMLHttpRequest are available inside the callback via this. This field is optional.
    timeoutNumberThe time to wait in milliseconds before cancelling the request. This field is optional, if not provided, the method will use the default value of 5000 milliseconds.

    querySelectorAll

    var foundElements = Kameleoon.API.Utils.querySelectorAll(".kameleoonClassName");
    
    foundElements.forEach(function (element) {
        element.style.display = "none";
    });
    

    The querySelectorAll() method returns all elements in the document that match a specified CSS selector(s), as a static NodeList object.

    Arguments
    NameTypeDescription
    selectorStringOne or more CSS selectors. This field is mandatory.
    Return value
    NameTypeDescription
    elementsArrayList of elements matching the query.

    setInterval

    var countdown = 10;
    var timer = document.createElement("div");
    timer.innerHTML = countdown.toString();
    document.body.appendChild(timer);
    
    var myInterval = Kameleoon.API.Utils.setInterval(function() {
        countdown--;
        timer.innerHTML = countdown.toString();
    
        if (countdown == 0)
        {
            Kameleoon.API.Utils.clearInterval(myInterval);
        }
    }, 1000);
    

    The setInterval() method calls a function or evaluates an expression at the specified interval (in milliseconds).

    Arguments
    NameTypeDescription
    functionFunctionJavaScript function that will be executed periodically. This field is mandatory.
    millisecondsNumberNumber of milliseconds for the interval. This field is optional, if not provided, the method will use the default value of 200 milliseconds.
    Return value
    NameTypeDescription
    intervalIdNumberID that can be used as the argument to the clearInterval() method to cancel the timer.

    setTimeout

    var myTimeout = Kameleoon.API.Utils.setTimeout(function () {
        Kameleoon.API.Events.Trigger("5 seconds elapsed");
    }, 5000);
    

    The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.

    Arguments
    NameTypeDescription
    functionFunctionJavaScript function that will be executed periodically. This field is mandatory.
    millisecondsNumberNumber of milliseconds to wait before executing the given function. This field is optional, if not provided, the method will use the default value of 200 milliseconds.
    Return value
    NameTypeDescription
    timeoutIdNumberID that can be used as the argument to the clearTimeout() method to cancel the timer.

    Kameleoon.API.Visitor

    This module is a shortcut to obtain a reference to the current Visitor object. There is only a single, unique Visitor object within the Activation API.

    Kameleoon.API.CurrentVisit

    This module is just a shortcut to obtain a reference to the current (in-progress) Visit object. It is the reference to the same object that you would obtain by calling 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
    NameTypeDescription
    siteCodeStringThe unique site code corresponding to the Kameleoon application file installed on the website. It is a string of 10 random characters (lower case letters and numerals).
    singlePageSupportBooleanEquals true if Single Page Support was configured for this website. This can be done either globally via Kameleoon's Back-Office, or via the Activation API Kameleoon.API.Core.enableSinglePageSupport() method. Single Page Support means any changes in the hash (#) part of the URL will trigger Kameleoon.API.Core.load().
    goalsArrayList of Goal objects representing all the active (configured) goals for this site.
    generationTimeNumberTime of the last generation of the Kameleoon application file (UTC format - ms since 1st January, 1970).

    Visitor

    A Visitor object contains data scoped to the visitor, that is not dependent of a given visit. Note that this object contains a list of all the Visit objects related to this visitor.

    Properties
    NameTypeDescription
    codeStringThe randomly generated visitor code. Unless a custom value has been specifically set on the server (via a Kameleoon server-side SDK), it is a string of 16 random characters (lower case letters and numerals).
    numberOfVisitsNumberThe total number of visits made by this visitor on your website. It is not always equal to visits.length, since we only keep available the latest 25 visits to the Activation API.
    visitsArrayList of all the Visit objects made by this visitor on your website, with a maximum of 25 visits. If this visitor made more than 25 visits, only the latest 25 are available via this property.
    currentVisitObjectVisit object corresponding to the current, in-progress visit. This is a reference to the same object as Kameleoon.API.CurrentVisit.
    previousVisitObjectVisit object corresponding to the previous visit. If there was no previous visit (ie, the current visit is the first one), this property is null.
    customDataObjectMap of all the custom data with a scope of Visitor. The keys of the map are the defined custom data names. Note that not all custom data are included on this map, only those that were defined on the Kameleoon's Back-Office as having a scope of Visitor. Other custom data can be accessed from a Visit object.

    Visit

    A Visit object represents a single visit. It contains all the information gathered by Kameleoon, which is updated in real-time. Data can be related to the context of the visit (device used, location...), to the behavior observed during the visit (duration, number of pages viewed...) or to Kameleoon operations (triggered experiments or personalizations).

    Properties
    NameTypeDescription
    indexNumberIndex of the visit. The first visit of a given visitor has an index of 0, the second of 1, etc. Note that only the ten latest visits of a visitor can be accessed via the Activation API, so Kameleoon.API.Visitor.visits[0].index is not always equal to 0.
    startDateNumberDate (UTC format - ms since 1st January, 1970) of the start of the visit.
    durationNumberDuration of this visit in ms. If this visit is the current visit, this value is always up to date (it is recomputed each time it is accessed).
    pageViewsNumberNumber of pages viewed in this visit. If your website is a Single Page Application, calling Kameleoon.API.Core.load() will increase this number. Changes in the hash part of the URL can automatically trigger a Kameleoon.API.Core.load() call if you chose the Single Page Support option for your website in Kameleoon's Back-Office configuration section (or called manually Kameleoon.API.Core.enableSinglePageSupport()).
    localeStringThe locale of the visitor's browser.
    deviceObjectDevice object corresponding to the visitor's device for this visit.
    geolocationObjectGeolocation object corresponding to the visitor's location for this visit.
    weatherObjectWeather object corresponding to the visitor's weather for this visit.
    triggeredExperimentsArrayList of Experiment objects, corresponding to all the experiments that were triggered on this visit.
    triggeredPersonalizationsArrayList of Personalization objects, corresponding to all the personalizations that were triggered on this visit.
    interestsArrayList of interest names identified for this visit. Interests (including their names) are defined via Kameleoon's Back-Office. Important note: the interests identification engine runs asynchronously, so this property may not always be available. It takes a bit of time to compute the interests after the main Kameleoon engine has started, and this operation is only done once per visit (after the first page load). While the initialization and run of the interests engine is not completed, this property has a value of null; once it is done, it is a List (which may be empty).
    conversionsObjectMap of conversions performed on this visit. The keys of the map are the defined goal IDs. The values are Objects with two keys: count (number of times this goal was converted for this visit) and revenue (total revenue of this goal for this visit).
    customDataObjectMap of all the custom data with a scope of Visit. The keys of the map are the defined custom data names. Note that not all custom data are included on this map, only those that were defined on the Kameleoon's Back-Office as having a scope of Visit. Other custom data can be accessed from the Visitor object.
    acquisitionChannelStringName of the acquisition channel for the visit. The list of acquisition channels, along with their characteristics (mainly how they can be inferred, for instance by URL parameter), are defined via Kameleoon's Back-Office.
    landingPageURLStringURL of the first page of the visit, usually called the landing page.
    kameleoonConversionScoresObjectMap of Kameleoon Conversion Scores (KCS). The keys of the map are the defined key moments names. The values are numbers from 0 to 100 representing the KCS for the given key moment.

    Device

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

    Properties
    NameTypeDescription
    browserStringName of the browser. Possible values are: Chrome, Chromium, Firefox, Safari, Microsoft Edge, Internet Explorer, Opera, Android, iPhone, iPad, iPod, Samsung Internet for Android, Opera Coast, Yandex Browser, UC Browser, Maxthon, Epiphany, Puffin, Sleipnir, K-Meleon, Windows Phone, Vivaldi, Sailfish, SeaMonkey, Amazon Silk, PhantomJS, SlimerJS, BlackBerry, WebOS, Bada, Tizen, QupZilla, Googlebot, Blink, Gecko, Webkit.
    browserVersionStringVersion of the browser.
    osStringName of the OS. Possible values are: Windows, Mac, Linux, Android, iOS, Chrome OS, Windows Phone.
    typeStringType of the device. Possible values are: Desktop, Tablet, Smartphone.
    screenHeightNumberHeight of the device's screen (in pixels).
    screenWidthStringWidth of the device's screen (in pixels).
    windowHeightNumberHeight of the browser's window (in pixels).
    windowWidthStringWidth of the browser's window (in pixels).
    timeZoneStringTime zone of the browser. The value is a String (for instance "Europe/Paris") that corresponds to the TZ database of time zones.

    Geolocation

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

    Properties
    NameTypeDescription
    countryStringCountry name, in English.
    regionStringName of the region, in the country's preferred language.
    cityStringName of the city, in the country's preferred language.
    postalCodeStringPostal code.
    latitudeNumberLatitude (in degrees).
    longitudeNumberLongitude (in degrees).

    Weather

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

    Properties
    NameTypeDescription
    temperatureStringTemperature in Kelvin.
    humidityStringHumidity in percentage (from 0 to 100).
    pressureStringAtmospheric pressure in hPa.
    windSpeedStringWind speed in meters/sec.
    cloudinessNumberCloudiness in percentage (from 0 to 100).
    sunriseNumberTime of sunrise (UTC format - ms since 1st January, 1970).
    sunsetNumberTime of sunset (UTC format - ms since 1st January, 1970).
    conditionCodeNumberWeather condition ID code. Full reference list is available here.
    conditionDescriptionStringWeather condition description. It is the description matching the conditionCode. For instance, a conditionCode of 800 would have a conditionDescription of clear sky.

    Experiment

    An Experiment object represents a Kameleoon A/B test. Its main properties are its segment (defining the conditions under which the experiment will be triggered) and the associated variations. Variations contain the JavaScript and CSS code that implement the changes needed to produce the desired end-result.

    Properties
    NameTypeDescription
    idNumberID of the experiment.
    NameStringName of the experiment.
    dateLaunchedNumberTime of first launch of the experiment (UTC format - ms since 1st January, 1970).
    dateModifiedNumberTime of last modification of the experiment (UTC format - ms since 1st January, 1970).
    activeBooleanBoolean equal to true if the experiment is currently active on the page, else to false.
    triggeredInVisitBooleanBoolean equal to true if the experiment was triggered in the current visit, else to false.
    targetSegmentObjectSegment object associated with the experiment.
    variationsArrayList of Variation objects for this experiment.
    associatedVariationObjectVariation object associated with the experiment for the given visitor. If the experiment was not yet triggered, this will usually be null, except if a pre-allocation was performed.
    trafficDeviationObjectMap of the traffic deviation currently used by the experiment. The keys of the map are the IDs of the variations in the experiment (by convention, the reference / original variation will always have an ID of 0). The values are percentage number from 0 to 100. Note that the sum of all the values in this map may not be equal to 100, since part of the traffic may be unallocated (untracked).
    goalsArrayList of Goal objects tracked for the experiment.
    mainGoalObjectGoal object representing the main goal of the experiment.
    untrackedTrafficReallocationTimeNumberTime of the last reallocation performed for untracked traffic (UTC format - ms since 1st January, 1970). If a reallocation was never performed, the value will be null. See this article for more details.

    Personalization

    A Personalization object represents a Kameleoon personalization action for a given segment. Its main properties are its segment (defining the conditions under which the personalization will be triggered and displayed) and the associated single variation. Technically, the Variation object is the same used by an Experiment. It contains the JavaScript and CSS code that implement the actual displayed personalization action.

    Properties
    NameTypeDescription
    idNumberID of the personalization.
    NameStringName of the personalization.
    dateLaunchedNumberTime of first launch of the personalization (UTC format - ms since 1st January, 1970).
    dateModifiedNumberTime of last modification of the personalization (UTC format - ms since 1st January, 1970).
    activeBooleanBoolean equal to true if the personalization is currently active and displayed on the page, else to false.
    triggeredInVisitBooleanBoolean equal to true if the personalization was triggered in the current visit, else to false. This means that the visit fulfilled the personalization's segment conditions at some point.
    displayedInVisitBooleanBoolean equal to true if the personalization's action was actually displayed (executed) in the current visit, else to false. Note that a triggered personalization does not necessarily imply that the associated action was displayed, since several additional factors can affect the execution of the action. For instance, capping options may prevent the execution, or the visitor may be part of a control group for this personalization (in which case Kameleoon also does not display the personalization's action).
    targetSegmentObjectSegment object associated with the personalization.
    associatedVariationObjectVariation object associated with the personalization. Note that contrary to the Experiment object, this property always links to a valid Variation object; it is never null.
    goalsArrayList of Goal objects tracked for the personalization.
    mainGoalObjectGoal object representing the main goal of the personalization.

    Variation

    A Variation object represents one of the main components of an Experiment. An A/B test experiment contains a list of variations (if the test contains 1 variation in addition to the original, it is usually called an A/B test, if it has 2 variations, an A/B/C test, and so on). Note that while an Experiment contains a list of variations, a Personalization has a reference and is associated to a single Variation object.

    Properties
    NameTypeDescription
    idNumberUnique id of the variation.
    NameStringName of the variation.
    reallocationTimeNumberTime of the last traffic reallocation performed for the variation (UTC format - ms since 1st January, 1970). If a reallocation was never performed, the value will be null. See this article for more details.

    Goal

    A Goal object represents a given KPI (Key Performance Indicator) that is tracked on the website. Goals are defined via Kameleoon's Back-Office.

    Properties
    NameTypeDescription
    idNumberID of the goal.
    nameStringName of the goal.
    typeStringType of the goal. Possible values are: CLICK, SCROLL, URL, ENGAGEMENT and CUSTOM.

    Segment

    A Segment object contains a list of criteria that must be fulfilled for the visit to belong to the segment. Note that on the Kameleoon platform, a Segment contains both "constant" conditions (such as age, location) and "triggering" conditions (such as the number of seconds ellapsed since the load of the page or the visit, or the total amount of items in the shopping cart).

    Properties
    NameTypeDescription
    idNumberID of the segment.
    nameStringName of the segment.

    Product

    A Product object describes a product in your catalog, with many attached information. However, most of the properties described here are optional and can be null.

    Properties
    NameTypeDescription
    idStringUnique ID of the product.
    nameStringName of the product.
    skuStringStock Keeping Unit (SKU) of the product.
    categoryIDStringUnique ID of the product's category.
    mainImageURLStringThe URL of the main image for this product.
    imageURLsArrayList of URLs for all the images related to this product.
    currentPriceNumberThe current price of the product.
    originalPriceNumberThe original price of the product, usually before discounts or promotions.
    brandStringName of the product's brand.
    availableQuantityNumberCurrent stock of the product.
    sizesArrayList of Sizes (as Strings) available for this product.
    merchantIDStringSeller / merchant ID of this product (in case your website operates a marketplace).