# Event

This document explains what you need to do to analyze user behavior using the DFINERY SDK. [SDK integration](https://docs.dfinery.ai/developer-guide/platform/android/integration) is required to use this.

## Before you start

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

## Note

* Events will not be logged if unregistered events or event properties are entered.
* If the type of the event attribute entered does not match the event attribute type, the event will not be recorded.
* If an event property that is required for an event is missing, the event will not be logged.
* A maximum of 100 [products](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) can be entered per event.

## Event Log

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

```java
void logEvent(String eventName)
void logEvent(String eventName, JSONObject properties)
```

Each parameter means:

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

### Event log example

{% tabs %}
{% tab title="Java" %}
```java
// If there is no attribute
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP);

// If there is an attribute
JSONObject properties = new JSONObject();
properties.put(DFEventProperty.SHARING_CHANNEL, "Kakao");
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP, properties);

```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
// If there is no attribute
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP)

// If there is an attribute
val properties = JSONObject()
properties.put(DFEventProperty.SHARING_CHANNEL, "Kakao")
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP, properties)
```
{% endtab %}
{% endtabs %}

## Standard Events and Properties

Standard events, standard event properties, and product properties are as follows:

### 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               | Loin 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

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 standard event properties for products, which are loaded as an array in DFEventProperty.ITEMS. ITEM\_ID, ITEM\_NAME, ITEM\_PRICE, ITEM\_QUANTITY, and 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     |           |

## Example of using standard events

### Log in

This event indicates that a user has signed up as a member of the service.

{% hint style="success" %}
[If you set the user identification information that](https://docs.dfinery.ai/developer-guide/platform/android/identity) you logged in with , the information will be reflected in the unified ID, allowing you to more clearly identify the user.
{% endhint %}

{% tabs %}
{% tab title="Java" %}
```java
Dfinery.getInstance().logEvent(DFEvent.LOGIN);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
Dfinery.getInstance().logEvent(DFEvent.LOGIN)
```
{% endtab %}
{% endtabs %}

### Log out

This event indicates that a user is logging out of the app.

{% tabs %}
{% tab title="Java" %}
```java
Dfinery.getInstance().logEvent(DFEvent.LOGOUT);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
Dfinery.getInstance().logEvent(DFEvent.LOGOUT)
```
{% endtab %}
{% endtabs %}

### Join the membership

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.SHARING_CHANNEL, "Kakao");
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val properties = JSONObject()
try {
    properties.put(DFEventProperty.SHARING_CHANNEL, "Kakao")
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

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

### Purchase

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
    properties.put(DFEventProperty.ORDER_ID, "Product Number");
    properties.put(DFEventProperty.PAYMENT_METHOD, "BankTransfer");
    properties.put(DFEventProperty.TOTAL_PURCHASE_AMOUNT, 25500.0);
    properties.put(DFEventProperty.DELIVERY_CHARGE, 3000.0);
    properties.put(DFEventProperty.DISCOUNT, 0);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.PURCHASE, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
    properties.put(DFEventProperty.ORDER_ID, "Product Number")
    properties.put(DFEventProperty.PAYMENT_METHOD, "BankTransfer")
    properties.put(DFEventProperty.TOTAL_PURCHASE_AMOUNT, 25500.0)
    properties.put(DFEventProperty.DELIVERY_CHARGE, 3000.0)
    properties.put(DFEventProperty.ITEM_DISCOUNT, 0)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.PURCHASE, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

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

### View Home Screen

View product detailsThis event indicates that the user is viewing the app's home screen.

{% tabs %}
{% tab title="Java" %}
```java
Dfinery.getInstance().logEvent(DFEvent.VIEW_HOME);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
Dfinery.getInstance().logEvent(DFEvent.VIEW_HOME)
```
{% endtab %}
{% endtabs %}

### View product details

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_PRODUCT_DETAILS, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_PRODUCT_DETAILS, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                    | Type  | Explanation                                                                           | Essential |
| ----------------------- | ----- | ------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅         |

### Put in a shopping cart

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.ADD_TO_CART, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.ADD_TO_CART, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                    | Type  | Explanation                                                                           | Essential |
| ----------------------- | ----- | ------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅         |

### Add to Wishlist

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.ADD_TO_WISHLIST, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.ADD_TO_WISHLIST, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                    | Type  | Explanation                                                                           | Essential |
| ----------------------- | ----- | ------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅         |

### Search for products

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
    properties.put(DFEventProperty.TOTAL_REFUND_AMOUNT, 22500.0);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.REFUND, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
    properties.put(DFEventProperty.TOTAL_REFUND_AMOUNT, 22500.0)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.REFUND, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                                  | Type   | Explanation                                                                           | Essential |
| ------------------------------------- | ------ | ------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS`               | Array  | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅         |
| `DFEventProperty.TOTAL_REFUND_AMOUNT` | Double | Search for productsTotal refund (cancellation) amount                                 | ✅         |

### Share this product

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
    properties.put(DFEventProperty.KEYWORD, "Pork belly");
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_SEARCH_RESULT, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.pThis event represents a user's action of sharing a product.
```
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
    properties.put(DFEventProperty.SHARING_CHANNEL, "Facebook");
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.SHARE_PRODUCT, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
    properties.put(DFEventProperty.SHARING_CHANNEL, "Facebook")
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.SHARE_PRODUCT, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                              | Type  | Explanation                                                                           | Essential |
| --------------------------------- | ----- | ------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS`           | Array | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅         |
| `DFEventProperty.SHARING_CHANNEL` | Enum  | Search Keywords                                                                       | ✅         |

### View product list

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_LIST, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_LIST, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                    | Type  | Explanation             | Essential |
| ----------------------- | ----- | ----------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Goods](#item_property) | ✅         |

### View Cart

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

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_CART, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.VIEW_CART, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                    | Type  | Explanation                                                                           | Explanation |
| ----------------------- | ----- | ------------------------------------------------------------------------------------- | ----------- |
| `DFEventProperty.ITEMS` | Array | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅           |

### Enter purchase information

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

{% tabs %}
{% tab title="Java" %}
```java
Dfinery.getInstance().logEvent(DFEvent.ADD_PAYMENT_INFO);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
Dfinery.getInstance().logEvent(DFEvent.ADD_PAYMENT_INFO)
```
{% endtab %}
{% endtabs %}

### Delete Cart

This event indicates that a user removes a product from their shopping cart.

{% tabs %}
{% tab title="Java" %}
```java
JSONObject item = new JSONObject();
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number");
    item.put(DFEventProperty.ITEM_NAME, "Product Name");
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food");
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack");
    item.put(DFEventProperty.ITEM_PRICE, 5000.0);
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0);
    item.put(DFEventProperty.ITEM_QUANTITY, 5L);
} catch (JSONException e) {
    e.printStackTrace();
}
JSONArray items = new JSONArray();
items.put(item);
JSONObject properties = new JSONObject();
try {
    properties.put(DFEventProperty.ITEMS, items);
} catch (JSONException e) {
    e.printStackTrace();
}
Dfinery.getInstance().logEvent(DFEvent.REMOVE_CART, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val item = JSONObject()
try {
    item.put(DFEventProperty.ITEM_ID, "Product Number")
    item.put(DFEventProperty.ITEM_NAME, "Product Name")
    item.put(DFEventProperty.ITEM_CATEGORY1, "Food")
    item.put(DFEventProperty.ITEM_CATEGORY2, "Snack")
    item.put(DFEventProperty.ITEM_PRICE, 5000.0)
    item.put(DFEventProperty.ITEM_DISCOUNT, 500.0)
    item.put(DFEventProperty.ITEM_QUANTITY, 5L)
} catch (e: JSONException) {
    e.printStackTrace()
}
val items = JSONArray()
items.put(item)
val properties = JSONObject()
try {
    properties.put(DFEventProperty.ITEMS, items)
} catch (e: JSONException) {
    e.printStackTrace()
}
Dfinery.getInstance().logEvent(DFEvent.REMOVE_CART, properties)
```
{% endtab %}
{% endtabs %}

#### Standard event properties

| Name                    | Type  | Explanation                                                                           | Essential |
| ----------------------- | ----- | ------------------------------------------------------------------------------------- | --------- |
| `DFEventProperty.ITEMS` | Array | [Goods](https://docs.dfinery.ai/developer-guide/platform/android/event#item_property) | ✅         |

## Custom Events

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="Java" %}
```java
Dfinery.getInstance().logEvent("CUSTOM_EVENT_NAME", null);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
Dfinery.getInstance().logEvent("CUSTOM_EVENT_NAME", null)
```
{% endtab %}
{% endtabs %}

**If there is an attribute**

{% tabs %}
{% tab title="Java" %}
```java
JSONObject properties = new JSONObject();
properties.put("CUSTOM_PROPERTY_KEY", "CUSTOM_PROPERTY_VALUE");//Custom property values(Optional)
Dfinery.getInstance().logEvent("CUSTOM_EVENT_NAME", properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val properties = JSONObject()
properties.put("CUSTOM_PROPERTY_KEY", "CUSTOM_PROPERTY_VALUE")//Custom property values(Optional)
Dfinery.getInstance().logEvent("CUSTOM_EVENT_NAME", properties)
```
{% endtab %}
{% endtabs %}

## Enter date and time format properties

Date and time formats `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` must be entered as strings in the format.

{% tabs %}
{% tab title="Java" %}
```java
JSONObject properties = new JSONObject();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DFEventProperty.FORMAT_DATETIME, Locale.US);
Date currentDate = new Date();
try {
    properties.put("CUSTOM_PROPERTY_KEY", simpleDateFormat.format(currentDate));
} catch (JSONException e) {
    throw new RuntimeException(e);
}
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP, properties);
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
val properties = JSONObject()
val simpleDateFormat = SimpleDateFormat(DFEventProperty.FORMAT_DATETIME, Locale.US)
val currentDate = Date()
try {
    properties.put("CUSTOM_PROPERTY_KEY", simpleDateFormat.format(currentDate))
} catch (e: JSONException) {
    throw RuntimeException(e)
}
Dfinery.getInstance().logEvent(DFEvent.SIGN_UP, properties)
```
{% endtab %}
{% endtabs %}

## Data collected automatically

DFINERY automatically collects the following information:

### Session Analysis

DFINERY uses [activity lifecycle callbacks](https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks) to divide sessions.

### App Set ID

DFINERY automatically collects [App Set Id](https://www.google.com/url?sa=t\&rct=j\&q=\&esrc=s\&source=web\&cd=\&ved=2ahUKEwjl6-Lfg8CDAxXdQPUHHa9BCYMQFnoECBIQAQ\&url=https%3A%2F%2Fdeveloper.android.com%2Ftraining%2Farticles%2Fapp-set-id\&usg=AOvVaw2BN0DC8U-gaq6r7U2PulxJ\&opi=89978449) to identify users.

### Terminal information

DFINERY automatically collects the following terminal information:

> This value may not be collected depending on the app's environment and granted permissions.

| Item                                                        | Example   |
| ----------------------------------------------------------- | --------- |
| Model of the terminal                                       | SM-G973N  |
| Operating system of the terminal                            | 12        |
| The carrier currently connected to the terminal             | SKTelecom |
| The language set on the terminal                            | ko        |
| The terminal's set region                                   | ko\_KR    |
| Set Time Zone Offset of the terminal                        | 540       |
| Whether the terminal has a phone function                   | true      |
| The type of network the terminal is currently connected to. | wifi      |
| Device manufacturer of the terminal                         | samsung   |

### Application Information

DFINERY automatically collects the following application information:

| Item                                | Example                  |
| ----------------------------------- | ------------------------ |
| App version of the application      | 1.0.30                   |
| The package name of the application | com.igaworks.dfinerydemo |
