Installing Sajari

If you currently use Google Tag Manager, please see instructions on installing sajari via GTM here.
Otherwise please add the following code to your global template, preferably in the "HEAD" of each page.

If you haven't signed up with Sajari yet, you can sign up here.


Global Install code

For website installs, Sajari is installed using a small HTML code snippet. This snippet performs several functions:

  • to know when new pages exist (quickly index new pages)
  • to see which pages are popular (improve site search and recommendations)
  • to track site search and recommendations performance (report statistics back to you)
  • to later install site search and/or recommendations with simple HTML attributes (save you time)


Copy the code

Below is the generic install code to connect your website to Sajari. This code is asynchronous and will not slow your site down. It will also not interfere with existing search or recommendations functionality. This is just a base install to connect instant indexing of your site content and to enable other functions to be installed when you choose to do so.

In the below code, please replace <PROJECT> and <COLLECTION> with your actual company and collection names.


<script type="text/javascript">
    var _sj = _sj || [];
    _sj.push(['company', '<PROJECT>']);
    _sj.push(['collection', '<COLLECTION>']);
    (function () {
        var sj = document.createElement('script');
        sj.type = 'text/javascript';
        sj.async = true;
        sj.src = '//cdn.sajari.com/js/sj.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(sj, s);
    })();
 </script>


Further assistance

If you are having trouble with the above, please contact us so we can assist.

If you're also ready to begin adding search and recommendations functionality to your site, see our documentation for site search and recommendations widgets.

Events

In order to see how your site search and recommendations widgets are impacting your site conversion, it's important to add conversion tracking. Click through statistics for search and recommendations are quite useful, but tracking that through to conversion is even more powerful.


Conversions

There are two ways to track conversions. The first is to add the relevant code to an HTML element on the page. As the page is loaded, our library will detect this information and automatically send it to the Sajari server. You can put this information on any element, but keep in mind a conversion will be sent for each item on the page. We suggest sending the value in cents. An example is shown below:

<span data-sj-conv-type="sale" data-sj-conv-val="2000"></span>


The other method to send conversions is to trigger the JavaScript directly. This is done using the following code, which can be triggered anywhere after the Sajari install code on the page.

_sj.push(['conversion','sale', 2000]);



Add free text and meta information to the current users profile

If you have specific text (unstructured) or meta (structured) information that you think is useful to help profile the current user, you can add this information using the following function:

_sj.push(['profile', 'free text to bind to the user', {name:'roger', value:'high', groups:'B;C;F', customer_type:'existing'}]);


Successful businesses use Sajari