# "Client action" event

Smartico has a special type of event called "Client action".

Such actions can be triggered from the front-end or through the REST API and can start real-time campaigns (Journeys), Automation rules, and progress/complete Missions or Badges.

{% hint style="info" %}
In order to see the "Client action" value in the Smartico BackOffice, you need to trigger it at least once; the triggered value will appear within 30 minutes in Smartico BackOffice automatically.

You can also register "Client action" manually in the Smartico BackOffice \ Tools \ Properties. Search for "Client action" property and use the "+" sign to add an action.
{% endhint %}

<div data-with-frame="true"><figure><img src="https://77049817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfS5hl0PiysHtKAKMsQTe%2Fuploads%2Fgit-blob-bb9314fdc4efda69d6b86b76e3ee66810e5cd905%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

## How to trigger client action from the front-end

You can report a specific action done by the end-user, for example, when the user is clicking on the submit button on the cashier page, you can report the action 'CashierSubmitClicked'.

```javascript

_smartico.action('CashierSubmitClicked');

```

As soon as the action is defined and triggered at least once, you can build a real-time journey to react to such an action.

<div data-with-frame="true"><figure><img src="https://77049817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfS5hl0PiysHtKAKMsQTe%2Fuploads%2Fgit-blob-1ea2c4c6e8c31debb4ad334b3d882a1011f7f2ee%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

You can also pass additional parameters in the event, like

```
_smartico.action('PIGGY-BANK-CLICK', { prize: 'ABC' }); 
```

In the backoffice, in the Query Builder, you can validate the value of the event payload (read [Query Builder](https://help.smartico.ai/welcome/crm-automation/segmentation/query-builder#event-evaluation-in-query-builder) article for more details about event evaluation)

<div data-with-frame="true"><figure><img src="https://77049817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfS5hl0PiysHtKAKMsQTe%2Fuploads%2Fgit-blob-79ae33d6de6858b8db71f22ce39840216187843a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

## Triggering a custom action through the URL (or any other deep link) <a href="#triggering-custom-action-through-the-url-or-any-other-deep-link" id="triggering-custom-action-through-the-url-or-any-other-deep-link"></a>

In some cases, you may want to start a campaign when the user reaches a specific page.

One option is to pass a special parameter in the URL of any of your pages.

For example, you can build a URL like:

```url
https://mycasino.com/deposit.html#_smartico_dp=dp%3Aaction%26action%3DDEPOSIT_OPENED
```

When a user comes on this page, you can catch him with the campaign waiting for the "Core: client action" and action DEPOSIT\_OPENED

<div data-with-frame="true"><figure><img src="https://77049817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfS5hl0PiysHtKAKMsQTe%2Fuploads%2Fgit-blob-fa00e91db37f2e8b361899f8feb919d8ddf09874%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Note: the passed parameter in our example is "dp:action\&action=TEST5" which is "URL Encoded". You can also pass any other deep links that will be triggered automatically after the user is logged in

## Trigger client action through the REST API

You can send client action using a server-to-server approach using Smartico REST API.

You can find details of the REST API in Smartico BackOffice \ Tools \ REST API (requires special permissions, as it contains secret keys that should be kept private).

<div data-with-frame="true"><figure><img src="https://77049817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfS5hl0PiysHtKAKMsQTe%2Fuploads%2Fgit-blob-b0ddb1ea1f10585445db9595a83db4410365700c%2Fimage.png?alt=media" alt=""><figcaption><p>Example of payload in the REST API request</p></figcaption></figure></div>

The payload of the request should contain one required field called "**client\_action**" and may contain any other information.\
The event payload may include links to reset the password, email verification, or whatever you decide.

For example, your payload may look like

```jsonp
{
    "eid": "98866720-1ae7-452c-bc08-1b703954d2ea",
    "event_date": 1737986306201,
    "ext_brand_id": "spacex",
    "user_ext_id": "test98635568",
    "event_type": "client_action",
    "payload": {
        "client_action": "reset_password",
        "url": "https://mysitecom/reset?code=WREWSREGS"
    }
}
```

\
To handle this event, you need to prepare a real-time campaign triggered by the "Client action" event with Client action = "reset\_password" (or any other name you choose).

Within the campaign, you will send an email at the start. And inside the mail resource, you will write something like this

```html
Here is your link to reset password - <a href="{{event.url}}">click here</a>
```

Another case, you want to inform the client that he got a cashback.

```jsonp
{
    "eid": "98866720-1ae7-452c-bc08-1b703954d2ea",
    "event_date": 1737986306201,
    "ext_brand_id": "spacex",
    "user_ext_id": "test98635568",
    "event_type": "client_action",
    "payload": {
        "client_action": "cashback_ready",
        "cashback_amount": 44.22,
        "cashback_currency": "USD",
        "url": "https://mysitecom/activate_cashback?code=WREWSREGS"
    }
}
```

An example of email:

```html
You got {{event.cashback_amount}} {{event.cashback_currency}} in cashback, 
<a href="{{event.url}}">click here to activate</a>
```

You can validate any parameters of the event payload in the Query Builder. See more details in the [#event-evaluation-in-query-builder](https://help.smartico.ai/welcome/crm-automation/segmentation/query-builder#event-evaluation-in-query-builder "mention")
