Skip to main content

iOS SDK (Swift)

A powerful analytics library for iOS applications that provides comprehensive user interaction tracking and behavioral analysis through the Moveo One platform.

Current version: 1.0.17

The Moveo Analytics Swift Library is designed to capture and analyze user interactions within your iOS application. It provides detailed insights into user behavior, interaction patterns, and application usage through a comprehensive tracking system.

The library supports:

  • Context-based tracking for organizing user sessions
  • Semantic grouping for logical element organization
  • Flexible metadata for enhanced analytics
  • Data processing with configurable flush intervals
  • Multiple event types and actions for comprehensive interaction capture

Prerequisites

  • Swift 5.7 or later
  • iOS 15.0 or later
  • Moveo One API key (obtain from Moveo One App)

Installation

Add the Moveo Analytics Swift Library to your project using Swift Package Manager:

  1. In Xcode, go to File → Add Package Dependencies
  2. Enter the package URL: https://github.com/your-repo/moveo-analytics-swift
  3. Select the latest version and add to your target

Library Initialization

Initialize the library in your AppDelegate or @main app struct:

import MoveoOneLibrary

@main
struct MyApp: App {
init() {
// Initialize with your API token
MoveoOne.instance.initialize(token: "YOUR_API_KEY")

// Set flush interval (in seconds)
MoveoOne.instance.setFlushInterval(interval: 20000)

// Enable logging for debugging
MoveoOne.instance.setLogging(enabled: true)
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

Setup

Start Session

Start a session with context and metadata:

// Start session with context
MoveoOne.instance.start(
context: "main_app_flow",
metadata: [
"test": "a",
"locale": "eng",
"app_version": "2.1.0"
]
)

Important: The start() method is called only once at the beginning of a session and must be called before any track() or tick() calls.


Metadata and Additional Metadata

The library supports two types of metadata management:

Session Metadata

Updates current session metadata. Session metadata should split sessions by information that influences content or creates visually different variations of the same application.

MoveoOne.instance.updateSessionMetadata([
"test": "a",
"locale": "eng",
"app_version": "2.1.0"
])

Additional Metadata

Updates additional metadata for the session. This is used as data enrichment and enables specific queries or analysis by the defined split.

MoveoOne.instance.updateAdditionalMetadata([
"user_country": "US",
"company": "example_company",
"user_role": "admin", // or "user", "manager", "viewer"
"acquisition_channel": "organic", // or "paid", "referral", "direct"
"device_category": "mobile", // or "desktop", "tablet"
"subscription_plan": "pro", // or "basic", "enterprise"
"has_purchased": "true" // or "false"
])

Track Data

Understanding Context

Context represents large, independent parts of the application and serves to divide the app into functional units that can exist independently of each other.

Examples: onboarding, main_app_flow, checkout_process

Semantic Groups are logical units within a context that group related elements. Depending on the application, this could be a group of elements or an entire screen (most common).

Examples: navigation, user_input, content_interaction

When to Use Each Tracking Method

Use track() when:

  • You want to explicitly specify the event context
  • You need to change context between events
  • You want to use different context than one specified in start method
MoveoOne.instance.track(
context: "checkout_process",
moveoOneData: MoveoOneData(
semanticGroup: "user_interactions",
id: "payment_button",
type: .button,
action: .click,
value: "pay_now"
)
)

Use tick() when:

  • You're tracking events within the same context
  • You want tracking without explicitly defining context
  • You want to track events in same context specified in start method
MoveoOne.instance.tick(
moveoOneData: MoveoOneData(
semanticGroup: "screen_0",
id: "text_view_1",
type: .text,
action: .view,
value: "welcome_message"
)
)

Metadata Support in Track and Tick Events

// Track with metadata
MoveoOne.instance.track(
context: "checkout_screen",
moveoOneData: MoveoOneData(
semanticGroup: "user_interactions",
id: "checkout_button",
type: .button,
action: .click,
value: "proceed_to_payment"
)
)

// Tick with metadata
MoveoOne.instance.tick(
moveoOneData: MoveoOneData(
semanticGroup: "content_interactions",
id: "product_card",
type: .card,
action: .appear,
value: "product_view"
)
)

Event Types and Actions

Available Event Types

TypeDescription
buttonInteractive buttons
textText elements
textEditText input fields
imageSingle images
imagesMultiple images
image_scroll_horizontalHorizontal image scrolling
image_scroll_verticalVertical image scrolling
pickerSelection pickers
sliderSlider controls
switchControlToggle switches
progressBarProgress indicators
checkboxCheckbox controls
radioButtonRadio button controls
tableTable views
collectionCollection views
segmentedControlSegmented controls
stepperStepper controls
datePickerDate pickers
timePickerTime pickers
searchBarSearch bars
webViewWeb view components
scrollViewScroll views
activityIndicatorLoading indicators
videoVideo elements
videoPlayerVideo players
audioPlayerAudio players
mapMap components
tabBarTab bar components
tabBarPageTab bar pages
tabBarPageTitleTab bar page titles
tabBarPageSubtitleTab bar page subtitles
toolbarToolbar components
alertAlert dialogs
alertTitleAlert titles
alertSubtitleAlert subtitles
modalModal dialogs
toastToast notifications
badgeBadge elements
dropdownDropdown menus
cardCard components
chipChip elements
gridGrid layouts
customCustom elements

Available Event Actions

ActionDescription
clickElement clicked (normalized to tap)
viewElement viewed (normalized to appear)
appearElement appeared
disappearElement disappeared
swipeSwipe gesture
scrollScroll action
dragDrag action
dropDrop action
tapTap gesture
doubleTapDouble tap gesture
longPressLong press gesture
pinchPinch gesture
zoomZoom action
rotateRotate action
submitForm submission
selectSelection action
deselectDeselection action
hoverHover action
focusFocus action
blurBlur action
inputInput action
valueChangeValue change
dragStartDrag start
dragEndDrag end
loadLoad action (normalized to appear)
unloadUnload action (normalized to disappear)
refreshRefresh action
playPlay action
pausePause action
stopStop action
seekSeek action
errorError action
successSuccess action
cancelCancel action
retryRetry action
shareShare action
openOpen action (normalized to appear)
closeClose action (normalized to disappear)
expandExpand action
collapseCollapse action
editEdit action
customCustom action

Comprehensive Example Usage

Here's a complete example showing how to integrate Moveo Analytics in a SwiftUI app:

import MoveoOneLibrary
import SwiftUI

struct MainContentView: View {
@State private var inputText: String = ""

var body: some View {
GeometryReader { geometry in
ScrollView {
VStack {
Text("Moveo One")
.font(.system(size: 32, weight: .bold))
.foregroundColor(Color(red: 0.1, green: 0.2, blue: 0.36))
.padding(.top, 60)
.padding(.bottom, 40)
.onAppear {
// Track screen appearance
MoveoOne.instance.tick(
moveoOneData: MoveoOneData(
semanticGroup: "content_interactions",
id: "main_title",
type: .text,
action: .appear,
value: "app_title"
)
)
}

// Content Container
VStack {
Text("This is an example SwiftUI app made for demo purposes.")
.font(.system(size: 16))
.foregroundColor(Color(red: 0.29, green: 0.33, blue: 0.41))
.lineSpacing(6)
.multilineTextAlignment(.center)
.padding(.bottom, 30)
.onAppear {
trackParagraphImpression()
}

// Buttons
VStack(spacing: 16) {
Button("Button One") {
handleButtonPress("Button One")
}
.onAppear {
MoveoOne.instance.tick(
moveoOneData: MoveoOneData(
semanticGroup: "content_interactions",
id: "main_button",
type: .button,
action: .appear,
value: "Button One"
)
)
}
.onDisappear {
MoveoOne.instance.tick(
moveoOneData: MoveoOneData(
semanticGroup: "content_interactions",
id: "main_button",
type: .button,
action: .disappear,
value: "Button One"
)
)
}
.buttonStyle(MoveoButtonStyle(primary: true))

Button("Button Two") {
handleButtonPress("Button Two")
}
.buttonStyle(MoveoButtonStyle(primary: false))
}
.padding(.bottom, 20)

// Text Field
TextField("Type something...", text: $inputText)
.textFieldStyle(MoveoTextFieldStyle())
.onSubmit(handleInputSubmit)
}
.padding(25)
.background(Color.white)
.cornerRadius(20)
.shadow(color: Color(red: 0.17, green: 0.42, blue: 0.69).opacity(0.1), radius: 10, y: 4)
.frame(width: geometry.size.width * 0.85)
}
}
.background(Color(red: 0.94, green: 0.97, blue: 0.98))
}
}

private func trackParagraphImpression() {
MoveoOne.instance.tick(
moveoOneData: MoveoOneData(
semanticGroup: "content_interactions",
id: "intro_paragraph",
type: .text,
action: .view,
value: "demo_description"
)
)
}

private func handleButtonPress(_ buttonName: String) {
MoveoOne.instance.track(
context: "main_screen",
moveoOneData: MoveoOneData(
semanticGroup: "user_interactions",
id: "main_button",
type: .button,
action: .click,
value: "primary_action"
)
)
}

private func handleInputSubmit() {
MoveoOne.instance.track(
context: "main_screen",
moveoOneData: MoveoOneData(
semanticGroup: "user_interactions",
id: "main_input",
type: .textEdit,
action: .input,
value: "text_entered"
)
)
}
}

@main
struct SimpleExampleAppApp: App {
init() {
// Initialize Moveo Analytics
MoveoOne.instance.initialize(token: "YOUR_API_KEY")
MoveoOne.instance.setLogging(enabled: true)
MoveoOne.instance.setFlushInterval(interval: 5)

// Start session with context
MoveoOne.instance.start(
context: "main_screen",
metadata: [
"test": "a",
"locale": "eng",
"app_version": "2.1.0"
]
)

// Update additional metadata
MoveoOne.instance.updateAdditionalMetadata([
"user_country": "US",
"company": "example_company",
"user_role": "admin"
])
}

var body: some Scene {
WindowGroup {
MainContentView()
}
}
}

Obtain API Key

You can find your organization's API token in the Moveo One App. Navigate to your organization settings to retrieve your unique API key.


Dashboard Access

Once your data is being tracked, you can access your analytics through Moveo One Dashboard. The dashboard provides comprehensive insights into user behavior, interaction patterns, and application performance.


Support

For any issues or support, feel free to:

Note: This library is designed for iOS applications and requires iOS 15.0 or later. Make sure to handle user privacy and data collection in compliance with relevant regulations.