Cart View | Kevel Audience
Cart View Event
An event that describes the action of viewing the shopping cart.
Example of a Cart View:
pcdp("event", "track", {
"clientId": "kevel",
"siteId": "kevel.com",
"type": "cartView",
"customFields": {
"debug": "true",
"role": "superuser"
},
"products": [
{
"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"
}
]
})
import Foundation
let event = """
{
"clientId": "kevel",
"siteId": "kevel.com",
"type": "cartView",
"customFields": {
"debug": "true",
"role": "superuser"
},
"products": [
{
"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"
}
]
}"""
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()
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": "cartView",
"customFields": {
"debug": "true",
"role": "superuser"
},
"products": [
{
"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"
}
]
}"""
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()
}
}
Fields Supported on Every Cart View
| Field |
Required |
Type |
Default |
Example |
Description |
clientId |
|
string |
|
"kevel" |
The client identifier. |
siteId |
|
string |
|
"kevel.com" |
The client’s site identifier. |
type |
required |
"cartView" |
|
"cartView" |
The event type. |
customFields |
|
object of string |
|
{...} |
An object with custom fields for extra metadata to be supplied in the event. The values within this object must all be strings. |
facebookConversionTracking |
|
Facebook Conversion Tracking Details |
|
{...} |
A description of a tracking event to send to Facebook using Facebook Conversions API. |
products |
|
array of Product |
|
[...] |
An array of the products currently on the shopping cart. |
Facebook Conversion Tracking Details
A description of a tracking event to send to Facebook using Facebook Conversions API.
| Field |
Required |
Type |
Default |
Example |
Description |
pixel_id |
|
string |
|
"396622227884531" |
The pixel ID to associate this Facebook tracking event with. |
event_id |
|
string |
|
"0c53d0b57" |
ID used to deduplicate events sent by both Facebook Pixel and Conversions API. |
event_name |
|
string |
|
"AddToCart" |
A Facebook pixel Standard Event or Custom Event name. |
custom_data |
|
object |
|
{...} |
Parameters to send additional data Facebook can use for ads delivery optimization. |
Product
Product details.
| Field |
Required |
Type |
Default |
Example |
Description |
itemGroupId |
|
string |
|
"p125" |
Identifier for a group of products that come in different versions (variants). |
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"] |
A hierarchically sorted list of the sub-categories that this product belongs to. |
secondaryCategory |
|
string |
|
"Men/Collections/Summer Essentials/Short Sleeve Shirts" |
Secondary Product category. |
secondaryCategoriesList |
|
array of string |
|
[...] |
A hierarchically sorted list of the secondary sub-categories that this product belongs to. |
currency |
required |
string |
|
"EUR" |
The currency used in monetary values. |
promotions |
|
array of string |
[] |
["WINTERSALE"] |
Vouchers applied in the 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 by your product. |
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 |
|
{...} |
Discount applied to the product. |
gender |
|
string |
|
"male" |
Gender for which the product is intended. |
sku |
|
string |
|
"p125zc-5" |
Product SKU. |
Discount
Discount applied to the product. One of Percentage Discount, Price Discount or Value Discount.
Percentage Discount
| Field |
Required |
Type |
Default |
Example |
Description |
percentage |
required |
number |
|
0.25 |
The percentage of the discount. |
Price Discount
| Field |
Required |
Type |
Default |
Example |
Description |
price |
required |
number |
|
42 |
The price after the discount. |
currency |
required |
string |
|
"EUR" |
The currency used in monetary values. |
Value Discount
| Field |
Required |
Type |
Default |
Example |
Description |
value |
required |
number |
|
10 |
The total value of the discount. |
currency |
required |
string |
|
"EUR" |
The currency used in monetary values. |