iOS SDK¶
Segmentify iOS SDK for sending visitor behavior and rendering product recommendations.
Important warning
ProductView, Basket Add/Remove, View Basket, Purchase and Click events must match productId.
Introduction¶
This tutorial provides a very simple and quick introduction to the Segmentify integration for iOS applications by walking you through details of different events.
To see sample application using iOS SDK, please check iOS SDK repository.
Integration¶
This guide will help you to integrate different events (visitor actions) and also product recommendations. Integration can be divided into following steps:
- Event Types
- Event/Request Details
- Response Details
- User & Session Management
- Common Parameters
- Page View
- Product View
- Basket Operations
- Checkout Operations
- User/Visitor Operations
- Custom Event
- Interaction
- Search
- Banners
- Debugging Notes
Event Types¶
Segmentify uses different event types for different visitor actions. You can define following events by using Segmentify iOS SDK:
Event | Description | Event Name |
---|---|---|
Page | It is sent when a visitor views a page | PAGE_VIEW |
Product | It is sent when a visitor views a product | PRODUCT_VIEW |
Basket | It is sent when a visitor makes a basket action (add product to basket or remove product from basket) | BASKET_OPERATIONS |
Checkout | It is sent when a visitor makes a checkout action (views basket, enter customer information, enter payment information, finishes purchase) | CHECKOUT |
User | It is sent when a visitor makes a user action or use this event to update information about customers | USER_OPERATIONS |
Custom | It is sent when to identify any visitor action that has no predefined value in Segmentify | CUSTOM_EVENT |
Interaction | It is sent when a visitor makes an interaction like click, view a widget, submit, etc. | INTERACTION |
Search | It is sent when a visitor makes a search action like clicking a search input or typing words on the search input | SEARCH |
API Errors¶
If your request body has a field statusCode
, then you have an error in your request. Details of errors are given in below table:
Error Code | Description |
---|---|
NO_API_KEY | Your request doesn't have an apiKey parameter, please provide apiKey parameter at the request with your account's unique api key. |
NO_ACCOUNT | Given api key is not associated with a Segmentify account, please check your api key value. |
UNVERIFIED_ACCOUNT | Account associated with api key is not a verified account. To verify your account, please check your email and verify it. |
FAILED_ACCOUNT | Account associated with api key is not an active account. Please contact with support team to re-activate your account. |
NO_DOMAIN_APIKEY_MATCH | Each Segmentify account is associated with a domain. Please check your domain and provide at requests with header Origin . Check Reqeust Details for required headers. |
UNVERIFIED_ACCOUNT | Account associated with api key is not a verified account. To verify your account, please check your email and verify it. |
NO_EVENT | There is no events inside request body. You should add at least one event with each request. |
NO_USERID | Each Segmentify event should have an userId parameter, and at least one event in the request lacks this parameter. |
NO_SESSIONID | Each Segmentify event should have an sessionId parameter, and at least one event in the request lacks this parameter. |
BAD_INPUT | Your request body should be a json array of Segmentify events. It is malformed, please check your json object for validity. |
Common Parameters¶
Every event in Segmentify shares common parameters and you can add these parameters to all events that will be defined later.
Details of common parameters for events are given below:
Name | Type | Description | Example |
---|---|---|---|
Event (name) |
Mandatory | Name of the event. Use one name from Event Types | 'PAGE_VIEW' or 'CHECKOUT' |
User ID (userId) |
Mandatory | Unique id of the user. Please check User & Session Management for creating unique key for the user/visitor. You should send same key for every event of same user and this id must be unique among other users | 'USER_1234567890' |
Session ID (sessionId) |
Mandatory | Unique id of the user session. Please check User & Session Management for creating unique key for the user/visitor session. You should send same key for every event of same user session and this id must be unique among other sessions | 'SESSION_1234567890' |
Language (lang) |
Optional | Type of current visitor's language.Contact us for other languages. Default languages : - 'TR' - 'EN' - 'FR' - 'DE' |
'FR' |
Region (region) |
Optional | Type of current visitor's region. | 'EU' |
Currency (currency) |
Optional | Currency of product price. Must be in Short Format. If not given, account's currency will be used for the product |
'EUR' |
Page Url (pageUrl) |
Optional | Url of the current page which the event is generated | 'https://www.exampleshop.com/example-product-1/' |
Test Mode (testMode) |
Optional | Test Mode Flag. If event is set to test mode, it will be only processed by campaigns in test mode and discarded in reports. Possible values are 'true' or 'false' | 'false' |
Basic Configuration¶
Segmentify accounts have two important system variables used in integration: APP KEY and Data Center. You can access these values from Integrations menu of Segmentify Panel:
System Variable | Description |
---|---|
App Key | unique Segmentify key value to send events |
Data Center | data center end point to send Segmentify events |
To access Integrations menu of Segmentify Panel, please login to your Segmentify account and navigate to
Settings > Integrations
.
Segmentify uses podfile for integration into the project. Inside your Xcode project's root folder run the following commands.
- Run pod init
to create an empty pod file
- Run pod install
to add Cocoapods to your project
- Run open YourProject.xcworkspace
to your new Xcode project's workspace.
After, import Segmentify
must be defined in AppDelegate.swift
and in required classes..
Segmentify iOS SDK requires App key, Subdomain and Data Center URL to establish a connection.
Define configuration method in AppDelegate.swift
file.
Example configuration is given below:
SegmentifyManager.config(
appkey: “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”,
dataCenterUrl: “https://xxx.segmentify.com“,
subDomain: “example.com”
)
If you do not want console log to be visible, define it as false
.
let _ = SegmentifyManager.logStatus(isVisible: true)
You can use the following command to set new configs
SegmentifyManager.setConfig(apiKey: newApiKey, dataCenterUrl: newDataCenterUrl, subDomain: newDomain)
An empty array of type RecommendationModel is required where the products to be suggested are stored within any view controller.
Example;
var recommendations : [RecommendationModel] = []
The response will be stored in this array as the response.
Basic response method for spesific event;
SegmentifyManager.sharedManager(
appKey: appKey,
dataCenterUrl: dataCenterUrl,
subDomain: subDomain).setPageViewEvent(
segmentifyObject: obj,
callback: { (response: [RecommendationModel]) in
self.recommendations = response
//for example to process on recommendations
self.createProducts(recommendations: self.recommendations)
})
Callback returns as a one-dimensional array. Optional operation on the array can be done to show it in the UI. Widget View is used when the page's widget is actually displayed. Related title: Interaction
func createProducts(recommendations : [RecommendationModel]) {
for recObj in recommendations {
if recObj.instanceId == "YOUR_CAMPAIGN_INSTANCE_ID" {
// to show details of the products in the UI
self.setProductInfos(products: recObj.products!)
}
}
}
Page View¶
When a visitor views a view controller, this event should be sent.
Parameters can be sent with page view event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Category (category) |
String | Mandatory | Category of the Page. Predefined values for Segmentify are: - Home Page - Product Page - Category Page - Basket Page - Checkout Page - Search Page - 404 Page |
'Product Page' |
Sub Category (subCategory) |
String | Optional | Sub-category of the page. It is used to enhance information about product and category pages. Example: For a sports category listing page, page category should be 'Category Page' and sub category should be 'Men>Shoes>Sports' |
'Men>Shoes>Sports' |
An example Page View request is given below:
//define page view object
let obj = PageModel()
obj.category = "Home Page"
obj.lang = "EN"
obj.region = "EU"
//send page view request
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: obj) {
(response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
An example of parameterized use as an alternative;
//send page view request
SegmentifyManager.sharedManager().sendPageView(
category: "Home page", subCategory: String?) {
(response: [RecommendationModel]) in
}
Search View¶
When a visitor wants to search products, this event should be sent.
There are two search type before search input and after search input. Before search input module works until the search is done. After search input starts working after searching. These recommendations are updated after minimum characters written in the search bar. Minimum character count presents in the campaign that is in search request response.
Parameters can be sent with search event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Query (query) |
String | Optional | Typed words for searching products. Should be empty or null for before search. | 'Dress' |
An example search view request is given below:
//define search view object
let searchViewObj = SearchPageModel()
searchViewObj.query = "Dress"
searchViewObj.lang = "EN"
searchViewObj.region = "EU"
//send search view request
SegmentifyManager.sharedManager().sendSearchPageView(segmentifyObject: searchViewObj){
(response: SearchModel) in
self.response = response
//operations about search
}
Search Response Details¶
SearchModel has thirteen objects: products for product list, campaign for search campaign details, errorString in case of an error, instanceId and interactionId for action identity, banners for search banners, meanings for alternative word suggestions, lastSearches for user's last searched words, brands and brandProducts for brand asset, categories and categoryProducts for category asset, keywords for keyword asset.
SearchModel¶
Name | Type | Description |
---|---|---|
campaign |
SearchCampaignModel? | Search Campaign object. |
products |
[ProductRecommendationModel]? | Products for product list. |
errorString |
String? | Error message in case of unexpected results. |
instanceId |
String? | Campaign instanceId. It will be used on events. |
interactionId |
String? | Identity of the action. |
banners |
[SearchBannerModel]? | Search banners list. |
meanings |
[String]? | List of alternative keywords. It uses for 'did you mean' feature. |
lastSearches |
[String]? | List of user's last searched words. |
brands |
String:String? | Map of brand name and its tracking url. It uses for brand asset. |
brandProducts |
String:[ProductModel]? | Map of brand name and list of its products. |
categories |
String:String? | Map of category name and its tracking url. It uses for category asset. |
categoryProducts |
String:[ProductModel]? | Map of category name and list of its products. |
keywords |
String:[ProductModel]? | Map of keyword and list of its products. It uses for keyword asset. |
SearchCampaignModel¶
Name | Type | Description |
---|---|---|
instanceId |
String? | Campaign instanceId. It will be used on events. |
name |
String? | Campaign name. |
status |
String? | campaign status like ACTIVE/TEST |
devices |
String? | Available device list. |
searchDelay |
Int? | delay for calling search event. |
minCharacterCount |
Int? | min character count in input to call search event. |
searchUrlPrefix |
String? | search url prefix of website |
mobileItemCount |
Int? | max product count to be displayed |
stringSearchAssetTextMap |
[String:SearchAssetTextModel] | language based map of titles |
SearchAssetTextModel¶
Name | Type | Description |
---|---|---|
popularProductsText |
String? | title for popular products on cold start. |
mobileCancelText |
String? | title for cancel button. |
notFoundText |
String? | title for no result. |
Product View¶
When a visitor views a product, this event should be sent.
If product is also inside a page, don't forget to send a page view event with category 'Product Page' and subCategory product's category too.
Parameters can be sent with product view event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Product ID (productId) |
String | Mandatory | Unique id of the product | 'EXAMPLE_PRODUCT_1' |
Title (title) |
String | Mandatory | Name/Title of the product | 'EXAMPLE PRODUCT' |
Stock (inStock) |
Bool | Optional | Product’s stock status - either true or false. If not given it is assumed to be in stock ('true') | 'true' |
Url (url) |
String | Mandatory | Canonical url of the product | 'https://www.exampleshop.com/example-product-1/' |
Mobile Url (mUrl) |
String | Optional | mobile specific url for the product | 'https://m.exampleshop.com/example-product-1/' |
Image (image) |
String | Mandatory | main image url to be used in product recommendations | 'https://cdn.exampleshop.com/example-product-1.png' |
Image X-Small (imageXS) |
String | Optional | very small image url to be used in product recommendations | 'https://cdn.exampleshop.com/example-product-1-xs.png' |
Image Small (imageS) |
String | Optional | small image url to be used in product recommendations | 'https://cdn.exampleshop.com/example-product-1-small.png' |
Image Medium (imageM) |
String | Optional | medium image url to be used in product recommendations | 'https://cdn.exampleshop.com/example-product-1-medium.png' |
Image Large (imageL) |
String | Optional | large image url to be used in product recommendations | 'https://cdn.exampleshop.com/example-product-1-large.png' |
Image X-Large (imageXL) |
String | Optional | very large image url to be used in product recommendations | 'https://cdn.exampleshop.com/example-product-1-xl.png' |
Category (category) |
String | Mandatory | Hierarchical category of the product | 'Men > Sports > Shoes' |
Brand (brand) |
String | Optional | Brand of the product | 'EXAMPLE BRAND' |
Price (price) |
NSNumber | Mandatory | Price of the product, must be numeric | 349.99 |
Old/Sales Price (oldPrice) |
NSNumber | Optional | Price of the product before sales | 449.99 |
Currency (currency) |
String | Optional | Currency of product price. Must be in Short Format. If not given, account's currency will be used for the product | 'EUR' |
Gender (gender) |
Optional | Gender of the product. Possible values are 'M', 'F', 'U' | 'M' | |
Colors (colors) |
Array type String | Optional | Different color options of the product. Must be in array format | ['black', 'red', 'blue'] |
Sizes (sizes) |
Array type String | Optional | Different size options of the product. Must be in array format | ['small', 'medium', 'large'] |
Labels (labels) |
Array type String | Optional | Custom labels associated with the product. You can use these labels to filter products in the recommendations. Must be in array format | ['top-seller', 'new-comer'] |
noUpdate (noUpdate) |
Bool | Optional | noUpdate must be defined as "true" in order not to disturb the products. | 'true' |
An example product view request is given below:
// START Page view request
// define page model object
let pageObj = PageModel()
pageObj.category = "Product Page"
// send page view request
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) {
(response: [RecommendationModel]) in
}
// END Page view request
//START Product view request
//define product model object
let ProductObj = ProductModel()
ProductObj.title = "Asymmetric Dress in Black"
ProductObj.category = "Womenswear"
ProductObj.image = "//cdn.shopify.com/s/files/1/1524/5822/products/2014_11_17_Lana_Look034_02_300x300.jpg?v=1475497696"
ProductObj.url = "https://segmentify-shop.myshopify.com/products/asymmetric-dress-black"
ProductObj.inStock = true
ProductObj.brand = "Amelia Toro"
ProductObj.price = 578
ProductObj.productId = "25799860937"
ProductObj.noUpdate = true
//send product view request
SegmentifyManager.sharedManager().sendProductView(segmentifyObject: ProductObj) {
(response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Product view request
An example of parameterized use as an alternative;
//START Page View request
//define page model object
let pageObj = PageModel()
pageObj.category = "Product Page"
//send page view request
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) {
(response: [RecommendationModel]) in
}
//END Page View request
//send product view request
SegmentifyManager.sharedManager().sendProductView(
productID : "25799860937",
title : "Asymmetric Dress in Black",
category : "Womenswear",
price : 578,
brand : "Amelia Toro",
stock : true,
url: "https://segmentify-shop.myshopify.com/products/asymmetric-dress-black",
image: "//cdn.shopify.com/s/files/1/1524/5822/products/2014_11_17_Lana_Look034_02_300x300.jpg?v=1475497696") {
(response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
Basket Operations¶
Segmentify uses basket operations as intermediary step for measuring success of recommendations throughout the conversion funnel. Basket success rate is also reported by Trendify and Bannerify to show individual performance of products, categories, brands and banners.
Basket operations are similar to page view and product view. There are two possible steps in a basket operation these are: add product to basket, remove product from basket.
Add Product to Basket¶
When a visitor adds a product to basket/cart, this event should be sent.
An example request is given below:
//Define basket operations model
let addBasketObj = BasketModel()
addBasketObj.step = "add"
addBasketObj.productId = "25800400265"
addBasketObj.quantity = "2"
addBasketObj.price = 358
//Send add to basket event
SegmentifyManager.sharedManager().sendAddOrRemoveBasket(segmentifyObject: addBasketObj)
An example of parameterized use as an alternative;
//Send add to basket event
SegmentifyManager.sharedManager().sendAddOrRemoveBasket(basketStep : "add", productID : "25800400265", quantity : 2,price : 358)
Remove Product from Basket¶
When a visitor removes a product from basket/cart, this event should be sent.
An example request is given below:
//Define basket operations model
let removeBasketObj = BasketModel()
removeBasketObj.productId = "25799860937"
removeBasketObj.price = 578
removeBasketObj.quantity = "1"
removeBasketObj.step = "remove"
//Send remove from basket request
SegmentifyManager.sharedManager().sendAddOrRemoveBasket(segmentifyObject: obj)
An example of parameterized use as an alternative;
//Send add to basket event
SegmentifyManager.sharedManager().sendAddOrRemoveBasket(basketStep : "remove", productID : "25800400265", quantity : 2,price : 358)
Basket Event Parameters¶
Parameters can be sent with basket operations event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Values |
---|---|---|---|---|
Basket Step (step) |
String | Mandatory | Basket operation type. Can be either 'add' or 'remove' | 'add' |
Product ID (productId) |
String | Mandatory | Unique id of the product. Must match with product ids sent with product view event | 'EXAMPLE_PRODUCT_1' |
Price (price) |
NSNumber | Optional | Price of the product in the basket. If not given, price of the product in product catalogue will be assumed | 349.99 |
Currency (currency) |
String | Optional | Currency of product price. Must be in Short Format. Currency of the product is used if not given | 'EUR' |
Quantity | String | Optional | Number of items added to basket at this operation. If not given, it is assumed 1. You can also use decimals for not integer quantities like 2.3 | 1 |
Checkout Operations¶
Segmentify uses checkout operations to measure success of recommendations throughout the conversion funnel. Checkout information and steps are also used in email & personalization campaigns. Campaign, Trendify, Bannerify and Sales reports are feed from checkout information. It is essential for both analyitcs and recommendation capabilities to function properly.
Segmentify track four different steps of checkout operation:
Operation | Step | Details |
---|---|---|
View Basket | basket | When customer views the basket page. Some online stores has dedicated basket pages, others have basket detail pop-ups. For both use cases we recommend you to send checkout event with basket details. To see details, please click |
Customer Information | customer | This is the second step on checkout funnel. When customer is entering his personal information details, this event should be send to Segmentify. To see details, please click |
Payment Information | payment | When customer is on payment stage of checkout funnel, you should send this event to Segmentify.To see details, please click |
Purchase/Success | purchase | Final step of checkout funnel is purchase and Segmentify uses this step as success indicator for recommendations. Reports for campaigns (both recommendation and engagement), sales analysis and real-time analtyics are dependent to this event and shoukd be implemented with great care. To see details, please click |
View Basket¶
View Basket is the first step of checkout funnel, and followed by Customer Information.
When a visitor views his/her basket/cart, this event should be sent with basket details.
An example request is given below:
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Basket View Request
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
productsArray.append(firstProduct)
let checkoutObj = CheckoutModel()
checkoutObj.productList = productsArray
checkoutObj.totalPrice = 78
SegmentifyManager.sharedManager().sendViewBasket(segmentifyObject: checkoutObj) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Basket View Request
An example of parameterized use as an alternative;
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Basket View Request
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
productsArray.append(firstProduct)
SegmentifyManager.sharedManager().sendViewBasket(totalPrice: 78, productList: productsArray) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Basket View Request
Customer Information¶
Customer Information is the second step of checkout funnel, and preceeded by View Basket & followed by Payment Information.
When a visitor enters customer information as second step of checkout funnel, this event should be sent with basket details.
An example request is given below:
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Customer information request
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
productsArray.append(firstProduct)
let custInfObj = CheckoutModel()
custInfObj.productList = productsArray
custInfObj.totalPrice = 78
SegmentifyManager.sharedManager().sendCustomerInformation(segmentifyObject: custInfObj) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Customer information request
An example of parameterized use as an alternative;
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Customer information request
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
productsArray.append(firstProduct)
SegmentifyManager.sharedManager().sendCustomerInformation(totalPrice: 78, productList: productsArray) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Customer information request
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Payment Information¶
Payment Information is the third step of checkout funnel, and preceeded by Payment Information & followed by Purchase/Success.
When a visitor enters payment information as third step of checkout funnel, this event should be sent with basket details.
An example request is given below:
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Payment information request
//example array
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
//append product to example array
productsArray.append(firstProduct)
//define a variable type of CheckoutModel
let paymentInf = CheckoutModel()
paymentInf.totalPrice = 78
paymentInf.productList = productsArray
//payment information request
SegmentifyManager.sharedManager().sendViewBasket(segmentifyObject: paymentInf) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Payment information request
An example of parameterized use as an alternative;
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Payment information request
//example array
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
//append product to example array
productsArray.append(firstProduct)
//Send user register request
SegmentifyManager.sharedManager().sendPurchase(totalPrice: 78, productList: productsArray, orderNo: 1234) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Payment information request
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Purchase/Success¶
Purchase/Success is the fourth and final step of checkout funnel, and preceeded by Payment Information.
When a visitor finalizes a purchase, this event should be sent with basket details.
An example request is given below:
//START Page View
let pageViewObj = PageModel()
pageViewObj.category = "Purchase Success Page"
//send page view request
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: obj) { (response: [RecommendationModel]) in
}
//END Page View
//START Purchase Success request
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
productsArray.append(firstProduct)
let purchaseObj = CheckoutModel()
purchaseObj.productList = productsArray
purchaseObj.totalPrice = 78
purchaseObj.orderNo = "12313"
//Puchase success request
SegmentifyManager.sharedManager().sendPurchase(segmentifyObject: purchaseObj) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Purchase Success request
An example of parameterized use as an alternative;
//START Page view request
let pageObj = PageModel()
SegmentifyManager.sharedManager().sendPageView(segmentifyObject: pageObj) { (response: [RecommendationModel]) in
}
//END Page view request
//START Purchase Success request
//example array
var productsArray = [Any]()
let firstProduct = ["price":"78","productId":"25799809929","quantity":"1"]
//append product to example array
productsArray.append(firstProduct)
//Send user register request
SegmentifyManager.sharedManager().sendPayment(totalPrice: 78, productList: productsArray, orderNo: 1234) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Purchase Success request
Please refer to View Basket Step of Checkout for basket products detail and use the same information throughout the purchase funnel by only changing step information.
Checkout Parameters¶
Detailed explanation for each parameter is given below:
Name | Type | Description | Example |
---|---|---|---|
Checkout Step (step) |
String | Mandatory | Identifies which step of the checkout funnel. Each step has different meaning and use it accordingly |
Total Price/Amount (totalPrice) |
NSNumber | Mandatory | Total amount of the basket including taxes, shipping costs and also discounts |
Currency (currency) |
String | Optional | Currency of the total amount of the basket. Must be in Short Format. If not given, currency of the account is used |
Order No (orderNo) |
String | Optional | Your unique id of the order. Send this value only for purchase/succeess step and you can access to this id on sales report |
Cart Url (cartUrl) |
String | Optional | Permalink for accessing basket at later stages. Should be used for view basket, customer information and payment information steps of checkout. This url can be used at engagement campaigns like cart abondonment reminders. Customers will be informed with this url with out-bound channels like email and push messages. If not given, account's default cart url will be used (which can be adjusted from account settings in panel) |
Products | Array type Any | Mandatory | List of products inside the basket. Must be in array format. Details are given at product parameters |
Basket Product Parameters¶
Each product inside the basket can be defined with following parameters. See Checkout Parameters for defining checkout operation in which basket product is also defined.
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Product ID (productId) |
String | Mandatory | Unique id of the product | 'EXAMPLE_PRODUCT_1' |
Price | NSNumber | Optional | Price of the product in the basket. If not given, price of the product in the product catalogue will be used | 349.99 |
Currency | String | Optional | Currency of product price. Must be in Short Format. If not given, currency of the product in the product catalogue will be used | 'EUR' |
Quantity | String | Optional | Number of items from current product in the basket. If not given, it is assumed to be 1 | 1 |
User/Visitor Operations¶
Segmentify tracks important user operations like sign-up/register, sign-in/login, sign-out/logout and also you can share your customer's information with Segmentify by sending an update event.
Important warning
The userid must be used for the unification operation on all channels in the same userId. See the success department for the web side
There are 4 possible user/visitor operations:
- User Register/Sign-up: It should be sent when a visitor signed up to your website, to see details please click
- User Login/Sign-in: It should be sent when a registered user logins to your website, to see details please click
- User Logout/Sign-out: It should be sent when a registered user logouts from your website, to see details please click
- User Update: It should be sent when you want to share registered user's information (ex: name, email, phone number, etc.) with Segmentify. These information can be used at campagin templates to customize message or email address is used for email out-bound campaigns like abandoned cart reminders. To see details please click
New User¶
When a visitor registers (sign-up) to your website, you should send a new user event.
If you want to share details of an already registered user with Segmentify, please use User Update.
Details of parameters of new user is given below:
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
User Operation (step) |
String | Mandatory | Identifies which operation is taken for current user/customer. Each operation has differen meaning and use it accordingly | 'signup' |
Username (username) |
String | Mandatory | Unique identifier for the customer | 'johndoe' |
Full Name (fullName) |
String | Optional | Full name of the customer. | 'John Doe' |
Email (email) |
String | Optional (Mandatory for using email module) |
Email address of the customer | 'john.doe@exampleshop.com' |
Mobile Phone (phone) |
String | Optional | Mobile phone number of the customer | '+1 555 555 5555' |
Is Login (isLogin) |
Bool | Optional | Login information of the user | true |
Is Registered (isRegistered) |
Bool | Optional | Register information of the customer | true |
Gender (gender) |
String | Optional | Gender of the customer. Must be either 'M' or 'F' | 'M' |
Age (age) |
String | Optional | Age of the customer. Must be numeric. Either use age or birthdate | 27 |
Birthdate (birthdate) |
String | Optional | Birthdate of the customer. Must be in format 'DD.MM.YYYY'. Either use age or birthdate | '23.01.1980' |
Membership Date (memberSince) |
String | Optional | Membership date of the customer. Must be in format 'DD.MM.YYYY' | '20.01.2014' |
Location (location) |
String | Optional | Location of the customer | 'New York' |
Customer Segments (segments) |
Array type String | Optional | Segments of the customer. Must be in array format | ['SEGMENT 1', 'SEGMENT 2'] |
An example request is given below:
//Create new user Object
let newUserObj = UserModel()
//Define user object's username and email
newUserObj.username = "segmentify"
newUserObj.email = "example@segmentify.com"
//Send user register request
SegmentifyManager.sharedManager().sendUserRegister(segmentifyObject: newUserObj)
An example of parameterized use as an alternative;
//Send user register request
SegmentifyManager.sharedManager().sendUserRegister(username: "Segmentify", fullName: "Segmentify User", email: "example@segmentify.com", mobilePhone: "123456789", gender: "Male/Female", age: "4", birthdate: "04/2014")
User Login¶
When a registered customer logins (sign-in), a user login event should be sent to Segmentify.
Details of parameters of user login is given below:
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
User Operation (step) |
String | Mandatory | Identifies which operation is taken for current user/customer | 'signin' |
Username | String | Mandatory | Unique identifier for the customer | 'johndoe' |
An example request is given below:
//Create user Object
let UserObj = UserModel()
//Define user object's username and email
UserObj.username = "segmentify"
UserObj.email = "example@segmentify.com"
//Send user login request
SegmentifyManager.sharedManager().sendUserLogin(segmentifyObject: UserObj)
An example of parameterized use as an alternative;
//Send user login request
SegmentifyManager.sharedManager().sendUserLogin(username: "Segmentify", email: "example@segmentify.com")
User Logout¶
When a registered customer logouts (sign-out), a user logout event should be sent to Segmentify.
Details of parameters of user logout is given below:
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
User Operation (step) |
String | Mandatory | Identifies which operation is taken for current user/customer | 'signout' |
Username | String | Mandatory | Unique identifier for the customer | 'johndoe' |
An example request is given below:
/Create user Object
let UserObj = UserModel()
//Define user object's username and email
UserObj.username = "segmentify"
UserObj.email = "example@segmentify.com"
//Send user logout request
SegmentifyManager.sharedManager().sendUserLogout(segmentifyObject: UserObj)
An example of parameterized use as an alternative;
//Send user logout request
SegmentifyManager.sharedManager().sendUserLogout(username: "Segmentify", email: "example@segmentify.com")
User Update¶
When you want to share an already registered customer information, provide details of the customer by sending an user update event. You can use both this integration for both frequently updating user information and instant updates when customer updates his/her personal information.
If you want to share a new registered user with Segmentify, please use New User.
Details of parameters of user update is given below:
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
User Operation (step) |
String | Mandatory | Identifies which operation is taken for current user/customer. Each operation has differen meaning and use it accordingly | 'update' |
Username (username) |
String | Mandatory | Unique identifier for the customer | 'johndoe' |
Full Name (fullName) |
String | Optional | Full name of the customer. | 'John Doe' |
Email (email) |
String | Optional (Mandatory for using email module) |
Email address of the customer | 'john.doe@exampleshop.com' |
Mobile Phone (phone) |
String | Optional | Mobile phone number of the customer | '+1 555 555 5555' |
Gender (gender) |
String | Optional | Gender of the customer. Must be either 'M' or 'F' | 'M' |
Age (age) |
String | Optional | Age of the customer. Must be numeric. Either use age or birthdate | 27 |
Birthdate (birthdate) |
String | Optional | Birthdate of the customer. Must be in format 'DD.MM.YYYY'. Either use age or birthdate | '23.01.1980' |
Membership Date (memberSince) |
String | Optional | Membership date of the customer. Must be in format 'DD.MM.YYYY' | '20.01.2014' |
Location (location) |
String | Optional | Location of the customer | 'New York' |
Customer Segments (segments) |
Array type String | Optional | Segments of the customer. Must be in array format | [ 'SEGMENT 1', 'SEGMENT 2' ] |
Is Registered Flag (isRegistered) |
Bool | Optional | This is an advanced parameter, use cautiously. If you want to change user's register status without sending a register event, use this flag. Value is either 'true' or 'false' | 'true' |
Is Login Flag (isLogin) |
Bool | Optional | This is an advanced parameter, use cautiously. If you want to change user's login status without sending a login/logout event, use this flag. Value is either 'true' or 'false' | 'true' |
An example request is given below:
//Create new user Object
let UserObj = UserModel()
//Define user object's username and email
UserObj.username = "segmentify"
UserObj.email = "example@segmentify.com"
//Send user update request
SegmentifyManager.sharedManager().sendUserRegister(segmentifyObject: UserObj)
An example of parameterized use as an alternative;
//Send user update request
SegmentifyManager.sharedManager().sendUserUpdate(username : "Segmentify", fullName : "Segmentify Test", email : "example@segmentify.com", mobilePhone : "123456789", gender : "Male/Female", age : "4", birthdate : "04/2014", isRegistered : true, isLogin : false)
User Change¶
This event is used when userid wants to be changed.
let userObj = UserChangeModel()
userObj.userId = "XXXXXXXXXXX"
SegmentifyManager.sharedManager().sendChangeUser(segmentifyObject: userObj)
Custom Event¶
This integration enables any event & data important for you to be tracked by Segmentify and become actionable. With this integration, you can send any non standard events & data to Segmentify, and gives endless opportunities to track and take actions to your visitor's behaviour.
Details of parameters of custom event is given below:
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Type (type) |
String | Mandatory | Type of the event. You should use same type for same events | 'my_custom_event' |
Custom Parameters (params) |
Dictionary | Optional | Custom parameters of the event. Must be in map format. | '{"field1":"value1", "field2":"value2"}' |
An example request is given below:
//Config for Segmentify manager
SegmentifyManager.config(appkey: Constant.segmentifyApiKey, dataCenterUrl: Constant.segmentifyDataCenterUrl, subDomain: Constant.segmentifySubDomain)
//START Custom Event Request
let customObj = CustomEventModel()
let paramDict = ["PRICE":"200-500"]
customObj.type = "test"
customObj.params = paramDict as [String : AnyObject]
SegmentifyManager.sharedManager().sendCustomEvent(segmentifyObject: customObj) { (response: [RecommendationModel]) in
self.recommendations = response
//operations about recommendations
}
//END Custom Event Request
Interaction¶
Segmentify needs to be thrown to use the information from widgets.
Widget View¶
Widget View is used when the page's widget is actually displayed.
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
instanceId |
String | Mandatory | Identity of the campaign | scn_6186a632e0d76001 |
interactionId |
String | Mandatory | Identity of the action | act_6185c1e624ab0000 |
if recObj.instanceId == "scn_61869cb94553e000" { // recObj is the recomendationModel object returned from the productView event
//Any actions related to product's
self.interactionId = recObj.interactionId
self.impressionId = recObj.instanceId
SegmentifyManager.sharedManager().sendWidgetView(instanceId: self.impressionId!, interactionId: self.interactionId!)
}
Click¶
It is necessary to notify the product productId and which campaign it belongs to when it is clicked on a product in any recommendation.
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
instanceId |
String | Mandatory | Identity of the campaign | instanceId = "scn_6186a632e0d76001" |
interactionId |
String | Mandatory | Unique id of the product | interactionId = "25803234569" |
SegmentifyManager.sharedManager().sendClickView(instanceId: self.impressionId!, interactionId: productID)
Search Click¶
It is necessary to notify the productId when it is clicked on a product in any search result.
If identity of the campaign in search response is "BEFORE_SEARCH" then instanceId should be bs_product
.
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
instanceId |
String | Mandatory | Identity of the product for before search input | instanceId = "bs_product" |
interactionId |
String | Mandatory | Unique id of the product for before search input | interactionId = "123456789" |
If identity of the campaign in search response is "SEARCH" then instanceId should be product
.
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
instanceId |
String | Mandatory | Identity of the product for after search input | instanceId = "product" |
interactionId |
String | Mandatory | Unique id of the product for after search input | interactionId = "123456789" |
SegmentifyManager.sharedManager().sendClickView(instanceId: "product", interactionId: "123456789" )
Banners¶
Event Types and Definitions¶
Event | Description | Event Name |
---|---|---|
Banner Operations | Events that should be sent when there is an interaction with the banner. It can be an impression, a click to the banner, or an update for banner information. | BANNER_OPERATIONS |
Banner Group View | Event that needs to be sent for the banner group uploaded to the page. | BANNER_GROUP_VIEW |
Internal Banner Group | The event that feeds the active banner status in the relevant group and the information of these banners to the Segmentify. | INTERNAL_BANNER_GROUP |
Banner Operations¶
Parameters can be sent with banner operations event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Type (type) |
String | Mandatory | Banner operation type. Can be 'impression', 'click' or 'update' | 'impression' |
Title (title) |
String | Mandatory | Title of the banner | 'Home Page Banner' |
Group (group) |
String | Mandatory | Group of the banner | 'Home Page Banner - Group 1' |
Order (url) |
NSNumber | Mandatory | Order of the banner in the group | 1 |
Product ID (productId) |
String | Optional | Unique id of the product | 'EXAMPLE_PRODUCT_1' |
Category (category) |
String | Optional | Hierarchical category of the product | 'Men > Sports > Shoes' |
Brand (brand) |
String | Optional | Brand of the product | 'EXAMPLE BRAND' |
Label (label) |
String | Optional | Custom label associated with the banner. | 'top-seller' |
// Banner impression event
let bannerImpressionOperationModel = BannerOperationsModel()
bannerImpressionOperationModel.type = "impression"
bannerImpressionOperationModel.title = "Gorgeous Duo T-Shirt & Trousers"
bannerImpressionOperationModel.group = "Home Page Slider"
bannerImpressionOperationModel.order = 1
SegmentifyManager.sharedManager().sendBannerImpressionEvent(segmentifyObject: bannerImpressionOperationModel)
// Banner click event
let bannerClickOperationModel = BannerOperationsModel()
bannerClickOperationModel.type = "click"
bannerClickOperationModel.title = "Gorgeous Duo T-Shirt & Trousers"
bannerClickOperationModel.group = "Home Page Slider"
bannerClickOperationModel.order = 1
SegmentifyManager.sharedManager().sendBannerClickEvent(segmentifyObject: bannerClickOperationModel)
// Banner update event
let bannerUpdateOperationModel = BannerOperationsModel()
bannerUpdateOperationModel.type = "update"
bannerUpdateOperationModel.title = "Gorgeous Duo T-Shirt & Trousers"
bannerUpdateOperationModel.group = "Home Page Slider"
bannerUpdateOperationModel.order = 2
SegmentifyManager.sharedManager().sendBannerUpdateEvent(segmentifyObject: bannerUpdateOperationModel);
Banner Group View¶
Parameters can be sent with banner group view event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Group (group) |
String | Mandatory | Group of the banner | 'Home Page Banner - Group 1' |
// Banner Group View Model
let bannerGroupViewModel = BannerGroupViewModel()
bannerGroupViewModel.group = "Home Page Slider"
// optional parameters
var internalBannerViewArray = [InternalBannerModel]()
let internalBannerModel = InternalBannerModel()
internalBannerModel.title = "Gorgeous Duo T-Shirt & Trousers"
internalBannerModel.order = 1
internalBannerModel.image = "https://cdn.segmentify.com/demo/banner-img2.jpg"
internalBannerModel.urls = ["https://www.example.com/gorgeous-duo-tshirt-trousers"]
internalBannerViewArray.append(internalBannerModel)
let internalBannerModel2 = InternalBannerModel()
internalBannerModel2.title = "Ready to Renew"
internalBannerModel2.order = 2
internalBannerModel2.image = "https://cdn.segmentify.com/demo/banner-img1.jpg"
internalBannerModel2.urls = ["https://www.example.com/ready-to-renew"]
internalBannerViewArray.append(internalBannerModel2)
bannerGroupViewModel.banners = internalBannerViewArray
// optional parameters end
SegmentifyManager.sharedManager().sendBannerGroupViewEvent(segmentifyObject: bannerGroupViewModel)
Internal Banner Group¶
Parameters can be sent with banner group view event is given below (you can also add common parameters):
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Group (group) |
String | Mandatory | Group of the banner | 'Home Page Banner - Group 1' |
Banners (banners) |
Array type Any | Optional | List of banners. Must be in array format. Details are given at banner details | [banner1,banner2] |
Banner Details¶
Name | Type | Requirement | Description | Example |
---|---|---|---|---|
Title (title) |
String | Optional | Title of the banner | 'Home Page Banner' |
Image (image) |
String | Optional | Image of the banner | 'https://example.com/image.jpg' |
Order (url) |
NSNumber | Optional | Order of the banner | 1 |
Urls (urls) |
Array type Any | Optional | Urls of the banner | [https://example.com/banner1] |
// Banner Group View Model
let bannerGroupViewModel = BannerGroupViewModel()
bannerGroupViewModel.group = "Home Page Slider"
// optional parameters
var internalBannerViewArray = [InternalBannerModel]()
let internalBannerModel = InternalBannerModel()
internalBannerModel.title = "Gorgeous Duo T-Shirt & Trousers"
internalBannerModel.order = 1
internalBannerModel.image = "https://cdn.segmentify.com/demo/banner-img2.jpg"
internalBannerModel.urls = ["https://www.example.com/gorgeous-duo-tshirt-trousers"]
internalBannerViewArray.append(internalBannerModel)
let internalBannerModel2 = InternalBannerModel()
internalBannerModel2.title = "Ready to Renew"
internalBannerModel2.order = 2
internalBannerModel2.image = "https://cdn.segmentify.com/demo/banner-img1.jpg"
internalBannerModel2.urls = ["https://www.example.com/ready-to-renew"]
internalBannerViewArray.append(internalBannerModel2)
bannerGroupViewModel.banners = internalBannerViewArray
// optional parameters end
SegmentifyManager.sharedManager().sendBannerGroupViewEvent(segmentifyObject: bannerGroupViewModel)
Debugging Notes¶
On your application development phase debug logs can be enabled or disabled by following call, by default debug level logging is enabled
SegmentifyManager.logStatus(isVisible: false)