> For the complete documentation index, see [llms.txt](https://docs.dfinery.ai/developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event.md).

# Event

How to record user events using the DFINERY SDK. [SDK integration](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/integration) must be done first.

### Before you start <a href="#undefined" id="undefined"></a>

Before linking events, you need to register events in [the DFINERY console](https://console.dfinery.ai/). To register events, go to the console's Additional Settings > Data Linking > Event Management > Event List page and click the Create Event button to create standard and custom events.

{% hint style="warning" %}
Events are not logged if an unregistered event, an event property, an event property of the wrong type, or a registered event property is missing.
{% endhint %}

### Event Log <a href="#undefined-1" id="undefined-1"></a>

`logEvent`Log user events using methods. [Standard events](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#predefinded_event) provide constants.

```javascript
logEvent(eventName);

logEvent(eventName, properties);
```

Each parameter means:

* `eventName`: Event Name
* `properties`: Event properties

{% hint style="warning" %}
Required values ​​vary for each standard event. Please check and use.
{% endhint %}

#### Event log example <a href="#undefined-2" id="undefined-2"></a>

{% tabs %}
{% tab title="Javascript" %}

```javascript
// When recording only events ex) When using constants
Dfinery.logEvent(DFEvent.LOGIN);

// Alternatively, you can enter the event property name directly.
Dfinery.logEvent("df_login");

// When recording with event properties ex) Sign up
const properties = {};
properties[DFEventProperty.SIGN_CHANNEL] = "Kakao";
Dfinery.logEvent(DFEvent.SIGN_UP, properties);
```

{% endtab %}
{% endtabs %}

### Standard Events & Product Attributes <a href="#and" id="and"></a>

Standard events and standard event properties, product properties are as follows. They can also be used as event names.

#### Standard Events <a href="#predefinded_event" id="predefinded_event"></a>

Standard event names are provided as predefined static constants:

| Constant                       | Event name                 | Notation name              |
| ------------------------------ | -------------------------- | -------------------------- |
| `DFEvent.LOGIN`                | df\_login                  | Log in                     |
| `DFEvent.LOGOUT`               | df\_logout                 | Log out                    |
| `DFEvent.SIGN_UP`              | df\_sign\_up               | Join the membership        |
| `DFEvent.PURCHASE`             | df\_purchase               | Purchase                   |
| `DFEvent.VIEW_HOME`            | df\_view\_home             | View Home Screen           |
| `DFEvent.VIEW_PRODUCT_DETAILS` | df\_view\_product\_details | View product details       |
| `DFEvent.ADD_TO_CART`          | df\_add\_to\_cart          | Put in a shopping cart     |
| `DFEvent.ADD_TO_WISHLIST`      | df\_add\_to\_wishlist      | Add to Wishlist            |
| `DFEvent.REFUND`               | df\_refund                 | Cancel order               |
| `DFEvent.VIEW_SEARCH_RESULT`   | df\_view\_search\_result   | Search for products        |
| `DFEvent.SHARE_PRODUCT`        | df\_share\_product         | Share this product         |
| `DFEvent.VIEW_LIST`            | df\_view\_list             | View product list          |
| `DFEvent.VIEW_CART`            | df\_view\_cart             | View Cart                  |
| `DFEvent.ADD_PAYMENT_INFO`     | df\_add\_payment\_info     | Enter purchase information |
| `DFEvent.REMOVE_CART`          | df\_remove\_cart           | Delete Cart                |

#### Standard event properties <a href="#undefined-4" id="undefined-4"></a>

For property names of standard events, event property names are provided as predefined static constants as follows:

| Constant                                | Event attribute name        | Notation name                      |
| --------------------------------------- | --------------------------- | ---------------------------------- |
| `DFEventProperty.ITEMS`                 | df\_items                   | Goods                              |
| `DFEventProperty.TOTAL_REFUND_AMOUNT`   | df\_total\_refund\_amount   | Total refund (cancellation) amount |
| `DFEventProperty.ORDER_ID`              | df\_order\_id               | Order Number (ID)                  |
| `DFEventProperty.DELIVERY_CHARGE`       | df\_delivery\_charge        | Shipping Fee                       |
| `DFEventProperty.PAYMENT_METHOD`        | df\_payment\_method         | Payment Method                     |
| `DFEventProperty.TOTAL_PURCHASE_AMOUNT` | df\_total\_purchase\_amount | Order Total                        |
| `DFEventProperty.SHARING_CHANNEL`       | df\_sharing\_channel        | Product sharing channel            |
| `DFEventProperty.SIGN_CHANNEL`          | df\_sign\_channel           | Product Discount Price             |
| `DFEventProperty.KEYWORD`               | df\_keyword                 | Search Keywords                    |

#### Product Attributes <a href="#item_property" id="item_property"></a>

Information about predefined property values ​​for products loaded as an array in DFEventProperty.ITEMS. ITEM\_ID, ITEM\_NAME, ITEM\_PRICE, ITEM\_QUANTITY, ITEM\_DISCOUNT are required values ​​and must be included.

| Constant                         | Event attribute name | Type   | Explanation            | Essential |
| -------------------------------- | -------------------- | ------ | ---------------------- | --------- |
| `DFEventProperty.ITEM_ID`        | df\_item\_id         | String | Product Number (ID)    | ✅         |
| `DFEventProperty.ITEM_NAME`      | df\_item\_name       | String | Product Name           | ✅         |
| `DFEventProperty.ITEM_PRICE`     | df\_price            | Number | Product unit price     | ✅         |
| `DFEventProperty.ITEM_QUANTITY`  | df\_quantity         | Number | Product Quantity       | ✅         |
| `DFEventProperty.ITEM_DISCOUNT`  | df\_discount         | Number | Product Discount Price | ✅         |
| `DFEventProperty.ITEM_CATEGORY1` | df\_category1        | String | Product Category 1     |           |
| `DFEventProperty.ITEM_CATEGORY2` | df\_category2        | String | Product Category 2     |           |
| `DFEventProperty.ITEM_CATEGORY3` | df\_category3        | String | Product Category 3     |           |
| `DFEventProperty.ITEM_CATEGORY4` | df\_category4        | String | Product Category 4     |           |
| `DFEventProperty.ITEM_CATEGORY5` | df\_category5        | String | Product Category 5     |           |

### &#x20;Example of using standard events <a href="#undefined-5" id="undefined-5"></a>

#### log in <a href="#undefined-6" id="undefined-6"></a>

This is an event that indicates the user's action of logging in. If you set the user's Identity before calling the login event, you can measure it as the Login event for that user. The logEvent function must be called after executing the setIdentity function within the async function.

{% tabs %}
{% tab title="Javascript" %}

```javascript
async function DfineryLogin() {
  // Setting user identification information
  await Dfinery.setIdentity(DFIdentity.EXTERNAL_ID, "TestUserId");
  // login event
  Dfinery.logEvent(DFEvent.LOGIN);
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
`Dfinery.setIdentity`If you execute Login without waiting for the API, it may not be measured as a Login event for a user who has set Identity, so it must be called after Identity has been set using await or promise.then function.
{% endhint %}

#### log out <a href="#undefined-8" id="undefined-8"></a>

This event indicates that a user is logging out.

{% tabs %}
{% tab title="Javascript" %}

```javascript
Dfinery.logEvent(DFEvent.LOGOUT);
```

{% endtab %}
{% endtabs %}

#### Join the membership <a href="#undefined-10" id="undefined-10"></a>

This event indicates the action taken by a user to sign up as a member.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const properties = {};
properties[DFEventProperty.SIGN_CHANNEL] = "Kakao";
Dfinery.logEvent(DFEvent.SIGN_UP, properties);
```

{% endtab %}
{% endtabs %}

**Standard event properties**

| Name                           | Type   | Explanation        | Essential |
| ------------------------------ | ------ | ------------------ | --------- |
| `DFEventProperty.SIGN_CHANNEL` | String | Membership Channel | ✅         |

#### Purchase <a href="#undefined-13" id="undefined-13"></a>

An event that represents a user's action of purchasing a product or service.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 6;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
properties[DFEventProperty.PAYMENT_METHOD] = "BankTransfer";
properties[DFEventProperty.ORDER_ID] = "Order-123";
properties[DFEventProperty.TOTAL_PURCHASE_AMOUNT] = 30000;
properties[DFEventProperty.DELIVERY_CHARGE] = 2500;
properties[DFEventProperty.DISCOUNT] = 3000;

Dfinery.logEvent(DFEvent.PURCHASE, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                                    | Type   | Explanation                                                                                          | Essential |
| --------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS`                 | Array  | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |
| `DFEventProperty.ORDER_ID`              | String | Order Number (ID)                                                                                    | ✅         |
| `DFEventProperty.PAYMENT_METHOD`        | String | Payment Method                                                                                       | ✅         |
| `DFEventProperty.TOTAL_PURCHASE_AMOUNT` | NUMBER | Order Total                                                                                          | ✅         |
| `DFEventProperty.DELIVERY_CHARGE`       | NUMBER | Shipping Fee                                                                                         | ✅         |
| `DFEventProperty.DISCOUNT`              | NUMBER | Product discount price                                                                               | ✅         |

#### View Home Screen <a href="#undefined-16" id="undefined-16"></a>

This event indicates that the user is viewing the app's home screen.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const properties = {};
properties["key"] = "value"; //Custom property value (Optional)
Dfinery.logEvent(DFEvent.VIEW_HOME, properties);
```

{% endtab %}
{% endtabs %}

#### View product details <a href="#undefined-18" id="undefined-18"></a>

This event represents an action taken by a user to view detailed information about a specific product.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
Dfinery.logEvent(DFEvent.VIEW_PRODUCT_DETAILS, properties);
```

{% endtab %}
{% endtabs %}

#### Put in a shopping cart <a href="#undefined-20" id="undefined-20"></a>

This event represents the action of a user adding a product to the shopping cart.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
Dfinery.logEvent(DFEvent.ADD_TO_CART, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                    | Type  | Explanation                                                                                          | Essential |
| ----------------------- | ----- | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |

#### Add to Wishlist <a href="#undefined-23" id="undefined-23"></a>

This event indicates that a user has added a product to their interest list.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
Dfinery.logEvent(DFEvent.ADD_TO_WISHLIST, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                    | Type  | Explanation                                                                                          | Essential |
| ----------------------- | ----- | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |

#### Cancel Order <a href="#undefined-26" id="undefined-26"></a>

This event represents the action of canceling and refunding an order purchased by a user.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
Dfinery.logEvent(DFEvent.REFUND, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                                  | Type   | Explanation                                                                                          | Essential |
| ------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS`               | Array  | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |
| `DFEventProperty.TOTAL_REFUND_AMOUNT` | NUMBER | Total refund amount                                                                                  | ✅         |

#### Search for products <a href="#undefined-29" id="undefined-29"></a>

This event represents the action of a user searching for a product and checking the results.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 16000;
item[DFEventProperty.ITEM_DISCOUNT] = 700;
item[DFEventProperty.ITEM_QUANTITY] = 10;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
properties[DFEventProperty.KEYWORD] = "satobap";

Dfinery.logEvent(DFEvent.VIEW_SEARCH_RESULT, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                      | Type   | Explanation                                                                                          | Essential |
| ------------------------- | ------ | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS`   | Array  | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |
| `DFEventProperty.KEYWORD` | String | Search Keywords                                                                                      | ✅         |

#### Share this product <a href="#undefined-32" id="undefined-32"></a>

This event represents a user's action of sharing a product.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
properties[DFEventProperty.SHARING_CHANNEL] = "Facebook";

Dfinery.logEvent(DFEvent.SHARE_PRODUCT, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                              | Type   | Explanation                                                                                          | Essential |
| --------------------------------- | ------ | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS`           | Array  | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |
| `DFEventProperty.SHARING_CHANNEL` | String | Product sharing channel                                                                              | ✅         |

#### View product list <a href="#undefined-35" id="undefined-35"></a>

This event indicates the user's action of viewing a product list.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;

Dfinery.logEvent(DFEvent.VIEW_LIST, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                    | Type  | Explanation                                                                                          | Essential |
| ----------------------- | ----- | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |

#### View Cart <a href="#undefined-38" id="undefined-38"></a>

This event indicates the user's action of viewing the shopping cart.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);
//itemList.push(item2); If there are more than 2 items, enter additional items

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;

Dfinery.logEvent(DFEvent.VIEW_CART, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                    | Type  | Explanation                                                                                          | Essential |
| ----------------------- | ----- | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |

#### Enter purchase information <a href="#undefined-41" id="undefined-41"></a>

This event represents the action of a user entering purchase information.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const properties = {};
properties["key"] = "value"; //Custom property value (Optional)
Dfinery.logEvent(DFEvent.ADD_PAYMENT_INFO, properties);
```

{% endtab %}
{% endtabs %}

#### Delete Cart <a href="#undefined-43" id="undefined-43"></a>

This event indicates that the user has removed a product from their shopping cart.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const item = {};
item[DFEventProperty.ITEM_ID] = "Product number";
item[DFEventProperty.ITEM_NAME] = "Product name";
item[DFEventProperty.ITEM_PRICE] = 5000;
item[DFEventProperty.ITEM_DISCOUNT] = 500;
item[DFEventProperty.ITEM_QUANTITY] = 5;
item[DFEventProperty.ITEM_CATEGORY1] = "food";
item[DFEventProperty.ITEM_CATEGORY2] = "snack";

const itemList = [];
itemList.push(item);

const properties = {};
properties[DFEventProperty.ITEMS] = itemList;
Dfinery.logEvent(DFEvent.REMOVE_CART, properties);
```

{% endtab %}
{% endtabs %}

#### **Standard event properties**

| Name                    | Type  | Explanation                                                                                          | Essential |
| ----------------------- | ----- | ---------------------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Product Attributes](https://docs.dfinery.ai/developer-guide/en/undefined-1/web/event#item_property) | ✅         |

### Custom Events <a href="#undefined-46" id="undefined-46"></a>

This is an event that reflects the user's input of an arbitrary event name and properties. You can also use standard events by adding custom properties in the DFINERY Console.

**If there is no attribute**

{% tabs %}
{% tab title="Javascript" %}

```javascript
Dfinery.logEvent("CUSTOM_EVENT_NAME", null);
```

{% endtab %}
{% endtabs %}

**If there is an attribute**

{% tabs %}
{% tab title="Javascript" %}

```javascript
const properties = {};
properties["CUSTOM_PROPERTY_KEY"] = "CUSTOM_PROPERTY_VALUE"; //Custom property value (Optional)
Dfinery.logEvent("CUSTOM_EVENT_NAME", properties);
```

{% endtab %}
{% endtabs %}

### Data collected automatically <a href="#undefined-49" id="undefined-49"></a>

DFINERY SDK automatically collects the following information:

> This value may not be collected depending on the browser environment and type.

* Browser
* Browser version
* OS
* Set language
* Set Time Zone Offset
* Url
* Referer
* utm parameter


---

# 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://docs.dfinery.ai/developer-guide/en/undefined-1/web/event.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.
