Step 3: Report screens
Report the current screen to Digia Engage on every visit, so WebEngage campaigns can target specific screens in your React Native, Android, iOS and Flutter app.
Tell Digia which screen the user is on, every time they arrive on it (including coming back to it). Campaigns can then show on specific screens.
- React Native
- Android
- iOS (Swift)
- Flutter
With React Navigation, useFocusEffect runs each time a screen comes into focus:
import { useFocusEffect } from '@react-navigation/native';
import { useCallback } from 'react';
import { Digia } from '@digia-engage/core';
export function useScreenTracking(screenName: string) {
useFocusEffect(
useCallback(() => {
Digia.setCurrentScreen(screenName);
}, [screenName]),
);
}
// In each screen:
useScreenTracking('product_detail');
Using Expo Router, react-native-navigation, or no navigation library? See Reporting the Current Screen.
In Compose, at the top of each screen:
import com.digia.engage.DigiaScreen
@Composable
fun ProductDetailScreen() {
DigiaScreen("product_detail")
// … your screen
}
In an Activity or Fragment, call digiaScreen("product_detail") from onResume().
Use the same screen names as your iOS app. A campaign targets screens by name, and the same
campaign runs on both platforms. If Android reports product_detail and iOS reports
ProductDetailView, a campaign set up for product_detail never shows on iOS. Agree one list of
names with your iOS team, and keep it in a constants file in each app.
More cases (Activities, Fragments, pagers): see Reporting the Current Screen.
In SwiftUI, on the screen's root view:
ScrollView { /* … */ }
.onAppear { Digia.setCurrentScreen(name: "product_detail") }
In UIKit, call digiaScreen("product_detail") from viewDidAppear.
Use the same screen names as your Android app. A campaign targets screens by name, and the same
campaign runs on both platforms. If iOS reports ProductDetailView and Android reports
product_detail, a campaign set up for product_detail never shows on iOS. Agree one list of names
with your Android team, and keep it in a constants file in each app.
More cases (UIKit, SwiftUI lists): see Reporting the Current Screen.
DigiaNavigatorObserver (added in the previous step) reports named routes for you. For tabs or
unnamed routes, call it yourself:
Digia.setCurrentScreen('product_detail');
Using GoRouter, AutoRoute, or tab shells? See Reporting the Current Screen.
Screen names are case-sensitive. product_detail and ProductDetail are different screens. Your
campaign team doesn't type these names: when they capture screens from a debug build, the dashboard
lists the names your app reports, and they pick from that list. So the names in your code are the
names they see.
Reporting screens through Digia also records the screen view in WebEngage (screen),
so remove your own WebEngage screen-tracking call; you don't need both.