Install with Swift Package Manager(SPM)
Install
In your Xcode project, go to 1. Project Target > 2. Package Dependencies. 3. Click the + button at the bottom of the Packages section.
Copy URL:
https://github.com/corca-ai/adcio-ios-sdk
When the window to add a package opens, search for the 4. ADCIO package using the URL below. Check the packages and click the 5. Add Packages button.
ADCIO SDK
supports a total of 3 plug-ins (analytics, placement, agent), of which you can add the necessary ones to your project target.
Add the ADCIO Plugin by adding our link to your project's Package dependency.
For information on available ADCIO Plugin release versions, please refer here (opens in a new tab)
Initialize ADCIO Analytics
SwiftUI
import AdcioAnalytics
final class ViewModel {
private var analytics: AnalyticsManageable
private(set) var suggestion: SuggestionEntity // Suggestion's response value
init(_ clientID: String, suggestion: SuggestionEntity) {
self.analytics = AnalyticsManager(clientID: clientID)
self.suggestion = suggestion
}
}
For information on how to get the clientId, please refer here (opens in a new tab)
UIKit
import AdcioAnalytics
final class ViewModel {
private var analytics: AnalyticsManageable
private(set) var suggestion: SuggestionEntity // Suggestion's response value
init(_ clientID: String, suggestion: SuggestionEntity) {
self.analytics = AnalyticsManager(clientID: clientID)
self.suggestion = suggestion
}
}
For information on how to get the clientId, please refer here (opens in a new tab)
Use LogOptions
Log functions where option is used use the response value of methods of adcio_placement.
RecommendationBanners
func createRecommendationBanners() {
placementManager.createRecommendationBanners(
clientID: clientID,
excludingProductIDs: ["1031"],
categoryID: "1",
placementID: "placementID",
customerID: "corca0302",
fromAgent: false,
birthYear: 2000,
gender: .male) { [weak self] result in
switch result {
case .success(let suggestions):
// success do something
print("createRecommendationBanners ✅")
case .failure(let error):
// failure do something
print("createRecommendationBanners ❌ : \(error)")
}
}
}
RecommendationProducts
func createRecommendationProducts() {
placementManager.createRecommendationProducts(
clientID: clientID,
excludingProductIDs: ["1001"],
categoryID: "1",
placementID: "placementID",
customerID: "corca0302",
fromAgent: false,
birthYear: 2000,
gender: .male,
filters: [
"price_excluding_tax": Filter(not: 53636),
"product_code": Filter(contains: "KY"),
"province_id": Filter(equalTo: 1)
]
) { [weak self] result in
switch result {
case .success(let suggestions):
self?.suggestions = SuggestionMapper.map(from: suggestions)
self?.impressable = true
print("createRecommendationProducts ✅")
case .failure(let error):
print("createRecommendationProducts ❌ : \(error)")
}
}
}
AdvertisementBanners
func createAdvertisementBanners() {
placementManager.createAdvertisementBanners(
clientID: clientID,
excludingProductIDs: ["1031"],
categoryID: "1",
placementID: "placementID",
customerID: "corca0302",
fromAgent: false,
birthYear: 2000,
gender: .male) { [weak self] result in
switch result {
case .success(let suggestions):
// success do something
print("createAdvertisementBanners ✅")
case .failure(let error):
// failure do something
print("createAdvertisementBanners ❌ : \(error)")
}
}
}
AdvertisementProducts
func createAdvertisementProducts() {
placementManager.createAdvertisementProducts(
clientID: clientID,
excludingProductIDs: nil,
categoryID: "2179",
placementID: "5ae9907f-3cc2-4ed4-aaa4-4b20ac97f9f4",
customerID: "corca0302",
fromAgent: false,
birthYear: 2000,
gender: .male,
filters: [
"price_excluding_tax": Filter(not: 53636),
"product_code": Filter(contains: "KY"),
"province_id": Filter(equalTo: 1)
]
) { [weak self] result in
switch result {
case .success(let suggestions):
self?.suggestions = SuggestionMapper.map(from: suggestions)
self?.impressable = true
print("createAdvertisementProducts ✅")
case .failure(let error):
print("createAdvertisementProducts ❌ : \(error)")
}
}
}
Impression
Called when a product recommended as a suggestion
has at least 50% exposure on the screen for at least 1 second. Please refer here (opens in a new tab).
func onImpression(with option: LogOptionEntity) {
guard impressable else { return }
let optionEntity = LogOptionMapper.map(from: option)
analyticsManager.onImpression(option: optionEntity,
customerID: nil,
productIDOnStore: nil) { result in
switch result {
case .success(let isSuccess):
print("onImpression ✅ \(isSuccess) ")
case .failure(let error):
print("onImpression ❌ : \(error) ")
}
}
}
Click
It is called when customer clicks on the product recommended by the suggestion
.
func onClick(_ suggestion: SuggestionEntity) {
guard suggestion.product.isAd else { return }
let option = LogOptionMapper.map(from: suggestion.option)
analyticsManager.onClick(option: option,
customerID: "customerID",
productIDOnStore: "productIDOnstore") { result in
switch result {
case .success(let isSuccess):
print("onClick ✅ \(isSuccess) ")
case .failure(let error):
print("onClick ❌ : \(error) ")
}
}
}
Purchase
This should be called when a customer purchases a product recommended by a suggestion
.
For amount
, enter the actual price of the customer's final purchase. And as orderID
, enter the order ID you are using within your store service.
func onPurchase() {
analyticsManager.onPurchase(orderID: "orderID",
customerID: nil,
requestID: "requestId",
adsetID: "adsetId",
categoryIDOnStore: nil,
quantity: nil,
productIDOnStore: suggestion.product.id,
amount: suggestion.product.price) { result in
switch result {
case .success(let isSuccess):
print("onPurchase \(isSuccess) ✅")
case .failure(let error):
print("onPurchase : \(error) ❌")
}
}
}
AddToCart
This is a function to collect data on purchase conversion rate after adding to the shopping cart. It should be called when a customer adds an item to their shopping cart.
For cartID
(optional), enter the unique ID of the shopping cart you are using within your store service, if you have.
func onAddToCart() {
analyticsManager.onAddToCart(cartID: nil,
customerID: nil,
productIDOnStore: "productIDOnStore",
reqeustID: "productIDOnStore",
adsetID: "adsetID",
categoryIdOnStore: nil,
quantity: nil) { result in
switch result {
case .success(let isSuccess):
print("onAddToCart \(isSuccess) ✅")
case .failure(let error):
print("onAddToCart : \(error) ❌")
}
}
}
View Changed
It should be called when the screen is created and converted.
For productIdOnStore
or categoryIdOnStore
, please enter the name of the page you are using within your store service.
idOnStore
means the identifier that is unique on store’s system. Please refer here (opens in a new tab).
func onView(with path: String) {
analyticsManager.onView(customerID: nil,
productIDOnStore: "productIDOnStore",
requestID: "requestID",
adsetID: "adsetID",
categoryIDOnStore: nil) { result in
switch result {
case .success(let isSuccess):
print("\(path) onView \(isSuccess) ✅")
case .failure(let error):
print("\(path) onView : \(error) ❌")
}
}
}
Demo
UIKit
link_preview (opens in a new tab)