SDK Methods

List of commands available with our SDK

The SDK includes 5 types of methods :

  • set, to set or update something - window.jimo.push([ "set", method, [values] ])

  • get, to get a value - window.jimo.push([ "get", getter ])

  • do, to perform something - window.jimo.push([ "do", method, [parameters] ])

  • on, to listen to an event - window.jimo.push([ "on", method, [listener] ])

  • off, to stop listening to an event - window.jimo.push([ "off", method ])

SET

Change user id

Please check our Identify users guide in order to pass a user id.

Change user email

window.jimo.push([ "set", "user:email", [email] ])

// Example
window.jimo.push([ "set", "user:email", ["john.doe@domain.com"] ])

Change user name

window.jimo.push([ "set", "user:name", [username] ])

// Example
window.jimo.push([ "set", "user:name", ["john"] ])

Change user attributes

window.jimo.push([ "set", "user:attributes", [object, boolean /* refetchBoosted */] ])

// Example 1 : set the attribute foo and bar
window.jimo.push([ "set", "user:attributes", [ {foo : "hello", bar: "world" } ] ])
// Example 2 : set the attribute foo and bar and refetch boosted posts
window.jimo.push([ "set", "user:attributes", [ {foo : "hello", bar: "world" }, true ]])

Force language

window.jimo.push(['set', 'core:language', [string /* language */]])

// Example : Force language to fr
window.jimo.push([ "set", "core:language", [ "fr" ] ])

We expect the passed languages to be one of those :

  • en

  • fr

  • es

  • pt

  • it

  • de

  • jp

  • zh

  • sk

GET

Date when the user opened the widget for the last time

Useful if you want to implement custom logic based on the last time the user has opened the widget. For example, hide your custom What's new button if there is no new content in the widget.

window.jimo.push(['get', 'widget:lastOpenDate'])

DO

Open widget

// Open the widget
window.jimo.push([ "do", "widget:open" ])

// Open the widget to a specific page
// - page values : eedback
window.jimo.push(['do', 'widget:open', [{ page: 'feedback' }]])

// Open the widget to a specific experience(formerly poke)
window.jimo.push(['do', 'widget:open', [{ evolutionId : 'uuid_of_evolution' }]])

Trigger an experience (formerly poke)

// Trigger/open a specific experience
window.jimo.push(['do', 'boosted:trigger', [{ evolutionId : 'uuid_of_evolution' }]])

// Trigger an experience and bypass the recurrences rules
window.jimo.push(['do', 'boosted:trigger', [{ evolutionId : 'uuid_of_evolution' }, true]])

Close widget

// Close the widget (if opened)
window.jimo.push([ "do", "widget:close" ])

Reset widget last open date

// Reset the date of the last time the user opened the widget
window.jimo.push([ "do", "widget:resetOpenDate" ])

Boosted refresh

// Refresh the list of boosted pushes
window.jimo.push([ "do", "boosted:refresh" ])

Trigger badge find

// Find badge's triggers (require widget trigger mode to be "badge")
window.jimo.push([ "do", "trigger-badge:find" ])

Show trigger

// Show the Jimo trigger
window.jimo.push([ "do", "trigger:show" ])

Hide trigger

// Hide the Jimo trigger
window.jimo.push([ "do", "trigger:hide" ])

By default, the trigger is set to show. You can set the trigger to hide by default, using window.jimo["JIMO_DEFAULT_TRIGGER_HIDDEN"] = true; when the script is loaded, see example bellow.

    // Example 
    <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_DEFAULT_TRIGGER_HIDDEN"] = true; // add this

        document.getElementsByTagName("head")[0].appendChild(s);
      })(window);
    </script>

ON

To remove a listener, simply replace on by off. For example, window.jimo.push(["off", "widget:opened"]) to remove the listener on widget:opened.

Widget opened

// Event triggered when widget is opened
window.jimo.push([ "on", "widget:opened" ])

Widget closed

// Event triggered when widget is closed
window.jimo.push([ "on", "widget:closed" ])

Boosted closed

// Event triggered when a boosted push is closed
window.jimo.push([ "on", "boosted:closed" ])

Last updated