# Visii Analytics library

For ease of sending important events to Visii, we provide a va.js script that can be inserted into your page. Once added, calling the track function will send the event to Visii.

Data verification

The library does no client-side checks on the events or fields being sent, so please adhere to the correct format and structure we provide in the documentation.

!function(){var a=window.visii=window.visii||[];a.invoked?window.console&&console.error&&console.error("Visii analytics snippet was added twice."):(a.invoked=!0,a.track=function(){var e=Array.prototype.slice.call(arguments);return a.push(e),a},a.load=function(e){var o=document.createElement("script");o.type="text/javascript",o.async=!0;var i="https://cdn.visii.com/visii.com/va"+("function"==typeof window.fetch?"":"p")+".js";o.src=i;var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(o,t),a.config=e},a.load({
  organisation:"<organisation>",
  dataset:"<dataset>",
  token:"<token>",
  userCookie: { anonymous_id: "<anonymous-cookie>", user_id: "<user-id>" }
}),a.track("Page Loaded", {page_type:"other"}))}();

Replace in the above script your dataset details:

Field Type Required Value Description
organisation String yes The organisation name
dataset String yes The dataset name
token String yes The dataset API token

userCookie

Object

no

The cookie name that contains user identifiers: { anonymous_id: "_anon_cookie", user_id: "_user_cookie" }

# Usage

To send analytics to Visii, just call the track function:

Field Type Required Value Description
event-name String yes The event name
data Object no Details associated with the event
window.visii.track("event-name", dataObject);

The track function is using internally the /track endpoint described in the Analytics API.

See below a few examples of using the track function. The dataObject has a predefined structure for Standard Events and a more flexible structure for Custom Events.

window.visii.track("Product Clicked", {
  product_id: "735583523"
});
window.visii.track("Order Completed", {
  currency: "USD",
  tax: 10,
  total_price: 103,
  order_id: "oid293483",
  shipping: 5,
  items: [
    {
      id: "994949",
      price: 22,
      quantity: 1,
      sku: "p29473-C",
      size: "child"
    },
    {
      id: "994949",
      price: 33,
      quantity: 2,
      sku: "p29473-A",
      size: "adult"
    }
  ]
});
Last Updated: 8/4/2020, 4:44:48 PM