No description or website provided.
JavaScript CSS HTML
Latest commit 696a4e3 May 18, 2016 Rafał Sarzyński fix popup showing

README.md

Synerise SDK for JavaScript

The Synerise JavaScript SDK is designed to be simple to develop and allows you to easily integrate the SyneriseSDK software with your web application. For more information about Synerise visit the Synerise Website.

System requirements

  • You need to add the Synerise’s tracking codes into your website. You can find it in the Synerise Settings, in the Tracking code submenu. Alternatively, please sign up to your business profile in Synerise and open this location.

How to install the library

To start using the Synerise JavaScript SDK, just paste the following code into your web page inside the <head> and </head> tags.

    <script>
        function onSyneriseLoad() {
            SR.auth.apiKey('YOUR_API_KEY');
            SR.init();
        }

        (function(s,y,n,e,r,i,se){s['SyneriseObjectNamespace']=r;s[r]=s[r]||[],s[r]._t=1*new Date(),
        s[r]._i=0,s[r]._l=i;var z=y.createElement(n),se=y.getElementsByTagName(n)[0];z.async=1;z.src=e;
        se.parentNode.insertBefore(z,se);z.onload=z.onreadystatechange=function(){var rdy=z.readyState;
        if(!rdy||/complete|loaded/.test(z.readyState)){s[i]();z.onload = null;z.onreadystatechange=null;}};
        })(window,document,'script','https://app.synerise.com/js/sdk/synerise-javascript-sdk-latest.min.js','SR', 'onSyneriseLoad');
    </script>

The library provides a global variable named SR that can be used to send data to Synerise. You can its name in the last line of the presented code('SR').

Remember that the SP variable can be used, when the onSyneriseLoad function is loaded, which is realised automatically by the Synerise SDK.

Configuration and setup

To move to the next step of configuration, you have to create a business profile in Synerise. Learn how to do it here (http://synerise.com/faq_entry/how-to-create-my-synerise-business-profile/). If your business profile has already been created and configurated, the unique API-key will be created. After that you will be able to copy the API-key, which is necessary to send request to the Synerise API.

In the previous step the onSyneriseLoad function was presented:

    function onSyneriseLoad() {
        SR.auth.apiKey('YOUR_API_KEY');
        SR.init();
    }

Make sure to fill in the YOUR_API_KEY parameter with your unique Api-Key. You can get an Api-Key by logging in on app.synerise.com and going to Settings menu and then API submenu.

Using promises

A JavaScript promise represents the result of an asynchronous operation. Promises can be in one of three states: pending, fulfilled or rejected. To access a promise's fulfilled value or rejection reason, register your handler to the promise's Then method.

The JavaScript client library provides the Promises/A+-conformant interface. Using promises gives also you elegant error handling and easy chaining.

An example of a single request:

    SR.event.track('Add to favourites').then(function(response) {
      // Handle response
    }, function(reason) {
      // Handle error
    });

or

    SR.event.track('Add to favourites').then(function(response) {
      // Handle response
    }).catch(function(reason) {
      // Handle error
    });

Events tracking

If you want to inform Synerise about actions performed by users inside app, use the Synerise event manager SP.event and the track method.

    // Track an event
    SR.event.track();

First parameter is an event name that you want track and second are optional parameters you want to have associated with this event

    // e.g. track "add product to favourites" event
    SR.event.track('Add to favourites', {
        'producName': 'iPhone 6',
        'productCategory': 'Smartphones'
    });

    // e.g. track "choose point on map" event
    SR.event.track('Choose point on map', {
        'map': 'deliveryPoints',
        'points': 12
    });

Identifying Users

Tracking codes allow the identification of the client and his relationship with the existing profile. All events generated by such client are associated with the profile of the identified person.

In the future you will be able to take full advantage of the Customer Identify key. This is the identification key, which is not assigned by Synerise. It allows additional client identification, and also to associate clients with external database (e.g. the list of your online shop clients) with clients saved in the Synerise data base.

Dynamic content

Synerise enables you to create and send rich dynamic content to clients who are browsing your website. This is a very powerful feature! You can use it to show personalized notifications, ads or whatever you want.

Go to the Dynamic contents menu to use it.

When the library will be initialized the JavaScript SDK will automatically check for a dynamic content. It’s available for the current client, it will be displayed immediately in the specified place. You can define where and when dynamic content will be presented.