Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Product View
Method Objective
Status | ||||||
---|---|---|---|---|---|---|
|
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productView(id: product_id), recommendedBy: params) {callback} |
Name | Type | Requirement | Description |
---|---|---|---|
product_id | string | required | The ID of the current product |
params | RecomendedBy Class | required is some cases | Tuple with additional request parameters. See description below |
callback | function | optionally | Callback function to catch success or error |
RecomendedBy Class Properties
Name | Type | Requirement | Description |
---|---|---|---|
type | enum string | required in some cases | This property should be set to
|
code | string | required in some cases | This parameter can contain one of the values:
|
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
let recData = RecomendedBy(type: .dynamic, code: "b934b6ba2eb6202b8922d6a3fb8b3271") sdk.track(event: .productView(id: "100500"), recommendedBy: recData) { trackResponse in print("Product viewed callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Category View
Method Objective
Status | ||||||
---|---|---|---|---|---|---|
|
Warning |
---|
The API will respond with an error for categories unknown to the system. The system only knows the categories from the product feed (XML) or the HTTP import of the category list. |
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .categoryView(id: category_id)) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
category_id | string | required | The ID of the current category. |
callback | function | optionally | Callback function to catch success or error |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .categoryView(id: "146")) { trackResponse in print("Category viewed callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Adding a product to the cart
Method Objective
Status | ||||||
---|---|---|---|---|---|---|
|
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productAddedToCart(id: product_id, amount: product_amount), recommendedBy: params) { callback } |
Name | Type | Requirement | Description | ||
---|---|---|---|---|---|
product_id | string | required | The ID of the product added to the cart | ||
product_amount | number | optionally | The total value of the amount of product added to the cart. Default: 1.
| ||
params | RecomendedBy Class | required is some cases | Tuple with additional request parameters. See description below | ||
callback | function | optionally | Callback function to catch success or error |
RecomendedBy Class Properties
Name | Type | Requirement | Description |
---|---|---|---|
type | enum string | required in some cases | This property should be set to
|
code | string | required in some cases | This parameter can contain one of the values:
|
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
let recData = RecomendedBy(type: .dynamic, code: "b934b6ba2eb6202b8922d6a3fb8b3271") sdk.track(event: .productAddedToCart(id: "100500", amount: 2), recommendedBy: recData) { trackResponse in print("Product added to the cart callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Removing a product from the cart
Method Objective
Status | ||||||
---|---|---|---|---|---|---|
|
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productRemovedFromCart(id: product_id)) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
product_id | string | required | The ID of the product removed from the cart |
callback | function | optionally | Callback function to catch success or error |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productRemovedFromCart(id: "100500")) { trackResponse in print("Product removed from the cart callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Update the current cart
Method Objective
Status | ||||||
---|---|---|---|---|---|---|
|
Note |
---|
This method is required for use on the cart page when the user does certain actions there: when the user visits the page, changes the quantity of a product in the cart, removes a product from the cart, or clears the cart completely. |
Tip |
---|
This method can be used on the product page as an alternative to the "Add to cart" and "Remove from cart" methods if you have access to the entire cart on the product page. |
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .synchronizeCart(items: cart_items)) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
cart_items | array of "CartItem" objects | required | Array of objects with product properties in the cart. The "CartItem" object supports properties:
See example below. |
callback | function | optionally | Callback function to catch success or error |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .synchronizeCart(items: [CartItem(productId: "784", quantity: 1), CartItem(productId: "785", quantity: 3)])) { trackResponse in print("Cart synchronized callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Successful checkout
Method Objective
Status | ||||||
---|---|---|---|---|---|---|
|
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .orderCreated(orderId, totalValue, products, deliveryAddress, deliveryType, promocode, paymentType, taxFree)) { callback } |
Request parameters
Name | Type | Requirement | Description | ||
---|---|---|---|---|---|
products | array | required | An array of purchased products. See the table below for details. | ||
orderId | string | optionally | Internal store Order ID. If not specified, the system will create its internal ID. Synchronization of order statuses, in this case, won't be available.
| ||
totalValue | double | optionally | The final order value, including all discounts. If not specified, the system will calculate the order value based on prices from the product feed. | ||
deliveryAddress | string | optionally | Delivery address. Any text. | ||
deliveryType | string | optionally | Delivery Type, e.g. "courier", "self_pickup", "delivery", "pickup_point", etc. | ||
promocode | string | optionally | Promo code that was used.
| ||
paymentType | string | optionally | Payment method. Any string value. For example: "cash", "card", "wire". | ||
taxFree | string | optionally | It sets whether the order was placed with Tax-Free or not. |
Product properties:
Name | Type | Requirement | Discription |
---|---|---|---|
id | string | required | Product ID |
amount | int | required | Product Quantity |
price | float | optionally | Product Price |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .orderCreated(orderId: "N100500", totalValue: 750.12, products: [(id: "37", amount: 3, price: 11.45), (id: "187", amount: 1, price: 715.77)])) { trackResponse in print("Order is created callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Search Request
Method Objective
The method gives the system an understanding of the user's search queries.
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .search(query: search_query)) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
search_query | string | required | Search query phrase |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .search(query: "to be or not to be")) { trackResponse in print("The search request is sent") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Adding a product to the wishlist
Method Objective
The method gives the system an understanding the user has added a product to the wishlist.
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productAddedToFavorities(id: product_id)) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
product_id | string | required | The ID of the product added to the wishlist |
callback | function | optionally | Callback function to catch success or error |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productAddedToFavorities(id: "100500")) { trackResponse in print("Product added to the wishlist callback") switch trackResponse { case let .success(response): print("Successful") case let .failure(error): switch error { case .custom(let customError): print("Error: ", customError) default: print("Error: ", error.localizedDescription) } fatalError("Task failed successfully") } } |
Removing a product from the wishlist
Method Objective
The method gives the system an understanding the user has removed a product from the wishlist.
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productRemovedFromFavorities(id: product_id)) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
product_id | string | required | The ID of the product removed from the wishlist |
callback | function | optionally | Callback function to catch success or error |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.track(event: .productRemovedFromFavorities(id: "100500")) { trackResponse in
print("Product removed from the wishlist callback")
switch trackResponse {
case let .success(response):
print("Successful")
case let .failure(error):
switch error {
case .custom(let customError):
print("Error: ", customError)
default:
print("Error: ", error.localizedDescription)
}
fatalError("Task failed successfully")
}
} | ||||
Code Block | ||||
| ||||
sdk.track(event: .synchronizeFavorites(items) { callback
} |
Custom event
Method Objective
The method gives the system an understanding that some user event has happened.
Note |
---|
Before you can use custom events, you must create them in the PersonaClick account: Settings > Custom events. |
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.trackEvent(event: custom_event_key, category, label, value) |
Name | Type | Requirement | Description |
---|---|---|---|
custom_event_key | string | required | Unique custom event key. Must be pre-created in the PersonaClick account: Settings > Custom events. |
category | string | optionally | A category is a name that you supply as a way to group some event's properties. |
label | string | optionally | With labels, you can provide additional information for events that you need. |
value | number | optionally | The value property can be any integer and can be used to send a specific value in an event. |
Examples of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.trackEvent(event: "my_event") |
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.trackEvent(event: "my_event", category: "my_category", label: "my_label", value: 100500) |
Source Tracking
Method Objective
The method gives the system an understanding that the user jumped from the campaign message: bulk, chain, transactional.
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.trackSource(source, code) |
Name | Type | Requirement | Description | ||
---|---|---|---|---|---|
source | enum string | required | One of the string enum values. Available values:
| ||
code | string | required | Unique campaign code
|
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.trackSource(source: .chain, code: "100500146") |
Column | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Page Navigation
Related Pages
|