# Data Enrichment

The JENTIS App SDK empowers you to enhance your server-side tracking with data enrichment services. By simply using a provided command, you can easily add enrichment to a Data Submission request sent to JENTIS. Our servers will then process the data, enrich it, and forward it to your configured connectors.

This article explains exactly how to add the enrichment commands to your app. You will need app development expertise for this.

## How to enrich your data with App Tracking:

There are currently two ways to add enrichment to your app tracking with JENTIS: with the `addEnrichment()` or the `addCustomEnrichment()` commands.

{% hint style="info" %}
Regardless of the chosen approach, you must add the enrichment before every `.submit()` call, if needed.
{% endhint %}

### Option 1: Add Enrichment

The `addEnrichment()` command uses reference logic for the values of its arguments. This means you can reuse tracked data from the `.push()` chain. This approach reduces potential issues caused by providing the same data multiple times and enhances reusability within your APP.

#### How to implement on your iOS App:

```swift
TrackingService.shared.addEnrichment(
    pluginId: "productEnrichmentService",
    arguments: [
        "productId": "product_id"
    ],
    variables: ["enrich_product_name","enrich_product_brutto"]
)
```

Full Example:

```swift
TrackingService.shared.push([
    "track": "pageview",
    "pagetitle": "Demo-APP Order Confirmed"
])

TrackingService.shared.push([
    "track": "product",
    "type": "order",
    "id": "123"
])

TrackingService.shared.push([
    "track": "product",
    "type": "order",
    "id": "456"
])

TrackingService.shared.push([
    "track": "order",
    "orderid": "12345666",
    "brutto": 499.98,
    "paytype": "creditcard"
])

TrackingService.shared.addEnrichment(
    pluginId: "productEnrichmentService",
    arguments: [
        "productId": "product_id"
    ],
    variables: ["enrich_product_name","enrich_product_brutto"]
)

TrackingService.shared.submit()
```

#### How to implement on your Android app:

```kotlin
val enrichmentMap = mapOf(
  "plugin" to mapOf(
    "pluginId" to "productEnrichmentService"
  ),
  "enrichment" to mapOf(
    "variablesEnrichment" to listOf("enrichment_product_variant")
  ),
  "args" to mapOf(
    "accountId" to "account",
    "page_title" to "pagetitle",
    "productId" to "product_id"
  )
)

JentisTrackService.getInstance().addEnrichment(mockEnrichment, enrichmentMap)
```

Full Example:

```kotlin
val mockEnrichment = listOf(
  mapOf(
    "track" to "pageview",
    "pagetitle" to "Demo-APP Order Confirmed",
    "account" to "JENTIS TEST ACCOUNT"
  ),
  mapOf(
    "track" to "product",
    "type" to "order",
    "id" to "123",
    "name" to "Testproduct",
    "brutto" to 199.99
  ),
  mapOf(
    "track" to "product",
    "type" to "currentcart",
    "id" to "777",
    "color" to "green"
  ),
  mapOf(
    "track" to "product",
    "type" to "order",
    "id" to "456",
    "name" to "Testproduct 2",
    "brutto" to 299.99
  ),
  mapOf(
    "track" to "order",
    "orderid" to "12345666",
    "brutto" to 499.98,
    "paytype" to "creditcart"
  )
)

val enrichmentMap = mapOf(
  "plugin" to mapOf(
    "pluginId" to "productEnrichmentService"
  ),
  "enrichment" to mapOf(
    "variablesEnrichment" to listOf("enrichment_product_variant")
  ),
  "args" to mapOf(
    "accountId" to "account",
    "page_title" to "pagetitle",
    "productId" to "product_id"
  )
)

JentisTrackService.getInstance().addEnrichment(mockEnrichment, enrichmentMap)

JentisTrackService.getInstance().submit()
```

### Option 2: Add Custom - Enrichment

The `addCustomEnrichment()` command uses static values for its arguments. This is useful for enriching data by passing static and predefined information.

#### How to implement on your iOS App:

```swift
TrackingService.shared.addCustomEnrichment(
   pluginId: "enrichment_xxxlprodfeed",
   arguments: [
       "account": "JENTIS TEST ACCOUNT",
       "page_title": "MY PAGE TITLE",
       "productId": ["123", "ABC", "3"],
       "baseProductId": ["1"]
   ],
   variables: ["enrichment_product_variant"]
)
```

#### How to implement on your Android App:

```kotlin
val enrichmentMap = mapOf(
    "plugin" to mapOf(
        "pluginId" to "enrichment_prodfeed"
    ),
    "enrichment" to mapOf(
        "variablesEnrichment" to listOf("enrichment_product_variant")
    ),
    "args" to mapOf(
        "accountId" to "JENTIS TEST ACCOUNT",
        "page_title" to "Demo-APP Order Confirmed",
        "productId" to listOf("111", "222", "333", "444")
    )
)

JentisTrackService.getInstance().addCustomEnrichment(enrichmentMap)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jentis.com/app-tracking-setup/data-enrichment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
