Overview
Cryptique provides specialized methods for tracking wallet connections in Web3 applications. The SDK automatically detects wallet connections via EIP-6963 and window.ethereum, but you can also manually trigger wallet tracking.
When a wallet connects, Cryptique automatically links the wallet address to the current session and user profile. This enables unified analytics across off-chain behavior and on-chain transactions.
Automatic Wallet Detection
Cryptique automatically detects:
Wallet Connection : When window.ethereum or EIP-6963 providers connect
Account Changes : When user switches accounts (accountsChanged event)
Chain Changes : When user switches networks (chainChanged event)
Wallet Type : MetaMask, Coinbase Wallet, WalletConnect, etc.
This data is captured in session data without any code required.
Cryptique.walletAddress()
Associate a wallet address with the current user. Use this when you have the wallet address from your connection flow.
Cryptique . walletAddress ( address )
The wallet address to associate with the current user (e.g., 0x742d35Cc6634C0532925a3b844Bc9e7595f5bB21).
Returns
void
How It Works
When you call walletAddress():
The address is linked to the current session
If this address exists for another user profile, the profiles are merged via CQ Intelligence
The wallet becomes available for enrichment (if enabled)
Examples
// After your own wallet connection logic
const address = await connectWallet ();
Cryptique . walletAddress ( address );
// With ethers.js
const provider = new ethers . BrowserProvider ( window . ethereum );
const signer = await provider . getSigner ();
const address = await signer . getAddress ();
Cryptique . walletAddress ( address );
// With wagmi
const { address } = useAccount ();
useEffect (() => {
if ( address ) {
Cryptique . walletAddress ( address );
}
}, [ address ]);
// With RainbowKit
const { address , isConnected } = useAccount ();
useEffect (() => {
if ( isConnected && address ) {
Cryptique . walletAddress ( address );
}
}, [ isConnected , address ]);
Multiple Wallets
Users can connect multiple wallets. Each call to walletAddress() adds to the user’s wallet collection:
// User connects first wallet
Cryptique . walletAddress ( '0x111...' );
// User connects second wallet
Cryptique . walletAddress ( '0x222...' );
// Both wallets are now linked to this user profile
The user profile accumulates all connected wallets. You can see all associated wallets in the Cryptique dashboard under the user’s profile.
Wallet Disconnect Behavior
There is no explicit disconnect method. Disconnection is handled automatically:
SDK listens to accountsChanged events
When accounts become empty (disconnected), session data updates
wallet_connected session field becomes false
Last wallet data is retained for the session
Combining with identify()
You can use wallet address as the user’s identity:
// Option 1: Wallet as primary identity
function handleWalletConnect ( address ) {
Cryptique . identify ( address );
Cryptique . walletAddress ( address );
}
// Option 2: Separate user ID + wallet
function handleWalletConnect ( userId , walletAddress ) {
Cryptique . identify ( userId );
Cryptique . walletAddress ( walletAddress );
}
Session Data Fields
When a wallet is connected, these fields are captured in session data:
Field Type Description wallet_connectedboolean Whether a wallet is currently connected wallet_addressstring The connected wallet address wallet_typestring Detected wallet provider (MetaMask, etc.) chain_idnumber Connected chain ID
Integration Examples
wagmi + React
ethers.js
Web3Modal
import { useAccount } from 'wagmi' ;
import { useEffect } from 'react' ;
import Cryptique from 'cryptique-sdk' ;
function WalletTracker () {
const { address , isConnected , connector } = useAccount ();
useEffect (() => {
if ( isConnected && address ) {
Cryptique . walletAddress ( address );
Cryptique . track ( 'wallet_connected' , {
address: address ,
wallet_type: connector ?. name
});
}
}, [ isConnected , address , connector ]);
return null ;
}
// Use in your app
function App () {
return (
<>
< WalletTracker />
{ /* rest of app */ }
</>
);
}
import { ethers } from 'ethers' ;
import Cryptique from 'cryptique-sdk' ;
async function connectWallet () {
if ( ! window . ethereum ) {
alert ( 'Please install a wallet' );
return ;
}
const provider = new ethers . BrowserProvider ( window . ethereum );
await provider . send ( 'eth_requestAccounts' , []);
const signer = await provider . getSigner ();
const address = await signer . getAddress ();
const network = await provider . getNetwork ();
// Track with Cryptique
Cryptique . walletAddress ( address );
Cryptique . track ( 'wallet_connected' , {
address: address ,
chain_id: Number ( network . chainId )
});
return { address , provider , signer };
}
// Listen for account changes
window . ethereum ?. on ( 'accountsChanged' , ( accounts ) => {
if ( accounts . length > 0 ) {
Cryptique . walletAddress ( accounts [ 0 ]);
}
});
import { createWeb3Modal , defaultConfig } from '@web3modal/ethers5' ;
import Cryptique from 'cryptique-sdk' ;
const modal = createWeb3Modal ({
ethersConfig: defaultConfig ({ metadata }),
chains: [ mainnet ],
projectId: 'YOUR_PROJECT_ID'
});
// Subscribe to connection events
modal . subscribeProvider (({ address , isConnected }) => {
if ( isConnected && address ) {
Cryptique . walletAddress ( address );
Cryptique . track ( 'wallet_connected' , { address });
}
});
Best Practices
Track Connection Events
// Track the connection as an event too
function handleWalletConnect ( address , chainId ) {
Cryptique . walletAddress ( address );
Cryptique . track ( 'wallet_connected' , {
address: address ,
chain_id: chainId ,
connection_method: 'metamask'
});
}
Handle Multiple Chains
// Track chain switches
window . ethereum ?. on ( 'chainChanged' , ( chainId ) => {
Cryptique . track ( 'chain_switched' , {
new_chain_id: parseInt ( chainId , 16 ),
chain_name: getChainName ( chainId )
});
});
Store Primary Wallet
// If user has multiple wallets, track the primary one
function setPrimaryWallet ( address ) {
Cryptique . people . set ({
primary_wallet: address
});
}
Identify Users Link wallets to user identities
Wallet Enrichment Get on-chain wallet data