JavaScript SDK

General Description

JavaScript SDK allows your website to communicate with the Maestra framework asynchronously. It can be integrated just like Google Analytics or Yandex.Metrics without affecting page load speed and tracker operation.

To operate the JavaScript SDK, a single "maestra” object is used. Methods are called like this: maestra('methodName', methodParameters, ... )

Here methodParameters can be either a string or an object. The expression above allows you to invoke methods anywhere on the page after the initialization code. If JavaScript SDK code hasn’t loaded yet, tasks will be queued and will start processing as soon as script initialization completes.

<script>
    maestra = window.maestra || function() { maestra.queue.push(arguments); };
    maestra.queue = maestra.queue || [];
    maestra('create', {
        endpointId: '<access point ID>'
    });
</script>
<script src="https://api.maestra.io/scripts/v1/tracker.js" async></script>
maestra = window.maestra || function() { maestra.queue.push(arguments); };
maestra.queue = maestra.queue || [];
maestra('create', {
  endpointId: '<access point ID>'
});

var script = document.createElement("script");
script.src = "https://api.maestra.io/scripts/v1/tracker.js";
document.getElementsByTagName('head')[0].appendChild(script);

Initialization code should be included on top of page prior to any other JavaScript SDK calls.