Skip to main content
MoEngageChange your setup in the sidebar

Step 2: Add the UI pieces

Add DigiaHost, DigiaAnchor and DigiaSlot to your app so MoEngage-triggered Digia nudges, guides and inline content have a place to appear.

Campaigns need a place in your app to appear. There are three pieces. Add the ones for the campaign types your team plans to use:

PieceWhat it isNeeded for
DigiaHostOne layer above your whole app where popups appear. Android View and iOS UIKit apps add it with one call instead.Nudges, surveys, floating videos, and guides
DigiaAnchorA label you put on a button or other element, so a guide can point at it.Guides (tooltips and spotlights)
DigiaSlotAn empty space in your layout that inline content fills.Inline banners, carousels and stories

DigiaHost​

Add exactly one host, at your app's root. It's required: without it, campaigns are accepted but never appear, and are dropped as host_not_mounted. With two, popups can appear twice.

import { View } from 'react-native';
import { DigiaHost } from '@digia-engage/core';

export default function RootLayout() {
return (
<View style={{ flex: 1 }}>
<AppNavigator />
{/* Keep it last, so it sits above your app. */}
<DigiaHost />
</View>
);
}

In React Native, popups (nudges, surveys, floating videos) are drawn by a native host that Digia.initialize adds for you. <DigiaHost /> draws guides. Add it once, as the last child of your root view; placed earlier, your own screens can cover guide tooltips.

DigiaAnchor​

A guide is a tooltip or spotlight that points at something in your app, such as "Tap here to check out". DigiaAnchor tells Digia which element that is. You wrap the element and give it a name, the anchorKey. The element looks and works exactly as before.

import { DigiaAnchorView } from '@digia-engage/core';

<DigiaAnchorView anchorKey="cart_checkout_button">
<CheckoutButton />
</DigiaAnchorView>

Before you add anchors: guides only work well on elements that are always on screen, such as tab bar items or a screen's main button. On lists, content that loads later, or elements only some users see, a guide can skip steps or not show. Read Guide Anchors and Inline Slots before you choose where to put them.

A spotlight can also work without an anchor, on elements that don't scroll. See Spotlights without an anchor.

DigiaSlot​

A slot is a space in your layout where inline content can appear, such as a banner at the top of Home. You place the slot and give it a name, the placementKey. Your campaign team then picks that slot when they build an inline campaign.

import { DigiaSlotView } from '@digia-engage/core';

<DigiaSlotView placementKey="home_top" />

Before you add slots: an empty slot takes no space and grows when content arrives, so whatever is below it moves down. Read Guide Anchors and Inline Slots before you choose where to put them.

Share your anchor keys and slot keys with your campaign team. They pick them in the dashboard.

Details to keep in mind​

  • Guide anchors: when a Guide campaign runs, the SDK looks up the anchorKey to position the tooltip bubble or spotlight cutout relative to that element. Give each element a unique anchorKey. The key must match exactly what is configured for that step in the Digia dashboard Guide campaign.
  • Anchor not on screen: if the anchor is not mounted when a Guide campaign fires, the SDK logs an anchor_not_on_screen health event and skips that step. Ensure the anchor is on screen before navigating to the Guide step.
  • Inline slots: each slot's placementKey must match the slot key configured on the inline campaign in the Digia dashboard. If no campaign is active for a slot, it collapses to zero height.
  • React Native slot height: DigiaSlotView auto-sizes to match native content height. Pass style={{ height: N }} to pin a fixed height.

Android View/XML layouts: DigiaSlotView wraps the Compose DigiaSlot API and reads app:placementKey from XML. DigiaSlotView needs a host in the same Activity: Digia.attach(application) or a DigiaHost (see above). Or set the placement programmatically after inflation:

import com.digia.engage.DigiaSlotView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)

findViewById<DigiaSlotView>(R.id.homeHeroBanner).placementKey = "home_hero_banner"
findViewById<DigiaSlotView>(R.id.productOffers).placementKey = "product_offers"
}