react-native-replika-purchase-tracking
v0.1.833
Published
Purchase tracking directed from a Replika link
Downloads
27
Readme
react-native-replika-purchase-tracking
This utility library facilitates purchase tracking for users arriving at your application via a Replika link. It provides a streamlined way to monitor and record purchases made by these users, enhancing your ability to analyze the effectiveness of Replika-directed traffic.
Installation
npm install react-native-replika-purchase-tracking
Usage
Setting up tracking and passing down the link that will be checked for tracking. And an example of deep linking, in this example we use the 'expo-linking' library
import { ReplikaTracking } from 'react-native-replika-purchase-tracking';
import * as Linking from 'expo-linking';
// ...
const url = Linking.useURL();
const [replikaLink, setReplikaLink] = useState('');
if (url) {
const { hostname, path, queryParams } = Linking.parse(url);
setReplikaLink(url);
if (Object.keys(queryParams).length !== 0) {
navigation.navigate("productdetail", {
product: {
"_id": "1",
"image": "https://assets.adidas.com/images/w_940,f_auto,q_auto/5ae668a4e81749d6aa8c88dfee7c9882_9366/ID4989_01_standard.jpg",
"price": 10,
"quantity": 5,
"title": "Product 1",
}
});
}
}
// ...
return (
<TopLevelAppComponent store={store}>
<ReplikaTracking link={replikaLink}>
<ChildComponents />
</ReplikaTracking>
</TopLevelAppComponent>
);
Calling the purchaseMade
function
During the time of purchase make a call to the purchaseMade
function. The function will check to see if the purchase will be made.
- The first argument is the string key that you will be using to authorize the purchase.
- The second argument is the order details that you will be sending to the function. The order details should be in the format of the OrderDetails interface.
import { purchaseMade } from 'react-native-replika-purchase-tracking';
// ...
// Example of a purchaseMade call
purchaseMade("<YOUR STRING KEY HERE>", {
"consumerIdentifier": "anonymous",
"orderId": "MobileLibraryTest005",
"purchaseList": [
{
"productId": "AP_MBP_13",
"productName": "Absolute Repair",
"productPrice": "1800.00",
"currency": "$",
"productUrl": "https://myreplikacommerce.myreplika.com/absolute-repair-2",
"productImage": "https://myreplikacommerce.myreplika.com/images/thumbs/0000169_absolute-repair_550.jpeg",
"quantity": 2
},
{
"productId": "HP_ESB_15",
"productName": "Benefit Hair Oil",
"productPrice": "1460.50",
"currency": "$",
"productUrl": "https://myreplikacommerce.myreplika.com/benefit-hair-oil-2",
"productImage": "https://myreplikacommerce.myreplika.com/images/thumbs/0000171_benefit-hair-oil_550.jpeg",
"quantity": 1
}
],
"purchaseTotalInfo": {
"amount": "5060.50",
"currency": "$"
},
}).catch((error) => console.log('purchase Error', error));
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library