> For the complete documentation index, see [llms.txt](https://spock-analytics.gitbook.io/spock-analytics-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spock-analytics.gitbook.io/spock-analytics-docs/sdk-configuration/full-api-reference.md).

# Full 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**

```javascript
Web3Analytics.init({ appKey: 'YOUR APP KEY'});
```

<table><thead><tr><th width="148">Argument</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td>appKey</td><td>String</td><td>Unique appKey like <code>eba6...28c</code> for tracking. Can be obtained from the app's <a href="https://app.spockanalytics.xyz/dapp/config">configuration</a> page.</td></tr><tr><td><strong>Optional</strong></td><td></td><td></td></tr><tr><td>debug</td><td>Boolean</td><td>Defaults to <code>false</code>. Enable consoles for all the tracking events.</td></tr><tr><td>dataPoints</td><td>string[]</td><td><p>By default, SDK will track all data </p><p>points. But you can limit them by passing the desired <a href="/spock-analytics-docs/sdk-configuration/sdk.md#data-points">datapoints</a>.</p></td></tr><tr><td>inactivityTimeout</td><td>number</td><td>Defaults to <code>30</code>. This field takes time in mins to specify the inactivity duration in which the session will expire.</td></tr><tr><td>optOut</td><td>Boolean</td><td>Defaults to <code>false</code>. Opt users out of tracking.</td></tr><tr><td>testENV</td><td>Boolean</td><td>Defaults to <code>false</code>. Enable testing version of SDK in which SDK will interact with testing servers.</td></tr><tr><td>testMode</td><td>Boolean</td><td>Defaults to <code>false</code>. Enable test mode in which you can test tracking events without logging data onto the server in order to avoid storing testing data.</td></tr></tbody></table>

### Web3Analytics.walletProvider

Pass `web3 provider` to track wallet connections for all [supported wallets](/spock-analytics-docs/sdk-configuration/supported-wallets.md) and transaction status that are submitted or rejected on the dApp.

#### Usage

```javascript
Web3Analytics.walletProvider(window.ethereum);
```

In case of handling multiple wallets on the dApp. Example in `React`.

```javascript
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]);
```

<table><thead><tr><th width="139">Argument</th><th width="120">Type</th><th>Description</th></tr></thead><tbody><tr><td>provider</td><td>Web3Provider</td><td>EIP-1193 Standard Provider or Web3Provider-compatible Provider</td></tr></tbody></table>

### Web3Analytics.trackWalletConnection

To track other wallets that are currently not supported as mentioned [here](/spock-analytics-docs/sdk-configuration/supported-wallets.md).\
\
**Usage**

```javascript
Web3Analytics.trackWalletConnection('Ledger', '0x...96', 1);
```

<table><thead><tr><th width="142">Argument</th><th width="105">Type</th><th>Description</th></tr></thead><tbody><tr><td>walletType</td><td>String</td><td>Name of wallet</td></tr><tr><td>account</td><td>String</td><td>User Ethereum address</td></tr><tr><td>chainId</td><td>number</td><td>User connected chainId</td></tr></tbody></table>

### Web3Analytics.trackPageView

Track all the pages visited on a DApp.

#### Usage

```javascript
Web3Analytics.trackPageView('/home');
```

<table><thead><tr><th width="147">Argument</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td>path</td><td>String</td><td>Path of the page. e.g. '/about', '/dashboard/stats'</td></tr><tr><td>search</td><td>String</td><td>Query string of the page. eg: '?id=ab02'</td></tr></tbody></table>

### Web3Analytics.optOutTracking

Opt user out from tracking.

#### Usage

```javascript
Web3Analytics.optOutTracking();
```

<table><thead><tr><th width="147">Argument</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td>expiration</td><td>number</td><td>Default <code>365</code>. Duration in days for which the user is opt-out</td></tr></tbody></table>

### Web3Analytics.optInTracking

Opt user in tracking.

#### Usage

```javascript
Web3Analytics.optInTracking();
```

<table><thead><tr><th width="147">Argument</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td>expiration</td><td>number</td><td>Default <code>365</code>. Duration in days for which the user is opt-in</td></tr></tbody></table>

### Web3Analytics.hasOptedOutTracking

Getter method for the status of user tracking consent.

#### Usage

```javascript
Web3Analytics.hasOptedOutTracking();
```

<table><thead><tr><th width="134">Argument</th><th width="137">Return Type</th><th>Description</th></tr></thead><tbody><tr><td>-</td><td>number</td><td>Status of user tracking consent</td></tr></tbody></table>
