• Platforms
  • Partners
  • Forums
  • 日本語
  • TLC Tealium Learning Center Tealium Learning
    Community
  • Discussions & Ideas Dicussions & Ideas
  • Product Guides Product Guides
  • Knowledge Base Knowledge Base
  • Developer Docs Developer Docs
  • Education Education
  • TLC Blog TLC Blog
  • Support Desk Support Desk
  • CDH Customer Data Hub Customer Data Hub
  • Mobile
  • Getting Started
    • Overview
    • Quick Start Guide
    • Mobile Concepts
    • Client-Side
    • Server-Side
    • Tracking Webviews
    • Data Layer
    • Consent Management
    • Event Batching
    • User Location and Geofencing
    • Media Tracking
    • Deep Links
    • Timed Events
    • Trace
    • Hosted Data Layer
    • Adobe Visitor Service Module
    • Feature Comparison
    • Troubleshooting
  • Remote Commands
    • Overview
    • How It Works
    • Integrations
      • Adjust
      • AppsFlyer
      • Branch
      • Braze
      • Contentsquare
      • Facebook
      • Firebase
      • Kochava
      • Usabilla
  • Android (Java)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Module
      • Optimizely X Tracking Module
    • Android TV
    • Android Wear
    • API Reference
      • ConsentManager
      • DataSources
      • Lifecycle
      • Tealium
      • Tealium.Config
      • TealiumLocation
    • Release Notes
  • Android (Kotlin)
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • Identity Resolution
    • Module List
      • Ad Identifier Module
      • AutoTracking Module
      • AdobeVisitorService Module
      • Collect Module
      • Collectors Module
      • Crash Reporter Module
      • In-App Purchase Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Manager Module
      • Media Module
      • RemoteCommands Module
      • Tag Management Dispatcher Module
      • Visitor Service Module
    • Android TV
    • API Reference
      • ConsentCategory
      • ConsentManager
      • CurrentVisit
      • DataLayer
      • Lifecycle
      • LocationManager
      • Media
      • Tealium
      • TealiumConfig
      • VisitorProfile
      • VisitorService
    • Release Notes
  • Cordova 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
    • API Reference
    • Release Notes
  • Cordova 2.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Flutter 1.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
    • Release Notes
  • Flutter 2.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
      • Tealium
      • TealiumConfig
      • VisitorProfile
    • Release Notes
  • iOS (Objective-C)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Tag Management
    • Module List
      • Lifecycle Tracking Module
    • tvOS
    • watchOS
    • API Reference
    • Release Notes
  • iOS (Swift) 1.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • App Extensions
    • Identity Resolution
    • Consent Management
    • Modules
    • Module List
      • AppData Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DataSource Module
      • DefaultStorage Module
      • Delegate Module
      • DeviceData Module
      • DispatchQueue Module
      • FileStorage Module
      • Lifecycle Module
      • Location Module
      • Logger Module
      • PersistentData Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
      • VolatileData Module
    • Feature Comparison
    • Working with Objective-C
    • API Reference
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManagerDelegate
      • TealiumConsentManager
      • TealiumInstanceManager
      • TealiumPersistentData
      • TealiumVolatileData
      • Tealium
    • Release Notes
  • iOS (Swift) 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • App Extensions
    • Identity Resolution
    • Modules
    • Module List
      • AppData Module
      • AdobeVisitorService Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DeviceData Module
      • In-App Purchase Module
      • Lifecycle Module
      • Location Module
      • Media Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
    • Working with Objective-C
    • API Reference
      • LocationModule
      • MediaSession
      • Tealium
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManager
      • TealiumDataLayer
      • TealiumInstanceManager
    • Release Notes
  • NativeScript
    • Overview
    • Install
    • Track
    • API Reference
      • Tealium
      • TealiumConfig
    • Release Notes
  • React Native 1.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • React Native 2.x
    • Overview
    • Install
    • Track
    • Location Module
    • API Reference
    • Release Notes
  • Unity 1.x
    • Overview
    • Install
    • Track
    • API Reference
  • Unity 2.x
    • Overview
    • Install
    • Track
    • API Reference
  • Xamarin 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Consent Management
    • API Reference
    • Release Notes
  • Xamarin 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • API Reference
    • Release Notes
  • Web
  • Getting Started
    • Overview
    • Quick Start Guide
    • Web Concepts
    • Data Layer
      • An Introduction to the Data Layer
      • How the Data Layer Works for Websites
      • Data Layer Best Practices
      • Definitions
        • Retail
        • Publisher
        • Hotel
        • Travel
        • Basic Video Tracking
  • Adobe Launch
    • Overview
    • Install
    • Data Layer
  • AMP
    • Overview
    • Install
    • Track
    • Data Layer
  • Angular
    • Overview
    • Install
    • Track
    • API Reference
  • Google Tag Manager
    • Overview
    • Install
    • Data Layer
  • JavaScript (Web)
    • Overview
    • Install
    • Track
    • Data Layer
    • Universal Data Object (utag_data)
    • Universal Tag (utag.js)
    • Data Layer Object (b)
    • Single-Page Applications
    • Settings
    • Debugging
    • API Reference
      • Cookie Functions
      • GDPR Functions
      • Tracking Functions
      • Utility Functions
    • Release Notes
  • Server
  • C#
    • Overview
    • Install
    • Track
    • Data Layer
    • API Reference
    • Release Notes
  • HTTP API
    • Overview
    • Endpoint
    • Data Layer
  • Java
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Node
    • Overview
    • Install
    • Track
    • API Reference
  • Python
    • Overview
    • Install
    • Track
    • API Reference
  • Roku
    • Overview
    • Install
    • Track
    • API Reference
  • Ruby
    • Overview
    • Install
    • Track
    • API Reference
GETTING STARTED

Quick Start Guide

Quick start guide for mobile.

Install

Get started with installing Tealium for Android or iOS.

    To install Tealium for Android library with Maven:

    1. Add the Tealium Maven URL to your project’s top-level build.gradle file:

      allprojects {
        repositories {
          jcenter()
          maven {
            url "https://maven.tealiumiq.com/android/releases/"
          }
        }
      }
      
    2. In your project module’s build.gradle file, add the following Maven dependency:

      dependencies {
        implementation 'com.tealium:kotlin-core:1.X.X'
      }
      

    Check for the latest releases on Github and replace 1.X.X with the latest release number.

    To install Tealium for iOS library with Swift Package Manager:

    1. In your Xcode project, select File > Swift Packages > Add Package Dependency
    2. Enter the repository URL: https://github.com/tealium/tealium-swift
    3. Configure the version rules. Typically, Up to next major is recommended. If the current Tealium Swift library version does not appear in the list, then reset your Swift package cache.
    4. Select the modules to install and add the modules to each of your app targets in your Xcode project, under Frameworks > Libraries & Embedded Content

    Initialize

    Get started with initializing Tealium for Android or iOS.

      To initialize Tealium, configure a TealiumConfig instance and pass it into a Tealium instance. It’s recommended to initialize the Tealium Kotlin library in the app’s global application class within the onCreate() method.

      Manage your Tealium instance by using a tracking helper class, which provides a single point of entry for the Tealium Kotlin library and simplifies future upgrades.

      object TealiumHelper {
      
        lateinit var tealium: Tealium
      
        fun init(application: Application) {
          val tealiumConfig = TealiumConfig(
                            application,
                            "ACCOUNT",
                            "PROFILE",
                            Environment.DEV,
                            dataSourceId = "DATASOURCE_ID",  //optional
                            modules = mutableSetOf(VisitorService),
                            dispatchers = mutableSetOf(TagManagement, Collect)
                          )
          tealium = Tealium.create("tealium_instance", tealiumConfig)
        }
      }
      

      To initialize Tealium, pass a TealiumConfig instance to the Tealium() constructor.

      Manage your Tealium instance by using a tracking helper class, which provides a single point of entry for the Tealium iOS library and simplifies future upgrades.

      class TealiumHelper {
          static let shared = TealiumHelper()
          let config = TealiumConfig(account: "ACCOUNT",
                                     profile: "PROFILE",
                                     environment: "ENVIRONMENT",
                                     datasource: "DATASOURCE")
          var tealium: Tealium?
      
          private init() {
      
              // add necessary config options
              config.batchingEnabled = true
              config.logLevel = .debug
      
              // add desired Collectors - no need to include if want all compiled collectors
              config.collectors = [Collectors.Lifecycle,
                                   Collectors.Location,
                                   Collectors.VisitorService]
      
              // add desired Dispatchers - no need to include if want compiled dispatchers
              config.dispatchers = [Dispatchers.TagManagement,
                                    Dispatchers.RemoteCommands]
      
              tealium = Tealium(config: config)
      
              // optional post init processing
              tealium?.dataLayer.add("mykey", "myvalue", expiry: .forever)
      
          }
      
          public func start() {
              _ = TealiumHelper.shared
          }
      
          class func trackView(title: String, data: [String: Any]?) {    
            let tealView = TealiumView(title, dataLayer: data)
            TealiumHelper.shared.tealium?.track(tealView)
          }
      
          class func trackEvent(title: String, data: [String: Any]?) {
            let tealEvent = TealiumEvent(title, dataLayer: data)
            TealiumHelper.shared.tealium?.track(tealEvent)
          }
      }
      

      Mobile Publish Settings are enabled by default, and must be disabled if you don’t wish to use them. Configure the Mobile Publish Settings in iQ Tag Management, or disable them using config.shouldUseRemotePublishSettings = false.

      Track

      Get started with tracking views and events for Android or iOS.

      Track Views

      To track screen views, pass an instance of TealiumView(viewName:dataLayer:) to the track() method. TealiumView is comprised of a view name, which appears in the data layer as tealium_event, and an optional data dictionary.

        To track views:

        val tealView = TealiumView("screen_view", mutableMapOf("screen_name" to "Home"))
        tealium.track(tealView);
        

        To track views:

        let tealView = TealiumView("screen_view", dataLayer: ["screen_name": "Home"])
        tealium?.track(tealView)
        

        Track Events

        To track non-view events, pass an instance of TealiumEvent(eventName:dataLayer:) to the track() method. TealiumEvent is comprised of an event name, which appears in the data layer as tealium_event, and an optional data dictionary.

          To track events:

          val tealEvent = TealiumEvent("user_login", mutableMapOf("customer_id" to "1234567890"))
          tealium.track(tealEvent);
          

          To track events:

          let tealEvent = TealiumEvent("user_login", dataLayer: ["customer_id": "1234567890"])
          tealium?.track(tealEvent)
          

          The track() method tracks an event by accepting a TealiumDispatch of type TealiumEvent, which is comprised of an event name and an optional data dictionary.

          Data Layer

          Get started managing common data layer values and the data provided by each module for Android or iOS.

          To add data to the data layer:

            To set a String value use the putString() method:

            tealium.dataLayer.putString("my_string", "my_string_value")
            

            Similarly for different data types, the method begins with put, such as putInt() for integers and putDoubleArray() for an array of floating-point numbers. Learn more about methods for different data type.

            To set a String value to expire after 1 day:

            tealium.dataLayer.putString("my_string", "my_string_value", Expiry.afterTimeUnit(1, TimeUnit.DAYS))
            

            Learn more about the expiration types.

            To set a value of any type, use the add() method:

            tealium.dataLayer.add(key: "my_value", value: 123456)
            

            To set a value of any type to expire after 1 day:

            tealium?.dataLayer.add(key: "my_value", value: 123456, expiry: .afterCustom((.days, 1)))
            

            Identify

            Get started with adding a custom visitor ID for Android or iOS.

            Visitor ID

            The Tealium Android and Swift libraries generates a unique persistent visitor ID the first time it is launched and stores it in visitorId. This value is the primary visitor ID included in each tracked event as the attribute tealium_visitor_id.

              To get the visitor ID:

              class TealiumHelper {
                  lateinit var tealium: Tealium
              
                  fun getVisitorId(): String {
                      return tealium.visitorId
                  }
              }
              

              To get the visitor ID:

              class TealiumHelper {
                  var tealium: Tealium?
              
                  var visitorId: String? {
                      tealium?.visitorId
                  }
              }
              

              Provide additional visitor ID attributes to the data layer, as needed, by sending them as variables in your tracking calls.

              If you are using Tealium AudienceStream, visitorId is the primary visitor ID associated with the visitor. Learn more about configuring visitor IDs in AudienceStream.

              Secondary Visitor ID

              Include secondary visitor ID attributes as needed by adding them to the persistent data storage.

                To add a known visitor ID, such as a customer ID:

                fun setKnownVisitorId(id: String) {
                    tealium.dataLayer.putString("customer_id", id, Expiry.FOREVER)
                }
                

                To add a known visitor ID, such as a customer ID:

                func setKnownVisitorId(_ id: String) {
                    tealium?.dataLayer.add(key: "customer_id", value: id, expiry: .forever)
                }
                

                Validate

                Validate your data by inspecting log files, running a trace, and viewing live events.

                Logs

                Get started with logging for Android or iOS.

                  To set the log level, set the logLevel property:

                  Logger.logLevel = LogLevel.DEV // or LogLevel.QA, LogLevel.PROD
                  

                  To set the log level, set the logLevel property:

                  config.logLevel = .debug // or .info, .error, .fault, .silent
                  

                  Trace

                  Get started with trace for Android or iOS.

                    To join a trace, call the joinTrace() method:

                    Tealium["INSTANCE_NAME"]?.joinTrace("TRACE_ID")
                    

                    To leave a trace, call the leaveTrace() method:

                    Tealium["INSTANCE_NAME"]?.leaveTrace()
                    

                    To join a trace, call the joinTrace() method:

                    tealium?.joinTrace(id: "TRACE_ID")
                    

                    To leave a trace, call the leaveTrace() method:

                    tealium?.leaveTrace()
                    

                    The Mobile Trace Tool enhances the trace feature by providing a QR code that is scannable by your device, enabling you to quickly view events coming from the Tealium Mobile SDKs.

                    Live Events

                    The Live Events feature in Tealium EventStream is available to all Tealium customers for the purpose of toubleshooting mobile installations.

                    Learn more about using Live Events.

                    Next
                    Mobile Concepts
                    "Mobile Concepts"

                     

                    Was this article helpful?

                    This page was last updated: May 13, 2022      

                    Thank you for your feedback!

                    Table of Contents

                    • Install
                    • Initialize
                    • Track
                      • Track Views
                      • Track Events
                    • Data Layer
                    • Identify
                      • Visitor ID
                      • Secondary Visitor ID
                    • Validate
                      • Logs
                      • Trace
                      • Live Events
                    • Platforms
                    • Partners
                    • Forums
                    • Mobile
                    • Getting Started
                    • Remote Commands
                    • Android (Java)
                    • Android (Kotlin)
                    • Cordova 1.x
                    • Cordova 2.x
                    • Flutter 1.x
                    • Flutter 2.x
                    • iOS (Objective-C)
                    • iOS (Swift) 1.x
                    • iOS (Swift) 2.x
                    • NativeScript
                    • React Native 1.x
                    • React Native 2.x
                    • Unity 1.x
                    • Unity 2.x
                    • Xamarin 1.x
                    • Xamarin 2.x
                    • Web
                    • Getting Started
                    • Adobe Launch
                    • AMP
                    • Angular
                    • Google Tag Manager
                    • JavaScript (Web)
                    • Server
                    • C#
                    • HTTP API
                    • Java
                    • Node
                    • Python
                    • Roku
                    • Ruby