Manual Initialization

Let's see how to initialize Jimo whenever you want to

By default, Jimo will run automatically when a user visits a page where the snippet is installed. But you may want to prevent this and have control over when Jimo should start working.

Disable automatic initialization

If you want to prevent the script from loading automatically, you will have to add JIMO_MANUAL_INIT to your snippet integration (see the example below).

<script>
    window.jimo = [];
    (function(j,i,m,o) {
        var s = document.createElement("script");

        s.type = "text/javascript";
        s.async = true;
        s.src = "https://undercity.usejimo.com/jimo-invader.js";
        j['JIMO_PROJECT_ID'] = "YOUR_PROJECT_ID";

        j['JIMO_MANUAL_INIT'] = true; // <- Add this
        
        document.getElementsByTagName("head")[0].appendChild(s);
    })(window);
</script>

Initialize Jimo

To initialize Jimo, you will have to call the following command

window.jimoInit()

It's optionnal, but if you'd like to kill Jimo, you will have to call the following command

window.jimoKill()

Passing commands before Jimo is initialized

Even if Jimo is not yet initialized, we support buffering. In fact, you can still push commands that will be executed once you initialize Jimo.

With manual initialization, you should push commands before initializing Jimo to make sure they are executed in the correct order after calling jimoInit()

Here is a simple example that shows how to identify a user and then initialize manually Jimo

function launchJimo(user) {
    // Buffer some commands before initialize
    window['jimo'].push(['do', 'identify', [user.id]]);
    window['jimo'].push(['set', 'user:name', [user.username]]);
    
    // Initialize Jimo
    window.jimoInit();
}

Last updated