Comment on page

API Reference

Web3Analyitcs.init

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
Unique appKey like eba6...28c for tracking. Can be obtained from the app's configuration page.
Optional
debug
Boolean
Defaults to false. Enable consoles for all the tracking events.
dataPoints
string[]
By default, SDK will track all data
points. But you can limit them by passing the desired datapoints.
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.

Web3Analytics.walletProvider

Pass web3 provider to track wallet connections and transaction status that are submitted or rejected on the dApp.
Wallets that are not included in Supporting Wallets will be classified as Other wallet type.

Usage

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

To track the wallet type for wallets that are not part of Supporting Wallets. Usage
Web3Analytics.trackWalletConnection('Ledger', '0x...96', 1);
Argument
Type
Description
walletType
String
Name of wallet
account
String
User Ethereum address
chainId
number
User connected chainId

Web3Analytics.trackPageView

Track all the pages visited on a DApp.

Usage

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'

Web3Analytics.optOutTracking

Opt user out from tracking.

Usage

Web3Analytics.optOutTracking();
Argument
Type
Description
expiration
number
Default 365. Duration in days for which the user is opt-out

Web3Analytics.optInTracking

Opt user in tracking.

Usage

Web3Analytics.optInTracking();
Argument
Type
Description
expiration
number
Default 365. Duration in days for which the user is opt-in

Web3Analytics.hasOptedOutTracking

Getter method for the status of user tracking consent.

Usage

Web3Analytics.hasOptedOutTracking();
Argument
Return Type
Description
-
number
Status of user tracking consent

Web3Analytics.widgetOnClick

For the custom on-click implementation of widget button.

Usage

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.