DMPClient iOS SDK
DMPClient supports installation through SPM:
https://github.com/brainsland/DMPiOSClientPublic.git
You can download and embed the framework manually.
Firstly, you need to configure DMPClient SDK by calling setup
when the app is started, ideally at AppDelegate
's didFinishLaunchingWithOptions
function:
let url = URL(string: "https://backend.com/api")!
DMP.shared.setup(projectId: "usertest", url: url, language: "tr")
You can enable developer mode to get detailed logs from SDK.
DMP.shared.enableLogging(true)
SDK collects most of data automatically, like sent time, timezone, session identifier. Tracking requests through DMP.shared
instance are explained below. Any view controller that use tracking, must call pageView
function on its viewDidAppear
function as explained below. This way, SDK can track page durations automatically and reuse page identifiers.
Any page that is needed to be tracked, should use pageView
function. When the view controller is appeared, this function should be called.
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let request = PageViewRequest(
url: "https://example.com/", canonicalUrl: "", title: "", referrer: "r", infiniteScrollDepth: 0
)
DMP.shared.pageView(request)
}
}
Page durations are tracked through pageView
requests automatically through saved PageViewInfo
. Implementing pageView
mentioned above will be enough to get necessary functionality.
DMP.shared.breadcrumb(breadcrumb1: "b1", breadcrumb2: "b2", breadcrumb3: "b3", breadcrumb4: "b4", breadcrumb5: "b5")
DMP.shared.scrollPosition(12, limit: 10)
DMP.shared.trackZone(type: "z1", value: "v1")
DMP.shared.trackUser(type: "u_gold", id: "123")
DMP.shared.pageEvent(category: "c", action: "a", label: "l", value: "v")
let request = NewsArticleRequest(
newsUrl: "", headline: "", description: "d", section: "s",
author1: "a1", author2: "", author3: "", image1: "i1", image2: "", image3: "",
keywords: "ss,ss", info: "info", datePublished: "", dateModified: "", wordCount: 3
)
DMP.shared.newsArticle(request)
DMP.shared.gallery("https://backend.com/image.png", quantity: 10)
DMP.shared.galleryView("https://backend.com/image.png", index: 3)
DMP.shared.video(
identifier: "video-id", label: "video-label",
posterURL: "https://backend.com/image.png",
publishedDate: Date(), // Date the video is published at.
duration: 12 // Duration of the video.
)
DMP.shared.videoTrack(
identifier: "video-id", label: "video-label",
currentTime: 12 // Current time of the video is playing.
)
Video Tracking events can be stopped through stopVideoTracking
.
Call this when the controller displaying video player is dismissed.
DMP.shared.stopVideoTracking()
Use videoTrackIntervalInSeconds
to set time interval for the video tracking events.
Default value is 30 seconds, meaning, each 30 seconds will submit video track event automatically, unless it's stopped
/// Time interval in seconds to track video events.
DMP.shared.videoTrackIntervalInSeconds = 15