Promoted metrics logging library for React Native. Released for iOS and Android.
Add "@promotedai/react-native-metrics" as a dependency in your package.json file.
Call startSession* or log* directly from your React Native code when these events occur.
importPromotedMetricsfrom"@promotedai/react-native-metrics";PromotedMetrics.startSessionAndLogUser(user.uid);PromotedMetrics.logAction("Add to cart");PromotedMetrics.logView("Sign up");Impression tracking is possible for any kind of content. Here is an example using SectionList or FlatList using onViewableItemsChanged.
importPromotedMetrics,{useImpressionTracker}from"@promotedai/react-native-metrics";const{ _viewabilityConfig, _onViewableItemsChanged }=useImpressionTracker("MyListIdentifier",(viewToken)=>({content_id: viewToken.item.my_content_id,insertion_id: viewToken.item.promoted_insertion_id,name: viewToken.item.my_content_name}));return(<FlatListonViewableItemsChanged={_onViewableItemsChanged}viewabilityConfig={_viewabilityConfig}.../>
);In many cases, the Typescript library expects Objects as arguments to represent content. For these content objects, the library expects the following keys:
- (Required)
content_id,contentId, or_idshould contain a unique identifier for the content. This identifier can be anything from your system. - (Optional)
insertion_id, orinsertionIdshould contain the insertion ID as provided by Promoted for inserted content. - (Optional)
namecan contain a human-readable name for the content, and can be used for debugging purposes. This field is not sent to backends.
If your content objects contain additional data, we recommend filtering out all data except the above:
constcontentList=myViewableItems.map(i=>({content_id: i.my_content_id,insertion_id: i.promoted_insertion_id,name: i.my_content_name}));PromotedMetrics.collectionViewDidChange(contentList,"MyListIdentifier");