Event

How to record user events using the DFINERY SDK. SDK integration must be done first.

Before you start

Before recording an event, please register the event in the DFINERY console and then link it. You can register an event in the console's Additional Settings / Data Linkage / Event Management / Event List.

Event Log

Log an event by calling one of the following logEvent methods. The standard events provide constants.

func logEvent(_ name: String)
    
func logEvent(_ name: String, properties: [String: Any])

Each parameter means:

  • name : event name

  • properties : event properties

Example usage

// Path to record only events
Dfinery.shared().logEvent(DFEvent.LOGIN)

// When recording with event properties
Dfinery.shared().logEvent(
    "custom_event", 
    properties: ["custom_key": "custom_value"]
)

// When recording all event properties and items
let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "apple",
    DFEventProperty.ITEM_PRICE: 1000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "b131901200",
    DFEventProperty.ITEM_NAME: "car",
    DFEventProperty.ITEM_PRICE: 1000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0
]

let properties: [String: Any] = [
    DFEventProperty.TOTAL_PURCHASE_AMOUNT: 2,
    DFEventProperty.ORDER_ID: "a0b1c211",
    DFEventProperty.PAYMENT_METHOD: "credit_card",
    DFEventProperty.DELIVERY_CHARGE: 0.0,
    DFEventProperty.DISCOUNT: 0.0,
    DFEventProperty.ITEMS: [item1, item2]
]

Dfinery.shared().logEvent(DFEvent.PURCHASE, properties: properties)

Standard Events & Product Attributes

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

Standard Events

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

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

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

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

Double

Product unit price

DFEventProperty.ITEM_QUANTITY

df_quantity

Int

Product Quantity

DFEventProperty.ITEM_DISCOUNT

df_discount

Double

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

There is no need to call the df_start_session and df_end_session events as they are automatically collected by the SDK.

Example of using standard events

Log in

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

Dfinery.shared().logEvent(DFEvent.LOGIN)

Log out

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

Dfinery.shared().logEvent(DFEvent.LOGOUT)

Join the membership

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

Dfinery.shared().logEvent(
    DFEvent.SIGN_UP,
    properties: [DFEventProperty.SIGN_CHANNEL: "Apple"]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.SIGN_CHANNEL

String

Membership Channel

Purchase

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "accessories"
]

let items = [item1, item2]

let properties: [String: Any] = [
    DFEventProperty.TOTAL_PURCHASE_AMOUNT: 2,
    DFEventProperty.ORDER_ID: "a001",
    DFEventProperty.PAYMENT_METHOD: "credit_card",
    DFEventProperty.DELIVERY_CHARGE: 0.0,
    DFEventProperty.DISCOUNT: 0,
    DFEventProperty.ITEMS: items
]

Dfinery.shared().logEvent(DFEvent.PURCHASE, properties: properties)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

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

An event that indicates the user's action of viewing the app's home screen.

    Dfinery.shared().logEvent(DFEvent.VIEW_HOME)

View product details

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "Accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.VIEW_PRODUCT_DETAILS, 
    properties: [DFEventProperty.ITEMS: items]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

Put in a shopping cart

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.ADD_TO_CART, 
    properties: [DFEventProperty.ITEMS: items]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

Put in a shopping cart

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.ADD_TO_WISHLIST, 
    properties: [DFEventProperty.ITEMS: items]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

Add to Wishlist

This event represents the action taken by a user to add a product to their interest list.

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 1500000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "accessories"
]

Dfinery.shared().logEvent(
    DFEvent.REFUND,
    properties: [
        DFEventProperty.TOTAL_REFUND_AMOUNT: 1510000.0,
        DFEventProperty.ITEMS: [item1, item2]
    ]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

DFEventProperty.TOTAL_REFUND_AMOUNT

Double

Total refund (cancellation) amount

Search for products

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "Home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "Smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "Home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "Smartphone",
    DFEventProperty.ITEM_CATEGORY5: "Accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.VIEW_SEARCH_RESULT,
    properties: [
        DFEventProperty.KEYWORD: "keyword",
        DFEventProperty.ITEMS: items
    ]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

DFEventProperty.KEYWORD

String

Search Keywords

Share this product

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "Home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "Smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "Home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "Smartphone",
    DFEventProperty.ITEM_CATEGORY5: "Accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.SHARE_PRODUCT,
    properties: [
        DFEventProperty.SHARING_CHANNEL: "sharing_channel",
        DFEventProperty.ITEMS: items
    ]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

DFEventProperty.SHARING_CHANNEL

String

Product sharing channel

View product list

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "Home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "Smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "Home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "Smartphone",
    DFEventProperty.ITEM_CATEGORY5: "Accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.VIEW_LIST, 
    properties: [DFEventProperty.ITEMS: items]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

View Cart

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

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "accessories"
]

let items = [item1, item2]

Dfinery.shared().logEvent(
    DFEvent.VIEW_CART,
    properties: [DFEventProperty.ITEMS: items]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

Enter purchase information

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

Dfinery.shared().logEvent(DFEvent.ADD_PAYMENT_INFO)
[[Dfinery shared] logEvent:DFEvent.ADD_PAYMENT_INFO];

Delete Cart

This event represents the action of a user removing a product from their shopping cart.

let item1: [String: Any] = [
    DFEventProperty.ITEM_ID: "b1319000",
    DFEventProperty.ITEM_NAME: "iPhone12",
    DFEventProperty.ITEM_PRICE: 15000000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "apple"
]
let item2: [String: Any] = [
    DFEventProperty.ITEM_ID: "a3219006",
    DFEventProperty.ITEM_NAME: "Charger",
    DFEventProperty.ITEM_PRICE: 10000.0,
    DFEventProperty.ITEM_QUANTITY: 1,
    DFEventProperty.ITEM_DISCOUNT: 0.0,
    DFEventProperty.ITEM_CATEGORY1: "digital",
    DFEventProperty.ITEM_CATEGORY2: "home appliances",
    DFEventProperty.ITEM_CATEGORY3: "phone",
    DFEventProperty.ITEM_CATEGORY4: "smartphone",
    DFEventProperty.ITEM_CATEGORY5: "accessories"
]

let items = [item1, item2]
Dfinery.shared().logEvent(
    DFEvent.REMOVE_CART,
    properties: [DFEventProperty.ITEMS: items]
)

Standard event properties

Name
Type
Explanation
Essential

DFEventProperty.ITEMS

Array

Custom Events

Here is an example of calling a custom event created in the DFINERY console that is not predefined in DFINERY.

If there is no event property

Dfinery.shared().logEvent("YOUR_CUSTOM_EVENT")

If there is an event property

Dfinery.shared().logEvent(
    "CUSTOM_EVENT_WITH_PROPS", 
    properties: [
        "count": 42, 
        "name": "jimmy"
    ]
)

Last updated