# Product events

Product events are a special type of event. They have predefined event types and can be used to capture user’s shopping activity.

Define and send your product event

Every event type is predefined by enum type EventType. Below, you can find an example of two ways of sending product events to User.com app. First one is an advanced data structure with many custom parameters. The simple implementation of sending the minimal required data is in the last line.

  • Swift
  • Objective C
let eventId = "123"
let eventType = UserSDK.EventType.add

let name = "Shoes"
let productURL = "www.example.com/shoes"

let customParams = [
"attr1": "value1",
"attr2": "value2"
]

UserSDK.default?.sendProductEvent(eventId, eventType: eventType, name: name, productURL: productURL, params: customParams) { [weak self] (success, error) in
    if let error = error {
        //Error occured
    } else if success == false {
        //Something went wrong, the event wasn't sent correctly.
    } else {
        //The event has been sent correctly.
    }
}

// Properties name, productURL, params and completion are optional so sending event can be shortened to, if one does not need any of the mentioned parameters:

UserSDK.default?.sendProductEvent(eventId, eventType: eventType)