了解如何在行動應用程式中追蹤事件。
Edge Network擴充功能提供API,可將體驗事件傳送至Platform Edge Network。 「體驗事件」是物件,其中包含符合XDM ExperienceEvent架構定義的資料。 更簡單地說,它們會擷取使用者在您行動應用程式中的行為。 Platform Edge Network收到資料後,即可將其轉送至您資料流中設定的應用程式和服務,例如Adobe Analytics和Experience Platform。 深入了解 體驗事件 在產品檔案中。
在本課程中,您將:
Adobe Experience Platform Edge擴充功能可將遵循先前定義之XDM架構的事件傳送至Adobe Experience Platform Edge Network。
過程是這樣……
識別您嘗試追蹤的行動應用程式互動。
檢閱您的結構並識別適當的事件。
檢閱您的結構,並識別應用來說明事件的任何其他欄位。
建構並填入資料物件。
建立和傳送事件。
驗證.
讓我們看幾個例子。
檢閱下列範例,而不嘗試在範例應用程式中實施:
在您的結構中,識別您嘗試收集的事件,在此範例中,我們會追蹤產品檢視。
開始建構物件:
var xdmData: [String: Any] = [
"eventType": "commerce.productViews",
"commerce": [
"productViews": [
"value": 1
]
]
]
在您的結構中,識別與事件相關聯的任何其他資料。 在此範例中,包括 productListItems
這是與商務相關事件搭配使用的標準欄位集:
productListItems
是陣列,因此可提供多個產品。展開xdmData物件以包含補充資料:
var xdmData: [String: Any] = [
"eventType": "commerce.productViews",
"commerce": [
"productViews": [
"value": 1
]
],
"productListItems": [
[
"name": productName,
"SKU": sku,
"priceTotal": priceString,
"quantity": 1
]
]
]
使用資料結構來建立 ExperienceEvent
:
let productViewEvent = ExperienceEvent(xdm: xdmData)
將事件和資料傳送至Platform Edge Network:
Edge.sendEvent(experienceEvent: productViewEvent)
檢閱下列範例,而不嘗試在範例應用程式中實施:
在您的結構中,識別您嘗試收集的事件。 在此範例中,追蹤「應用程式互動」,此互動包含應用程式動作事件和名稱。
開始建構物件。
標準欄位組始終在對象根中開始。
自訂欄位群組一律從您Experience Cloud組織「_techmarketingdemos」中唯一的物件開始。
var xdmData: [String: Any] = [
"_techmarketingdemos": [
"appInformation": [
"appInteraction": [
"name": actionName,
"appAction": [
"value": 1
]
]
]
]
]
或者……
var xdmData: [String: Any] = [:]
xdmData["_techmarketingdemos"] = [
"appInformation": [
"appInteraction": [
"name": actionName,
"appAction": [
"value": 1
]
]
]
]
使用資料結構來建立 ExperienceEvent
.
let appInteractionEvent = ExperienceEvent(xdm: xdmData)
將事件和資料傳送至Platform Edge Network。
Edge.sendEvent(experienceEvent: appInteractionEvent)
上述例子有望說明構建XDM資料對象時的思路。 接下來,我們將在Luma應用程式中新增畫面檢視追蹤。
導覽至 Home.swift
。
將下列程式碼新增至 viewDidAppear(...)
.
let stateName = "luma: content: ios: us: en: home"
var xdmData: [String: Any] = [:]
//Page View
xdmData["_techmarketingdemos"] = [
"appInformation": [
"appStateDetails": [
"screenType": "App",
"screenName": stateName,
"screenView": [
"value": 1
]
]
]
]
let experienceEvent = ExperienceEvent(xdm: xdmData)
Edge.sendEvent(experienceEvent: experienceEvent)
對應用程式中的每個畫面重複,並更新 stateName
隨你。
hitReceived
來自 com.adobe.edge.konductor
供應商。messages
物件。在此範例中,假設使用者成功進行了下列購買:
以下是要使用的相關架構欄位:
自訂欄位群組一律放在您的Experience Cloud組織識別碼下。
「_techmarketingdemos」會取代為您組織的唯一值。
以下說明如何在應用程式中建構和傳送XDM物件。
let stateName = "luma: content: ios: us: en: orderconfirmation"
let currencyCode = "USD"
let orderTotal = "79.99"
let paymentType = "Visa Credit Card"
let orderId = "298234720"
let paymentTransactionId = "847361"
var xdmData: [String: Any] = [
"eventType": "commerce.purchases",
"commerce": [
"purchases": [
"value": 1
],
"order": [
"currencyCode": currencyCode,
"priceTotal": orderTotal,
"purchaseID": orderId,
"purchaseOrderNumber": orderId,
"payments": [ //Assuming only 1 payment type is used
[
"currencyCode": currencyCode,
"paymentAmount": orderTotal,
"paymentType": paymentType,
"transactionID": paymentTransactionId
]
]
]
],
"productListItems": [
[
"name": "Yoga Mat",
"SKU": "5829",
"priceTotal": "49.99",
"quantity": 1
],
[
"name": "Water Bottle",
"SKU": "9841",
"priceTotal": "30.00",
"quantity": 3
]
]
]
//Custom field group
xdmData["_techmarketingdemos"] = [
"appInformation": [
"appStateDetails": [
"screenType": "App",
"screenName": stateName,
"screenView": [
"value": 1
]
]
]
]
let experienceEvent = ExperienceEvent(xdm: xdmData)
Edge.sendEvent(experienceEvent: experienceEvent)
為了清楚起見,所有值都以硬式編碼撰寫。 在現實情況中,值會動態填入。
您應該有所有工具可以開始將資料收集新增至Luma範例應用程式。 以下是您可遵循的假設追蹤需求清單。
檢閱 完整實作的應用程式 以取得更多範例。
檢閱 安裝指示 區段,並將您的模擬器或裝置連線至「保證」。
執行動作並尋找 hitReceived
來自 com.adobe.edge.konductor
供應商。
選取事件並檢閱 messages
物件。
現在您已收集事件並將其傳送至Platform Edge Network,系統就會將它們傳送至您 資料流. 在稍後的課程中,您會將此資料對應至 Adobe Analytics 和 Adobe Experience Platform.
下一個: WebViews
感謝您花時間學習Adobe Experience Platform Mobile SDK。 如果您有任何疑問、想要分享一般意見,或對未來內容有任何建議,請就此分享 Experience League社群討論貼文