1.0.9 • Published 10 months ago

@web3analytic/retargeting-react v1.0.9

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
10 months ago

retargeting-react

Web3Analytic's react SDK for in-dapp retargeting

Install

npm install @web3analytic/retargeting-react

Usage

This package works through a React context provider.

Import the following:

import { 
  DappRetargetingProvider,
} from '@web3analytic/retargeting-react';

In your main App.tsx or whereever your React DOM and routes are, wrap the the DOM with the provider:

<DappRetargetingProvider>
  ...
</DappRetargetingProvider>

Then, in the component where users are connecting their wallet to your frontend, add the following lines:

import { useDappRetargeting } from '@web3analytic/retargeting-react';
...
const { onUserAction } = useDappRetargeting(); 

The function onUserAction is defined by this SDK as a callback when the end-user takes an off-chain or on-chain action. It will automatically register an impression and render the notification. For off-chain actions, you must provide an identifier matching the one specified upon campaign creation. For on-chain actions, you must provide the transaction hash and chain. See https://www.npmjs.com/package/@web3analytic/retargeting-sdk for more details!