Comment on page
API Reference
Web3Analytics must be initialized with
appKey
by invoking the init method at the top level of the application before using other methods.Usage
Web3Analytics.init({ appKey: 'YOUR APP KEY'});
Argument | Type | Description |
---|---|---|
appKey | String | |
Optional | | |
debug | Boolean | Defaults to false . Enable consoles for all the tracking events. |
dataPoints | string[] | By default, SDK will track all data |
inactivityTimeout | number | Defaults to 30 . This field takes time in mins to specify the inactivity duration in which the session will expire. |
optOut | Boolean | Defaults to false . Opt users out of tracking. |
testENV | Boolean | Defaults to false . Enable testing version of SDK in which SDK will interact with testing servers. |
testMode | Boolean | Defaults to false . Enable test mode in which you can test tracking events without logging data onto the server in order to avoid storing testing data. |
Pass
web3 provider
to track wallet connections and transaction status that are submitted or rejected on the dApp.Web3Analytics.walletProvider(window.ethereum);
In case of handling multiple wallets on the dApp. Example in
React
.import { useWeb3React } from '@web3-react/core';
const { provider } = useWeb3React();
//in order to pass an updated provider if the user changes wallet, account or chain.
useEffect(() => {
if (provider?.provider) {
Web3Analytics.walletProvider(provider.provider);
}
}, [provider]);
Argument | Type | Description |
---|---|---|
provider | Web3Provider | EIP-1193 Standard Provider or Web3Provider-compatible Provider |
Web3Analytics.trackWalletConnection('Ledger', '0x...96', 1);
Argument | Type | Description |
---|---|---|
walletType | String | Name of wallet |
account | String | User Ethereum address |
chainId | number | User connected chainId |
Track all the pages visited on a DApp.
Web3Analytics.trackPageView('/home');
Argument | Type | Description |
---|---|---|
path | String | Path of the page. e.g. '/about', '/dashboard/stats' |
search | String | Query string of the page. eg: '?id=ab02' |
Opt user out from tracking.
Web3Analytics.optOutTracking();
Argument | Type | Description |
---|---|---|
expiration | number | Default 365 . Duration in days for which the user is opt-out |
Opt user in tracking.
Web3Analytics.optInTracking();
Argument | Type | Description |
---|---|---|
expiration | number | Default 365 . Duration in days for which the user is opt-in |
Getter method for the status of user tracking consent.
Web3Analytics.hasOptedOutTracking();
Argument | Return Type | Description |
---|---|---|
- | number | Status of user tracking consent |
For the custom on-click implementation of widget button.
Web3Analytics.widgetOnClick(({ campaignId }) => {
if (campaignId === YOUR_CAMPAIGN_ID) {
//do something
}
});
Params | Type | Description |
---|---|---|
campaignId | number | A unique campaign ID belongs to the widget. |
redirectUrl | string | undefined | Redirect URL set on the campaign button click. |
Last modified 2mo ago