NAV Navbar
javascript
  • Introduction
  • Getting started
  • Installation
  • Initialization
  • Users
  • Additional settings
  • Introduction

    Welcome on the Javascript Omnisense SDK Documentation v1.0. You can use these to retrieve and add informations on your Omnisense instance.

    Omnisense is an omnicanal CRM.

    With Omnisense, you can manage the entire lifecycle of your users : Acquisition, Segmentation, Reengagement.

    Acquisition : Omnisense is connected to the main advertising companies of the market and will allow you to manage your acquisition easily.

    Segmentation : Retrieve all your user data within a clear and intuitive interface and segment them in a few clicks.

    Reengagement : Push, mails, sms ... You can reengage your users with all possible and unimaginable means...

    Getting started

    The Javascript Omnisense SDK has 2 main purposes:

    Dependencies :

    And... that's all !

    Installation

    <head>
      <!-- METAS -->
      <!-- CSS -->
      <!-- JS -->
      <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
      <script src="https://code.omnisense.io/omnisense-1.0.min.js"></script>
      <!-- /METAS -->
    </head>
    

    There is only to steps to get Omnisense working on your website.

    Initialization

    $(document).ready(function() {
      var API_KEY = "1234567890abcdef09876543210abcde";
      var INSTANCE = "YOUR_INSTANCE";
    
      var omnisense = new Omnisense(API_KEY, INSTANCE);
    
      omnisense.start();
    });
    

    Once the page is fully loaded, you can initialize Omnisense. To do so, you must set your Omnisense instance identifier and API KEY, which have been provided by the Omnisense Team.

    On first call of start() function, a cookie with a unique identifier is created to identify the user wheter he is connected or not.

    Once the start() function has been called, you can now send user's data and actions.

    Users

    Post Informations

    Method name : updateUser(user: Hash, metadata: Hash)

    User Registration Let's say the user is registering. Once he clicks the signup button, we can update his profile on Omnisense

    $(document).ready(function() {
      // ... OMNISENSE INITIALIZATION
    
      omnisense.updateUser({
        "email": "emailaddress@provider.com",
        "first_name": "John",
        "last_name": "Doe",
        "lang": "fr",
        "country": "FR",
        "postal_code": "66000"
      });
    });
    

    User Login Let's say the user is logging in. Once he clicks the login button, we can update his profile on Omnisense

    $(document).ready(function() {
      // ... OMNISENSE INITIALIZATION
    
      omnisense.updateUser({
        "email": "emailaddress@provider.com"
      });
    });
    

    Metadatas If your want to store any other informations not matching the attributes allowed for the user, you have to use the metadata param. You can only store set of key/values in metadata.

    $(document).ready(function() {
      // ... OMNISENSE INITIALIZATION
    
      omnisense.updateUser({}, {
        "purchase_count": "5"
      });
    });
    

    Method Informations

    Function name: updateUser(Hash, Hash)

    Method Parameters

    Parameter Value Description
    user Hash For the list of allowed attributes, see below.
    metadata Hash Set of key/values to store additional informations

    User Hash

    Parameter Value Description
    email String
    fb_id String
    first_name String
    last_name String
    birthday Date
    phone String
    address String
    city String
    postal_code String
    country String must be the iso code for country (ISO 3166)
    lang String must be the iso code for lang (ISO 639)
    sex String One of "male", "female"
    optin Boolean Set to true if the user is optin to receive email
    optin_sms Boolean Set to true if the user is optin to receive SMS
    registered Boolean Set to true if the user has signed up to your website
    custom_event_date Date
    company String

    Tracking

    User event tracking Let's say the user is looking a product. When the page is loaded you could do something like that to track your user for looking a product.

    $(document).ready(function() {
      // ... OMNISENSE INITIALIZATION
    
      var productParameters = {
        "id": "1234",
        "name": "foo",
        "price": "25",
        "currency": "EUR",
        "media": "website"
      };
    
      omnisense.trackEvent("product.view", productParameters);
    
      // OR...
    
      omnisense.trackEvent("product.view", productParameters, function() {
          // Callback, you can do whatever you want here.
      });
    });
    

    User event tracking: Comment Your user just posted a comment on your product.

    $(document).ready(function() {
      // ... OMNISENSE INITIALIZATION
    
      $("#postComment").on('click', function() {
        var commentParameters = {
          "id": "1234",
          "name": "foo",
          "media": "website",
          "comment": "lorem ipsum...",
          "note": "5"
        };
    
        omnisense.trackEvent("product.postcomment", commentParameters);
    
        // OR...
    
        omnisense.trackEvent("product.postcomment", commentParameters, function() {
            // Callback, you can do whatever you want here.
        });
      });
    });
    

    Method Informations

    Function name: trackEvent(identifier: String, segments: Hash [, callback: Callback])

    Method Parameters

    Parameter Value Description
    identifier String The action name
    segments Hash Set of key/values describing the event

    Optional Parameters

    Parameter Value Description
    callback Callback This callback will be fired after the action is saved

    Additional settings

    //I'm on a mobile website
    omnisense.setOrigin("mobile_website");
    

    The Javascript sdk send automatically a flag indicating the informations are tracked from "website". If you want to change this flag, you can by calling setOrigin() function. Call it before calling start() function, otherwise you could send the wrong flag to Omnisense.