# SDK Methods

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](/docs/for-developers/for-developers/sdk-guides/identify-users.md) guide in order to pass a user id.

### Change user email

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

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

### Change user name

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

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

### **Change user attributes**

```javascript
window.jimo.push([ "set", "user:attributes", [object, object /* { refetchBoosted: boolean, removeUnspecified: boolean } */] ])

// 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 refetch boosted posts
window.jimo.push([ "set", "user:attributes", [ { foo : "hello" }, { refreshBoosted: true } ]])
// Example 3 : set the attribute foo and delete all unspecified one
window.jimo.push([ "set", "user:attributes", [ { foo : "hello" }, { removeUnspecified: true } ]])
// Example 4 : set the attribute foo and refresh the changelog
window.jimo.push([ "set", "user:attributes", [ { foo : "hello" }, { refreshChangelog: true } ]])
```

### **Force language**

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

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

// Example : Force language to fr and refresh live experiences
window.jimo.push([ "set", "core:language", [ "fr", true ] ])

// Example : Set back the language to auto (Browser configuration)
window.jimo.push([ "set", "core:language", [ null ] ])
```

We expect the passed languages to be one of those :

```
en, fr, es, pt, it, de, jp, zh, zh-hant, sk, sv, nl, fi, ru, cs, hu, pl, da, no, nb, nn, ro, sq, ar, id, lo, sr, uk, th, tr, vi, he, el, bg
```

## GET

### User Id

```javascript
window.jimo.push([ 'get', 'jimer:id' ]) // "d33c2af7-b228-49f5-b02a-bd9af14987ac"

// this method return the internal jimo id of the current user 
```

### User attributes

```javascript
window.jimo.push([ 'get', 'jimer:attributes' ]) // { foo : "bar" }

// this method will always return an empty object if attributes is undefined
```

### User segments

```javascript
window.jimo.push([ 'get', 'jimer:segments' ]) // ["744da3be-7512-41c8-a93c-78081d3629e5"]

// this method will always return an empty array
```

### User language

```javascript
window.jimo.push([ 'get', 'jimer:language' ]) // en
```

### Date of the last changelog opening

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

### Number of unread posts in changelog

```javascript
await window.jimo.push(['get', 'widget:unreadCount'])
```

{% hint style="info" %}
If you are using [Jimo Manual Init](/docs/for-developers/for-developers/sdk-guides/manual-initialization.md), we recommend using this method in the callback of our [identify method](/docs/for-developers/for-developers/sdk-guides/identify-users.md).
{% endhint %}

### Banner is visible

Return `true` if a banner is visible else `false`.

```javascript
window.jimo.push(['get', 'banner:visible']) // return boolean
```

### Banner height

Return the height of the current banner in `px`. Returns `0px` if there is no banner visible.

```javascript
window.jimo.push(['get', 'banner:height']) // return string (ex. "40px")
```

## DO

### Trigger an experience (formerly poke)

```javascript
// 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]])

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

### Open resource center

```javascript
// Open any eligible RC if there's one live
window.jimo.push(["do", "resource-center:open"]);
```

### Close resource center

```javascript
// Close any eligible RC if there's one live
window.jimo.push(["do", "resource-center:close"]);
```

{% hint style="info" %}
These commands will affect any RC currently allowed to display on the page (based on publication settings).
{% endhint %}

### Open changelog widget

```javascript
// 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' }]])
```

### **Close changelog widget**

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

### Reset widget last open date

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

### Boosted refresh

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

### Trigger badge find

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

### Show changelog trigger

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

### **Hide changelog trigger**

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

{% hint style="warning" %}
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.
{% endhint %}

```javascript
// 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>
```

### Reset storage

We recommend clearing the storage at logout if you are using the Jimo [identify.](/docs/for-developers/for-developers/sdk-guides/identify-users.md)

```javascript
// Clear localstorage data related to Jimo
window.jimo.push([ "do", "storage:reset" ])
```

### Track custom event

Send a custom client-side event to Jimo (for segmentation, success tracking, etc.).

<pre class="language-javascript"><code class="lang-javascript"><strong>// Track a custom event
</strong>window.jimo.push([ "do", "event:track", [ "&#x3C;EVENT_NAME>", { /* properties (optional) */ } ]]);

<strong>//Example
</strong><strong>window.jimo.push([ "do", "event:track", [ "Sign Up", { plan: "Pro", value: 29 } ]]);
</strong></code></pre>

{% hint style="info" %}

#### Parameters

* **`<EVENT_NAME>`** *(string, required)* – The event name (e.g., `"Sign Up"`, `"Checkout Succeeded"`).
* **`<properties>`** *(object, optional)* – Key/value metadata for the event\
  (e.g., `{ plan: "Pro", source: "banner", value: 29 }`).\
  Strings, numbers, booleans and ISO datetimes are recommended.
  {% endhint %}

## ON

### **Widget opened**

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

### **Widget closed**

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

### **Boosted closed**

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

## OFF

{% hint style="info" %}
To remove a listener, simply replace `on` by `off`. For example, `window.jimo.push(["off", "widget:opened"])` to remove the listener on `widget:opened`.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.usejimo.com/docs/for-developers/for-developers/sdk-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
