SDK

Instructions to implement the SDK to track off-chain dApp data.
Configuring SDK is essential for unlocking and collecting the off-chain data generated on your dApp. Configuring SDK will unlock data points like:
  • Wallet connections and all associated sessions data,
  • Funnel,
  • Wallet journey,
  • Interacting wallets,
  • Extracting wallets,
  • Wallet application types like MetaMask, WalletConnect, etc.,
  • And much more.

Overview

You can use the Spock Analytics' javascript package to keep track of the off-chain data in your dApp. It is easy to install as an npm package and will give you valuable off-chain insights into how your dApp is performing.

Installation

This package is available as a package on npm (named analytics-web3). Use the following to install into a project through npm/yarn.
NPM
npm install --save analytics-web3

Initialization

You will need an app key for initializing your package. You can get this app key from the app configuration page. Import the package like a standard Node.js module on the root of your project code and initialize it with your app key.
import Web3Analytics from 'analytics-web3';
// Enabling the debug mode flag is useful during implementation,
// but it's recommended to remove it for production
Web3Analytics.init({ appKey: 'YOUR APP KEY', debug: true });
// pass your web3 provider for web3 data tracking
Web3Analytics.walletProvider(window.ethereum);
SDK contains further tracking options which are covered in

DApp Specific Initialization & Tracking

The SDK is completely customizable and allows users to track the specific data they want within their dApp. Currently, the full SDK offers the capability to monitor six different data points in your dApp. However, the choice of what type of tracking to implement in the dApp is entirely up to the user. Notably, the web3 data point is mandatory when integrating the most basic version of the SDK.

Currently, the SDK enables three major products:

  1. 1.
    Explore.
  2. 2.
    Probe.
  3. 3.
    Engage.

To leverage Spock Analytics' 'Explore and Probe' offering, ensure that you activate these specific data points within your dApp.

  1. 1.
    Web3 Data.
  2. 2.
    Browser Profile.
  3. 3.
    Demographics.
  4. 4.
    Navigations.
  5. 5.
    UTM Params.
For Explore & Probe:
Web3Analytics.init(
{ appKey: 'YOUR APP KEY',
dataPoints: [
'browser_profile',
'demographics',
'navigation',
'utm_params'
'web3'
]
});
Engage
Engage empowers you to interact directly with your users, bridging the gap between your decentralized application and its audience. With the ability to engage through in-app messaging, you're equipped to efficiently acquire new users and create lasting relationships that drive growth.
Engage provides functionality for audience creation and campaign building within your dApp, allowing users to present offers through in-app pop-ups or Twitter messaging.

To create and monitor your campaign effectively, it is essential to activate the following data points within your dApp.

  1. 1.
    Web3.
  2. 2.
    UTM Params.
  3. 3.
    Engage.
Web3Analytics.init(
{ appKey: 'YOUR APP KEY',
dataPoints: ['engage', 'utm_params', 'web3']
});

Point to be Noted:

web3 is the essential data point for all products as it enables the tracking of wallet connections.

SDK Tracked Data Metrics:

The SDK offers a completely customizable solution that can be seamlessly integrated into Spock Analytics. This SDK is composed of six major modules, which collectively allow you to comprehensively track various aspects within your dApp. These modules provide a high degree of flexibility, enabling you to tailor your analytics to precisely match your needs:
  1. 1.
    Web3 Data: Obtain detailed insights on off-chain data while interacting with your dApp.
  2. 2.
    Demographics: Capture demographic information about your users to gain a better understanding of your audience.
  3. 3.
    Browser Profile: Analyze user behavior and preferences to enhance the user experience.
  4. 4.
    Navigation: Monitor and assess a range of metrics related to your website, such as outbound links, page visits, and page views.
  5. 5.
    UTM Parameters: Track the effectiveness of marketing campaigns by capturing UTM parameters from incoming traffic.
  6. 6.
    Engagement: Quantify the performance of your campaign, gauging its effectiveness and return on investment (ROI).
By utilizing these customizable modules, you can create an analytics framework that aligns precisely with your specific requirements. This empowers you to gather insights, make informed decisions, and enhance the overall performance and user experience of your dApp.
Category
Data Points
Web3 (Mandatory)
Wallet Address, Chain ID, Wallet Type, Wallet Connection, Max Gas Fee, Quoted Gas Fee, Transaction Hash, Transaction Status, Submitted and Rejected Transaction Count and Failed Transactions.
Browser Profile
Current URL, Operating System, Browser, Referrer, Device, Referring Domain, Screen Width, Screen height, and Search Engine.
Demographics
Country,City and Region.
Navigation
Page Views and External Links.
UTM Params
UTM Campaign, UTM Content, UTM Medium, UTM Source and UTM Term.
Engage
Session Time, Last Function, Session Transaction Count, Rejected Transaction Count, Failed Transaction Count, Clicks, Click Through Rate (CTR), Unique Wallets, Transactions/Conversions, Transaction Through Rate (TTR), Number of Sessions, Avg. Session Duration, Avg. Pages Per Session, Dialogs Served, and Dialogs Closed.
Each of these modules empowers you to track various aspects of your dApp's performance and user interactions.

User Privacy :

Ensuring user privacy is a fundamental principle within the Web3 ethos. As your dApp attracts users with various intentions, it is crucial to address their concerns regarding privacy. To address these concerns, Spock Analytics recommends initializing the SDK with passing optOut:true and then ask user consent for tracking, if he agrees to execute Web3Analytics.optInTracking(). Through this approach, you can prioritize user consent when it comes to collecting their off-chain data.
The Spock SDK provides the capability to collect data, but it operates in a privacy-conscious manner. If a user rejects or opts out of data tracking, the SDK will refrain from monitoring off-chain data associated with that specific user. However, you will still have the ability to analyze the user's on-chain behavior.
By emphasizing user privacy as our foremost priority, Spock Analytics, as a web3 analytics product, ensures that users can confidently engage with your dApp, knowing that their personal information and data remain protected.

Verify Installation

Head back to Spock Analytics to check the SDK status on the configurations page.
Once data hits our API, it generally takes ~60 seconds for it to be processed, stored, and queryable in your application.
If the data is not being fetched. Reload your dApp 1-2 times for the SDK to fire up properly.

FAQs

1. Is Spock Analytics reliant on third-party cookies?

No Spock Analytics doesn't use third-party cookies.

2. Does Spock Analytics provide an SDK for iOS or Android dApps?

Currently, Spock only has one SDK available, which can be integrated to track web-based events.

3. Can the Spock SDK be integrated with wallet extensions like MetaMask, and WalletConnect?

No, the Spock SDK is not compatible with tracking data for applications that are specifically related to wallet types.

4. Why Web3 Data point is mandatory in SDK ?

SDK monitors and logs wallet-related data, including behavior and activity within your dApp. Without tracking web3 datapoint, the resulting data may lack clarity and prove challenging to analyze in terms of user activity and behaviour.
To gain a complete understanding of both off-chain and on-chain data, it's necessary to enable web3 datapoint. Otherwise, while the data can still be displayed on the dashboard, it won't provide valuable insights within any of the metrics on the Spock dashboard.

Need Help? Contact Our Team

If you are stuck anywhere or have a suggestion or feedback, you can fill out the form here, or reach out to our team at [email protected].