# Product Feedback

An event that describes the action of giving feedback to a list of products.

Here's an example of a _Product Feedback_:

- JavaScript
- Swift
- Kotlin

```javascript
pcdp("event", "track", {

"clientId": "kevel",

"siteId": "kevel.com",

"type": "productFeedback",

"customFields": {

"debug": "true",

"role": "superuser"

},

"product": {

"itemGroupId": "p125",

"name": "My product",

"brand": "Nike",

"category": "Men/Shirts/Short Sleeve Shirts",

"categoriesList": [
      "Men",
      "Shirts",
      "Short Sleeve Shirts"
    ],

"secondaryCategory": "Men/Collections/Summer Essentials/Short Sleeve Shirts",

"secondaryCategoriesList": [
      "Men",
      "Collections",
      "Summer Essentials",
      "Short Sleeve Shirts"
    ],

"currency": "EUR",

"promotions": [
      "WINTERSALE"
    ],

"adult": false,

"size": "S",

"sizeSystem": "EU",

"customFields": {
      "color": "blue"
    },

"id": "p125zc",

"price": 102.5,

"quantity": 1,

"discount": {
      "value": 5,
      "currency": "EUR"
    },

"gender": "male",

"sku": "p125zc-5"

},

"rating": 4.5,

"feedback": "Very good. Would recommend to friends."
})
```

```swift
import Foundation

let event = """
{

"clientId": "kevel",

"siteId": "kevel.com",

"type": "productFeedback",

"customFields": {

"debug": "true",

"role": "superuser"

},

"product": {

"itemGroupId": "p125",

"name": "My product",

"brand": "Nike",

"category": "Men/Shirts/Short Sleeve Shirts",

"categoriesList": [
      "Men",
      "Shirts",
      "Short Sleeve Shirts"
    ],

"secondaryCategory": "Men/Collections/Summer Essentials/Short Sleeve Shirts",

"secondaryCategoriesList": [
      "Men",
      "Collections",
      "Summer Essentials",
      "Short Sleeve Shirts"
    ],

"currency": "EUR",

"promotions": [
      "WINTERSALE"
    ],

"adult": false,

"size": "S",

"sizeSystem": "EU",

"customFields": {
      "color": "blue"
    },

"id": "p125zc",

"price": 102.5,

"quantity": 1,

"discount": {
      "value": 5,
      "currency": "EUR"
    },

"gender": "male",

"sku": "p125zc-5"

},

"rating": 4.5,

"feedback": "Very good. Would recommend to friends."
}"

let trackUrl = "https://tr.cdp.\(websiteDomain)/events"

var urlComponents = URLComponents(string: trackUrl)!  
urlComponents.queryItems = [
  URLQueryItem(name: "id_\(idType)", value: id),
  URLQueryItem(name: "cookies", value: "false")
]

var request = URLRequest(url: urlComponents.url!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue(userAgent, forHTTPHeaderField: "User-Agent")
request.httpBody = event.data(using: .utf8)!

URLSession.shared.dataTask(with: request).resume()
```

```kotlin
import androidx.core.net.toUri

import org.json.JSONObject

import java.net.URL

import javax.net.ssl.HttpsURLConnection

val event = """
{

"clientId": "kevel",

"siteId": "kevel.com",

"type": "productFeedback",

"customFields": {

"debug": "true",

"role": "superuser"

},

"product": {

"itemGroupId": "p125",

"name": "My product",

"brand": "Nike",

"category": "Men/Shirts/Short Sleeve Shirts",

"categoriesList": [
      "Men",
      "Shirts",
      "Short Sleeve Shirts"
    ],

"secondaryCategory": "Men/Collections/Summer Essentials/Short Sleeve Shirts",

"secondaryCategoriesList": [
      "Men",
      "Collections",
      "Summer Essentials",
      "Short Sleeve Shirts"
    ],

"currency": "EUR",

"promotions": [
      "WINTERSALE"
    ],

"adult": false,

"size": "S",

"sizeSystem": "EU",

"customFields": {
      "color": "blue"
    },

"id": "p125zc",

"price": 102.5,

"quantity": 1,

"discount": {
      "value": 5,
      "currency": "EUR"
    },

"gender": "male",

"sku": "p125zc-5"

},

"rating": 4.5,

"feedback": "Very good. Would recommend to friends."
}"

val trackUri = "https://tr.cdp.$websiteDomain/events".toUri().buildUpon()
    .appendQueryParameter("id_$idType", id)
    .appendQueryParameter("cookies", "false")

coroutineScope.launch(Dispatchers.IO) {
    val conn = (URL(trackUri.toString()).openConnection() as HttpsURLConnection).apply {
        requestMethod = "POST"
        setRequestProperty("User-Agent", userAgent)
        setRequestProperty("Content-Type", "application/json")
        doOutput = true
    }

conn.outputStream.use { os ->
        os.write(event.toByteArray(Charsets.UTF_8))
    }
    try {
        // Trigger the request
        conn.responseCode
    } finally {
        conn.disconnect()
    }
}
```

### Supported Fields for Product Feedback

| Field                        | Required | Type                       | Default | Example                               | Description                                            |
|------------------------------|----------|----------------------------|---------|---------------------------------------|--------------------------------------------------------|
| `clientId`                   |          | string                     |         | `"kevel"`                            | The client identifier.                                |
| `siteId`                     |          | string                     |         | `"kevel.com"`                        | The client's site identifier.                          |
| `type`                       | _required_ | `"productFeedback"`       |         | `"productFeedback"`                  | The event type.                                      |
| `customFields`               |          | object of string           |         | `{...}`                               | An object with custom fields for extra metadata.      |
| `facebookConversionTracking`  |          | [Facebook Conversion Tracking Details](https://docs.audience.kevel.com/collect/events/productFeedback#facebook-conversion-tracking-details) |         | [`{...}`](https://docs.audience.kevel.com/collect/events/productFeedback#facebook-conversion-tracking-details)           | Description of a tracking event to send to Facebook.  |
| `product`                    | _required_ | [Product](https://docs.audience.kevel.com/collect/events/productFeedback#product) |         | [`{...}`](https://docs.audience.kevel.com/collect/events/productFeedback#product) | The product whose feedback is given.                   |
| `rating`                     |          | number                     | `0`     | `4.5`                                | The rating given to the products.                     |
| `feedback`                   |          | string                     |         | `"Very good. Would recommend to friends."` | The textual feedback given to the products.           |

### Product Details

The product whose feedback is being given to.

| Field                         | Required | Type                        | Default | Example                               | Description                                            |
|-------------------------------|----------|-----------------------------|---------|---------------------------------------|--------------------------------------------------------|
| `itemGroupId`                |          | string                      |         | `"p125"`                            | Identifier for a group of products.                    |
| `name`                        |          | string                      | `""`  | `"My product"`                     | Product name.                                        |
| `brand`                       |          | string                      |         | `"Nike"`                           | Product brand.                                      |
| `category`                    |          | string                      |         | `"Men/Shirts/Short Sleeve Shirts"` | Product category.                                   |
| `categoriesList`              |          | array of string            |         | `[`"Men", "Shirts", "Short Sleeve Shirts"`]` | Hierarchical list of product sub-categories.         |
| `secondaryCategory`           |          | string                      |         | `"Men/Collections/Summer Essentials/Short Sleeve Shirts"` | Secondary Product category.                         |
| `secondaryCategoriesList`      |          | array of string            |         | `[...]`                             | Hierarchical list of secondary product sub-categories. |
| `currency`                   | _required_ | string                     |         | `"EUR"`                            | The currency used in monetary values.                |
| `promotions`                  |          | array of string            | `[]`    | `[`"WINTERSALE"`]`                 | Vouchers applied in purchase.                        |
| `adult`                       |          | boolean                    | `false` | `false`                               | Whether the product includes adult content.          |
| `size`                        |          | string                      |         | `"S"`                              | Product size.                                      |
| `sizeSystem`                  |          | string                      |         | `"EU"`                             | Country of the size system used.                     |
| `customFields`                |          | object of string           |         | `{"color": "blue"}`             | Additional fields related to the product.            |
| `id`                          | _required_ | string                     |         | `"p125zc"`                         | Product identifier.                                 |
| `price`                       |          | number                     | `0`    | `102.5`                              | The product's price.                                |
| `quantity`                    |          | number                     | `1`    | `1`                                  | Number of items purchased.                           |
| `discount`                    |          | [Discount](https://docs.audience.kevel.com/collect/events/productFeedback#discount) |         | [`{...}`](https://docs.audience.kevel.com/collect/events/productFeedback#discount) | Discount applied to the product.                     |
| `gender`                      |          | string                      |         | `"male"`                           | Gender for the product intended.                     |
| `sku`                         |          | string                      |         | `"p125zc-5"`                       | Product SKU.                                       |

### Discount Details

Discount applied to the product.

Discount types include Percentage, Price, or Value discount.
