> For the complete documentation index, see [llms.txt](https://help.smartico.ai/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.smartico.ai/welcome/products/crm-automation/activities-of-flows/activity-js-code.md).

# Activity: JS Code

Activity "JS Code" provides possibility to execute custom JavaScript code in the browser of the user that is online.

<figure><img src="/files/gGinKw0Rflzy4cd5DrOA" alt=""><figcaption></figcaption></figure>

Important to note that in order to be executed, the user should be online on your side, so the activity should be triggered when you are confident that user is on site, for example you can use "Wait for event" with event "User went online", or product specific activities that are done on the web site, e.g. deposit, request for withdrawal, bet, etc.

You can also use "Delivery timeout", in order to overcome cases when user went offline for some period of time, by default 20 seconds. For example:

* You build a campaign that is triggered on the first login during the day and is supposed to execute some JavaScript code.
* There is a chance that right after login, the user is redirected to another page, which means that he was "offline" for a short period of time while navigating to another page.
* Delivery timeout is supposed to handle such cases and deliver Popup to users on next time when he will be online within defined period

Some ideas of what you can do with "JS Code"

* Use own JavaScript methods, for example trigger opening of the deposit page
* Use 3rd party libraries APIs, e.g. trigger an event in the Google Analytics or start browser screen recording with HotJar or with Microsoft Clarity, or mark conversion with FaceBook AD API.
* Use [Smartico front-end API (extended integration)](/welcome/technical-guides/front-end-integration/extended-integration.md) to trigger different actions, for example to change an avatar of user - `_smartico.setAvatar("https://somesite.com/avatar.png");`
* Use [Smartico front-end API](https://github.com/smarticoai/public-api/blob/main/docs/classes/WSAPI.md) to do any actions with gamification setup, for example register in the tournament when user does a deposit with code like `_smartico.api.registerInTournament(12345)` or opt-in user in the specific mission with code like `_smartico.api.requestMissionOptIn(12345)`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://help.smartico.ai/welcome/products/crm-automation/activities-of-flows/activity-js-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
