# Step 5: Connect MoEngage campaigns

URL: https://www.digia.tech/docs/developer/moengage/connect-campaigns

MoEngage Change your setup in the sidebar
Link each MoEngage Self-Handled In-App campaign to a Digia Engage campaign with digia_campaign_key, so MoEngage decides who sees it.

Your app is ready to render campaigns. This step shows how a MoEngage campaign tells Digia what to render, and what to set on each campaign type.

## How Digia Maps to MoEngage Campaigns

> If you haven't read [How It Works](/docs/#how-it-works) in the overview, start there. The section below covers only what is MoEngage -specific.

In short: MoEngage decides **who** sees a campaign and **when** . Digia decides **what** is rendered. The two are linked by a `digia_campaign_key` you set in the MoEngage dashboard — the Digia plugin reads that key, resolves it against its local cache, and renders the right experience natively.

The table below shows how each Digia experience type maps to a MoEngage campaign type and which SDK component handles it on the app side:

| Experience Type | Digia Component | MoEngage Campaign Type | Description | **Nudge** | `DigiaHost` | Self-Handled In-App | Renders overlay experiences (bottom sheets, dialogs) above app content. | **Guide** | `DigiaAnchor` + `DigiaHost` | Self-Handled In-App | Step-by-step tooltip/spotlight flows anchored to specific UI elements. Each step targets a registered `anchorKey` . | **Survey** | `DigiaHost` | Self-Handled In-App | Multi-step survey flows rendered as overlays. | **Inline** | `DigiaSlot` | Self-Handled In-App | Renders inline content (banners, cards) within the app layout at a matching placement. 

Here is the end-to-end flow for a Self-Handled In-App campaign (Nudge, Guide, Survey, or Inline):

### The Campaign Contract

Whatever the experience type, a Digia-powered MoEngage campaign carries the same payload in its **Campaign data / Key-Value Pairs** field — a single JSON object:

```json
{
  "digia_campaign_key": "promo_offer_sheet",
  "variables": {
    "coupon": "SAVE20",
    "offer_title": "Limited Offer"
  }
}
```

- **`digia_campaign_key`** (required) — the key of the Digia campaign to render. This alone determines the experience type (nudge, guide, survey, or inline) and its design; nothing about the UI lives in the MoEngage payload.
- **`variables`** (optional) — a JSON object of runtime values interpolated into the campaign at render time.
Every experience type — nudge, guide, survey, and inline — is delivered through the same **Self-Handled In-App** campaign with this same payload. The per-experience sections below show it in context.

## Self-Handled In-App Campaigns

MoEngage supports a delivery mode called **Self-Handled In-App Campaigns** — instead of MoEngage rendering its own campaign UI, the SDK delivers the campaign payload to your app code. The Digia MoEngage plugin registers a self-handled in-app listener that intercepts this payload, extracts the **`digia_campaign_key`** , resolves it against the Digia campaigns pre-fetched at startup, and delegates rendering to Digia's runtime. **Without setting the campaign template type to Self Handled in the MoEngage dashboard, the payload will not be delivered to the plugin.**

No device-side sync is required — the plugin responds automatically once registered. Configure your campaign in the MoEngage dashboard:

1. Log in to the **MoEngage dashboard** and go to **Engage → In-App (NATIV)** .
2. Click **Create Campaign** and give it a name.
3. Set the **Template type** to **Self Handled** .
4. Configure the event trigger, audience, and schedule as required.
5. In the **Campaign data / Key-Value Pairs** field, add a key named **`digia_campaign_key`** with the Digia campaign key copied from your Digia dashboard.
See [MoEngage Self-Handled In-App](https://help.moengage.com/hc/en-us/articles/360051330591-Self-Handled-In-App-Template#h_01HP6KGBAVZDEV75BEFKRZ2M7R) .

## Trigger a Nudge from MoEngage

Create a Self-Handled In-App campaign in MoEngage. In the **Campaign data / Key-Value Pairs** field, provide the `digia_campaign_key` that links to your Digia campaign:

```json
{
  "digia_campaign_key": "promo_offer_sheet"
}
```

| Field | Required | Example value | Description | `digia_campaign_key` | Yes | `promo_offer_sheet` | The Digia campaign key copied from your Digia dashboard. Its type (nudge / guide / survey / inline) and design come from Digia, not the payload. | `variables` | No | `{"coupon":"SAVE20"}` | Optional JSON map of runtime variables interpolated into the campaign at render time. 

> **Linking:** In the Digia dashboard, copy the **Digia campaign key** assigned to your campaign. In the MoEngage Self-Handled In-App campaign's Key-Value Pairs, add a key named **`digia_campaign_key`** with that value. If the values differ, the plugin cannot resolve the campaign and nothing renders.

> **`variables` format:** Enter the value as plain JSON text directly in the field — e.g., `{"coupon":"SAVE20"}` . Do not wrap it in outer quotes. The plugin JSON-decodes the payload automatically.

## Serve Inline Content from MoEngage

`DigiaSlot` is a composable/widget that renders Digia-powered content inline within your screen layout. Each slot is identified by a `placementKey` . When a Self-Handled In-App campaign whose `digia_campaign_key` maps to an **inline** Digia campaign triggers, Digia renders that campaign into the slot whose `placementKey` matches the slot key configured on the campaign in the Digia dashboard. If no campaign is active for a slot, it collapses to zero height.

Inline campaigns are delivered the same way as nudges — through a Self-Handled In-App campaign carrying a `digia_campaign_key` . Build the inline campaign in the Digia dashboard (it defines which slot / `placementKey` it targets), then set `digia_campaign_key` to the Digia campaign key from that campaign:

```json
{
  "digia_campaign_key": "home_hero_banner_campaign"
}
```

| Field | Required | Description | `digia_campaign_key` | Yes | The Digia campaign key of an **inline** campaign copied from your Digia dashboard. The campaign defines which slot key it renders into. 

The app-side `DigiaSlot` / `DigiaSlotView``placementKey` must match the slot key configured on that campaign in the Digia dashboard.

info
Inline content stays loaded once a campaign renders it — it doesn't clear when the user's context changes. To clear it (for example on logout), seeManaging Inline Content .

## Link the MoEngage Campaign to Digia

To connect a MoEngage campaign to your Digia Guide, copy the **Digia campaign key** assigned to your Guide campaign in the Digia dashboard. Then, in the MoEngage Self-Handled In-App campaign's Key-Value Pairs, add a key named **`digia_campaign_key`** with that value:

```json
{
  "digia_campaign_key": "onboarding_tour"
}
```

> **Note:** The `digia_campaign_key` value must exactly match the Digia campaign key from the dashboard. If they differ, the plugin cannot resolve the campaign and nothing renders.

## Setting Up Surveys

Surveys are multi-step questionnaire flows you design in the Digia dashboard and render as overlays in the nudge host — no extra app-side widget is required beyond the [nudge container](/docs/developer/moengage/add-the-ui-pieces/#digiahost) . A survey is just another campaign type: create it in Digia, then trigger it from MoEngage by referencing its Digia campaign key via `digia_campaign_key` , exactly like a nudge.

1. Build the survey campaign in the Digia Engage Dashboard and copy its Digia campaign key.
2. Ensure your app mounts the nudge container — `DigiaHost` at the app root (all platforms).
3. Create a MoEngage Self-Handled In-App campaign and add a `digia_campaign_key` Key-Value Pair set to the survey's Digia campaign key.

```json
{
  "digia_campaign_key": "nps_q3_survey"
}
```

The survey renders over your app content and reports completion back through the plugin's analytics events.

## Personalize with variables

A Digia campaign shows personal values, such as a user's name or an offer amount, through `{{ variable }}` placeholders:

1. **Your campaign team declares the variables** in the Digia campaign's **Setup → Variables** step, each with a fallback value. Names use lowercase letters, digits and underscores, like `first_name` .
2. **The MoEngage campaign sends the values.** A value that's missing or empty uses the fallback.
3. **Let MoEngage fill in each user's value** with its personalization tags, so every user sees their own.
The campaign's **Integration details** panel in the Digia dashboard (on the **Review** step) gives you a ready-to-paste MoEngage config with a tag for each variable.

Keep every value in quotes. A value without quotes can make the whole set of variables unreadable.

Put the values in the `variables` object of the Self-Handled payload. Only the keys inside `variables` are used:

```json
{
  "digia_campaign_key": "promo_offer_sheet",
  "variables": {
    "first_name": "{{UserAttribute['first_name']|default('there')}}",
    "offer_amount": "20"
  }
}
```

## When several campaigns match

When one trigger matches several MoEngage campaigns, MoEngage shows only one, picked by its own rules (see [MoEngage 's documentation](https://www.moengage.com/docs/user-guide/campaigns-and-channels/in-app-message/analyze/campaign-delivery-mechanism-for-in-app-messages) ). Digia shows the campaign MoEngage sends. Digia also shows only one popup at a time: a campaign that arrives while another is on screen is dropped as `surface_busy` . SeeWhen Campaigns Overlap .

## Only target app versions that have Digia

A MoEngage campaign that points at a Digia campaign only works in app versions that include the Digia SDK. Users still on an older version of your app receive the MoEngage campaign too, but their app has nothing to show it with, so it doesn't appear correctly for them.

**Add an app version condition to the MoEngage campaign** , so it only targets your first app release with Digia and later. Raise that version again when a campaign uses something only a newer Digia SDK supports.
