Skip to content

Send Action (Event) Examples

ruofan edited this page Feb 19, 2024 · 29 revisions

Prerequisites

  • Import OmniSegment SDK in your React Native project.
  • Ensure that the OmniSegment is properly initialized and configured.

App Open

Syntax and Usage

import OmniSegment, {
  OSGEventBuilder,
} from "bebit-tech-react-native-app-sdk";

const App = () => {
  useEffect(() => {
    SplashScreen.hide();
    OmniSegment.setFCMToken("Test FCM Token from RN");
    OmniSegment.setAppId("TestAppId");
    OmniSegment.setAppName("TestAppName");
    OmniSegment.setDeviceId("TestDeviceId");
    const event = OSGEventBuilder.appOpen()
    event.location = 'app://LaunchApp' // you can set your deeplink here
    event.locationTitle = 'RN Test App @OpenApp'
    OmniSegment.trackEvent(event);
  }, []);
  return (
    <NavigationContainer>
      <Stack.Navigator screenOptions={{ headerShown: false }}>
        <Stack.Screen name='Login' component={LoginScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
};

export default App;

Explanation

Browsing history

  • You can find the incoming data in OmniSegment under the customer page, in the corresponding user details, and browsing history.
截圖 2024-02-19 下午1 03 22

Complete Registration

Syntax and Usage

  • Tracking with Email:
import OmniSegment, {
  OSGEventBuilder,
  OSGRecommendRequest,
  OSGRecommendType,
  OSGProduct,
} from "bebit-tech-react-native-app-sdk";

const LoginScreen = ({ navigation }: any) => {
  const handleLogin = () => {
    
    OmniSegment.login("omnisegment20240101"); // OmniSegment.login should be called with the unique user identifier (uid) of the member

    OmniSegment.setFCMToken("Test FCM Token from RN");
    OmniSegment.setCurrentPage("Login");

    OmniSegment.setAppId("TestAppId");
    OmniSegment.setAppName("TestAppName");
    OmniSegment.setDeviceId("TestDeviceId"); // OmniSegment.setDeviceId should be called with the unique device identifier (cid)


    const event = OSGEventBuilder.completeRegistration({email: 'renee@bebit-tech.com'})
    event.location = 'app://Login' // you can set your deeplink here
    event.locationTitle = 'Login'
    OmniSegment.trackEvent(event);

    navigation.navigate("Tab", { screen: "Home" });
   };

 return (
   <View style={styles.container}>
      <TouchableOpacity style={styles.button} onPress={handleLogin}>
        <Text style={styles.buttonText}>Login</Text>
      </TouchableOpacity>
   </View>
    )
  };
  • Tracking with Registration Type:
import OmniSegment, {
  OSGEventBuilder,
  OSGRecommendRequest,
  OSGRecommendType,
  OSGProduct,
} from "bebit-tech-react-native-app-sdk";

const LoginScreen = ({ navigation }: any) => {
  const handleLogin = () => {
    
    OmniSegment.login("omnisegment20240101"); // OmniSegment.login should be called with the unique user identifier (uid) of the member

    OmniSegment.setFCMToken("Test FCM Token from RN");
    OmniSegment.setCurrentPage("Login");

    OmniSegment.setAppId("TestAppId");
    OmniSegment.setAppName("TestAppName");
    OmniSegment.setDeviceId("TestDeviceId"); // OmniSegment.setDeviceId should be called with the unique device identifier (cid)

    const event = OSGEventBuilder.completeRegistration({regType: 'Google'});
    event.location = 'app://Login'
    event.locationTitle = 'Login'
    OmniSegment.trackEvent(event);

    navigation.navigate("Tab", { screen: "Home" });
   };

 return (
   <View style={styles.container}>
      <TouchableOpacity style={styles.button} onPress={handleLogin}>
        <Text style={styles.buttonText}>Login</Text>
      </TouchableOpacity>
   </View>
    )
  };

Explanation

  • The label dictionary can include various keys like email or regeType. These keys can be customized based on the data you want to track.

Browsing history

  • You can find the incoming data in OmniSegment under the customer page, in the corresponding user details, and browsing history.
截圖 2024-02-19 下午1 02 15

Clone this wiki locally