# Tealium

Consume Tealium data and send Airship engagement data to Tealium.

Tealium is a Customer Data Platform (CDP). CDPs collect, store, and normalize large volumes of data while creating a persistent identifier that spans across data sets. You can use the inbound and source integrations together or separately.

Inbound Integration
: Use Tealium to set [Tags](https://www.airship.com/docs/reference/glossary/#tag), [Attributes](https://www.airship.com/docs/reference/glossary/#attributes), and deliver [Custom Events](https://www.airship.com/docs/reference/glossary/#custom_event) in Airship. This data is synced between Tealium and Airship using [Named User](https://www.airship.com/docs/reference/glossary/#named_user).  

   Once in Airship, customers can segment based on those tags, events, and custom event properties, as well as trigger Automations and Sequences. Personalization using attributes and custom event properties is also supported. 

Source Integration
: Rich user-level App, SMS, Web, Email, and Open channel data is sent from Airship to Tealium using [Real-Time Data Streaming](https://www.airship.com/docs/reference/glossary/#rtds). Tealium then transforms Airship data into traits and audiences, unifying users and content across different platforms. You choose which RTDS events to send to Tealium.

## Tealium integration requirements

* **Accounts**
   1. Tealium
   1. Airship
      * Messaging
      * [Real-Time Data Streaming](https://www.airship.com/docs/reference/feature-packages/#data) — *Required for outbound integration only*
* **Airship project**
   * [Named User](https://www.airship.com/docs/reference/glossary/#named_user) must be enabled for your project.

## Configuring the Tealium inbound integration 

In Airship:

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **Partner Integrations**.
1. Select **Tealium**.
1. Select **Configure** for the inbound integration and follow the onscreen instructions to:
	* Create [Attributes](https://www.airship.com/docs/reference/glossary/#attributes), a [Tag Group](https://www.airship.com/docs/reference/glossary/#tag_group), and an authentication token. Tealium uses the token to communicate with your project in Airship.
	* Add a new connector for Airship in Tealium.

## Configuring the Tealium source integration

To set up this integration, you will:

1. Configure your app to set the `tealium_visitor_id` on Airship events. See the Kotlin and iOS setup sections below for more information.
1. Add Airship to Tealium as a source and retrieve your Data Source Endpoint.
1. Set up the RTDS integration for Tealium in the Airship dashboard.

When you set up a Tealium RTDS integration, your events will contain a `tealium_visitor_id` key. This is the identifier Tealium uses to differentiate between unique events. As a fallback, you may want to set your Airship [Named User](https://www.airship.com/docs/reference/glossary/#named_user) value to `tealium_visitor_id` to ensure that events are matched within Tealium.

### Set the `tealium_visitor_id` on Airship events

**Kotlin SDK example**

```kotlin
// Initialize the Tealium library
TealiumConfig tealiumConfig = TealiumConfig(
    application,
    {ACCOUNT},
    {PROFILE},
    {ENVIRONMENT},
    dataSourceId = {DATASOURCE_ID},  //optional
    modules = mutableSetOf(VisitorService),
    dispatchers = mutableSetOf(TagManagement, Collect)
  );
Tealium tealium = Tealium.create("tealium_instance", tealiumConfig);
// Get the Tealium visitor ID
String visitorId = tealium.getVisitorId();

// Add the visitor ID to the current associated identifiers
Airship.getAnalytics()
  .editAssociatedIdentifiers()
  .addIdentifier("tealium_visitor_id", visitorId)
  .apply();
```


See also: [Tealium Kotlin Identity Resolution documentation](https://docs.tealium.com/platforms/getting-started-mobile/identity-resolution/).
**Swift SDK example**

```swift
// Initialize the Tealium library
let config = TealiumConfig(account: {ACCOUNT},
               profile: {PROFILE},
               environment: {ENVIRONMENT},
               datasource: {DATASOURCE})
let tealium = Tealium(config: config)
// Get the Tealium visitor ID
let visitorId = tealium.visitorId

// Add the visitor ID to the current associated identifiers
let identifiers = Airship.analytics.currentAssociatedDeviceIdentifiers()
identifiers.set(identifier: visitorId, key:"tealium_visitor_id")
Airship.analytics.associateDeviceIdentifiers(identifiers)
```


See also: [Tealium Swift Identity Resolution documentation](https://docs.tealium.com/platforms/getting-started-mobile/identity-resolution/).

### Add Airship to Tealium as a source

You will also retrieve your *Data Source Endpoint URL*.

1. Log in to [Tealium](https://my.tealiumiq.com/).
1. In the sidebar, select **Sources**, then **Data Sources**, which will take you to a page where you can add Airship as a data source.
1. Select **Add Source**.
1. Under **Communication**, select **Airship**.
1. Enter a name for your Airship source integration.
1. Select **Continue** until you reach the **Choose Event Specifications** page.
   > **Note:** The event specifications currently do not support Airship-specific events. Tealium may add these in the future. For now, you can ignore the event specifications.

1. Select **Continue** to proceed to the **Get Code** page.
1. Copy the Data Source Endpoint URL. You will paste this in the Airship dashboard when setting up the RTDS integration.
   ![Copying the Data Source Endpoint URL from Tealium](https://www.airship.com/docs/images/tealium-install_hu_bbbcef297a7d9b29.webp)
   
   *Copying the Data Source Endpoint URL from Tealium*
   > **Note:** The Install steps listed in the Tealium **Get Code** page are the same as provided in the next section on this page. Please read the steps for information not provided by Tealium.


### Set up a Tealium RTDS integration in Airship

You will need your Tealium Data Source Endpoint URL.

In Airship:

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **Real-Time Data Streaming**.
1. Under **Real-Time Data Streaming**, select **Tealium**.
1. Follow the onscreen instructions to configure the integration.<p>You have the option to include anonymous data. Events that have a `tealium_visitor_id`, named user, or [delivery_address](https://www.airship.com/docs/developer/rest-api/connect/schemas/device-information/#sms-email-devices) (phone number, [MSISDN](https://www.airship.com/docs/reference/glossary/#msisdn), or email address) are delivered to Tealium by default. When electing to send anonymous data, Airship sends all events to Tealium regardless of whether the user is identified with a Visitor ID or Secondary Visitor ID.

See also [Airship incoming webhook setup guide](https://docs.tealium.com/server-side/data-sources/webhooks/airship/) in Tealium's *Incoming Webhooks* documentation.