Product View
Method Objective
Status |
---|
| |
---|
colour | Yellow |
---|
title | required |
---|
|
The method gives the system an understanding of the product viewed by the user.
Syntax and parameters
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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
- ".dynamic" if the current product was opened from the recommendation block. See example below.
- ".instant_search" if the current product was opened from the Instant Search tool.
- ".full_search" if the current product was opened from the Full Search tool.
|
code | string | required in some cases | This parameter can contain one of the values: - This parameter should have a unique code of the product recommendations block if the currently viewed product is from the recommendations block. The unique code is available in the PersonaClick account in the "data-recommender-code" attribute of each block.
- This parameter should have a search query in the value if the product is viewed from the Instant or Full Search tool.
|
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
| |
---|
colour | Yellow |
---|
title | required |
---|
|
The method gives the system an understanding of the category viewed by the user.
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
| |
---|
colour | Yellow |
---|
title | required |
---|
|
The method gives the system an understanding of the product added to the cart by the user.
Syntax and parameters
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
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
- ".dynamic" if the current product was opened from the recommendation block. See example below.
- ".instant_search" if the current product was opened from the Instant Search tool.
- ".full_search" if the current product was opened from the Full Search tool.
|
code | string | required in some cases | This parameter can contain one of the values: - This parameter should have a unique code of the product recommendations block if the currently viewed product is from the recommendations block. The unique code is available in the PersonaClick account in the "data-recommender-code" attribute of each block.
- This parameter should have a search query in the value if the product is viewed from the Instant or Full Search tool.
|
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
let recData = RecomendedBy(type: .dynamic, code: "b934b6ba2eb6202b8922d6a3fb8b3271")
sdk.track(event: .productAddedToCart(id: "100500"), recommendedBy: recData) { trackResponse in
print("Product added to the cart callback")
switch trackResponse {
product_amount | number | optionally | The total value of the amount of product added to the cart. Default: 1. Tip |
---|
For example: - A user has added the current product to the cart in the amount of 3 pieces. The request should have the "product_amount" value of 3.
- Then the user decides to add 2 more pieces of the current product (bringing the total to 5). The second request should have the "product_amount" value of 5.
|
|
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
- ".dynamic" if the current product was opened from the recommendation block. See example below.
- ".instant_search" if the current product was opened from the Instant Search tool.
- ".full_search" if the current product was opened from the Full Search tool.
|
code | string | required in some cases | This parameter can contain one of the values: - This parameter should have a unique code of the product recommendations block if the currently viewed product is from the recommendations block. The unique code is available in the PersonaClick account in the "data-recommender-code" attribute of each block.
- This parameter should have a search query in the value if the product is viewed from the Instant or Full Search tool.
|
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
| |
---|
colour | Yellow |
---|
title | required |
---|
|
The method gives the system an understanding of the product removed from the cart by the user.
Syntax and parameters
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
| |
---|
colour | Yellow |
---|
title | required |
---|
|
The method updates the whole cart on the system side.
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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: - productId - ID of the product in the cart (required)
- quantity - quantity of the product in the cart ( required)
See example below. |
callback | function | optionally | Callback function to catch success or error |
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
| |
---|
colour | Yellow |
---|
title | required |
---|
|
The method gives the system information about the successful checkout, its products, and other information related to the checkout.
Syntax and parameters
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 | number | optionally | The final order Note |
---|
Please note that order IDs in UUID format aren't displayed in the dashboard. Instead of UUDI, "---" will be displayed. To avoid this, add any prefix to this. |
|
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. |
Product properties:deliveryAddress | Namestring | Type | Requirement | Discription | idoptionally | Delivery address. Any text. |
---|
deliveryType | string | required | Product ID. |
amount | number | required | Product Quantity. |
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .orderCreated(orderId: "N100500", totalValue: 750.12, products: [(id: "37", amount: 3), (id: "187", amount: 1)])) { trackResponse inoptionally | Delivery Type, e.g. "courier", "self_pickup", "delivery", "pickup_point", etc. |
promocode | string | optionally | Promo code that was used. Tip |
---|
If a promo code from the list uploaded to the account has been used, it'll be marked as 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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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("Order is created callback")"Error: ", customError)
default:
switch trackResponse { case let .success(response):print("Error: ", error.localizedDescription)
print("Successful")}
case let .failure(error): fatalError("Task failed successfully")
switch error {
case .custom(let customError):
print("Error: ", customError)
}
} |
Search Request
Method Objective
The method gives the system an understanding of the user's search queries.
Syntax and parameters
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .search(query: search_query)) { callback } |
Name | Type | Requirement | Description |
---|
search_query | string | required | Search query phrase |
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .search(query: "to be or not to be")) { trackResponse in
print("The search request is sent")
switch trackResponse {
default: print("Error: ", error.localizedDescription)case let .success(response):
}print("Successful")
case let .failure(error):
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .search(query: search_query)) { callback } |
Name | Type | Requirement | Description |
---|
search_query | string | required | Search query phrase |
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .search(query: "to be or not to be")) { trackResponse in switch error {
case .custom(let customError):
print("The search request is sent")Error: ", customError)
switch trackResponse { default:
case let .success(response): print("SuccessfulError: ")
, error.localizedDescription)
case let .failure(error): }
switch error { fatalError("Task failed successfully")
case .custom(let customError):
print("Error: ", customError)
}
} |
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .productAddedToFavorities(id: "100500")) { trackResponse in
print("Product added to the wishlist callback")
switch trackResponse {
default: case let .success(response):
print("Error: ", error.localizedDescription)Successful")
case let .failure(error):
} switch error {
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .productAddedToFavorities(id: "100500")) { trackResponse in case .custom(let customError):
print("Product added to the wishlist callback")"Error: ", customError)
switch trackResponse { default:
case let .success(response): print("Successful"Error: ", error.localizedDescription)
case let .failure(error): }
switch error { 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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .productRemovedFromFavorities(id: product_id)) { case .custom(let customError):
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .productRemovedFromFavorities(id: "100500")) { trackResponse in
print("Error:Product ",removed customError)from the wishlist callback")
switch trackResponse {
default: case let .success(response):
print("Error: ", error.localizedDescription)
Successful")
} case let .failure(error):
fatalError("Task failed successfully") switch }
} |
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .productRemovedToFavorities(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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .productRemovedToFavorities(id: "100500")) { trackResponse inerror {
case .custom(let customError):
print("Product removed from the wishlist callback")"Error: ", customError)
switch trackResponse { default:
case let .success(response): print("Successful"Error: ", error.localizedDescription)
case let .failure(error):}
fatalError("Task switchfailed errorsuccessfully")
{ }
} |
Update the current wishlist
Method Objective
The method updates the whole wishlist on the system side
Syntax and parameters
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .synchronizeFavorites(items) { case .custom(let customError):
print("Error: ", customError)
default:
print("Error: ", error.localizedDescription)callback } |
Name | Type | Requirement | Description |
---|
items | array | required | Array with wish list product IDs. Tip |
---|
Use an empty array to clear the wishlist |
|
callback | function | optionally | Callback function to catch success or error. |
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.track(event: .synchronizeCart(items: ["784", "785"])) { trackResponse in
print("Cart synchronized callback")
switch trackResponse {
case let .success(response):
// }success
case let fatalError("Task failed successfully").failure(error):
// error
}
} |
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.trackEvent(event: "my_event") |
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
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 |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.trackSource(source, code) |
Name | Type | Requirement | Description |
---|
source | enum string | required | One of the string enum values. Available values: - .bulk
- .chain
- .transactional
Tip |
---|
The "src.type" value in the "payload" of the campaign should be used to define the value for this parameter. See Payload Examples. |
|
code | string | required | Unique campaign code Tip |
---|
The "src.id" value in the "payload" of the campaign should be used to define the value for this parameter. See Payload Examples. |
|
Example of use
Code Block |
---|
language | applescript |
---|
theme | FadeToGrey |
---|
|
sdk.trackSource(source: .chain, code: "100500146") |