Skip to main content

Overview

Events are the foundation of analytics in Cryptique. Every user action—from page views to transactions—is captured as an event with associated properties.

Event Structure

Every event has this structure:
{
  // Required
  "event_name": "swap_completed",
  "distinct_id": "user_12345",
  "timestamp": "2024-01-15T10:30:00.000Z",
  
  // Auto-captured (default properties)
  "session_id": "sess_abc123",
  "current_url": "https://app.example.com/swap",
  "browser_name": "Chrome",
  "country": "US",
  // ... more default properties
  
  // Custom (your properties)
  "properties": {
    "input_token": "ETH",
    "output_token": "USDC", 
    "amount": 1.5,
    "slippage": 0.5
  }
}

Event Types

Auto-Events

Captured automatically only when auto-events="true" (or Cryptique.enableAutoEvents()). Examples of implemented names:
EventTrigger (summary)
page_viewLoad / route
element_clickAny click
rage_clickRapid repeated clicks on the same element
dead_clickClick with no navigation or DOM change after a short window
page_scrollIncreasing scroll depth
form_submitForm submit
form_validation_errorNative invalid field
form_abandonedStarted a form, left without submit
media_play / media_pauseVideo or audio
text_selectionText highlighted
copy_action / context_menuCopy / right-click
js_error / network_errorErrors (when enabled)
page_performanceCore vitals-style summary after load
exit_intent / page_summaryEngagement / exit aggregates
See Auto-Events for the full catalog, script attributes, and JavaScript API. Custom properties on each event may also include group membership fields merged from set_group / add_group.

Custom Events

Tracked via SDK:
Cryptique.track('swap_completed', {
  input_token: 'ETH',
  output_token: 'USDC',
  amount: 1.5
});

Transaction Events

Generated from indexed smart contracts:
// Auto-generated when transaction detected
{
  "event_name": "contract_interaction",
  "event_category": "transaction",
  "properties": {
    "contract_name": "Swap Router",
    "method_name": "swapExactTokensForTokens",
    "transaction_hash": "0xabc...",
    "chain": "ethereum"
  }
}

Properties

Properties provide context to events. They come in several categories:

Default Properties

Auto-captured on every event:
PropertyDescription
team_idYour Cryptique team
session_idCurrent session
distinct_idUser identifier
website_idSite identifier
event_typeauto, custom, transaction
event_nameName of the event
event_categoryCategory grouping
timestampEvent time (ISO 8601)

Custom Properties

Add your own properties to events:
Cryptique.track('purchase_completed', {
  // Strings
  product_name: 'Premium NFT',
  category: 'art',
  
  // Numbers
  price_usd: 150.00,
  quantity: 1,
  
  // Booleans
  is_first_purchase: true,
  used_discount: false,
  
  // Arrays
  tags: ['rare', 'animated', '1of1'],
  
  // Nested objects
  metadata: {
    collection: 'CryptoPunks',
    token_id: 1234
  }
});

Event-Specific Properties

Auto event payloads vary by event_name. Examples: element_click (abbreviated):
{
  "click_coordinates": { "x": 120, "y": 340 },
  "page_x": 120,
  "page_y": 540,
  "scroll_x": 0,
  "scroll_y": 200,
  "document_height": 3200,
  "document_width": 1280,
  "double_click": false,
  "element_category": "button",
  "element_tag_name": "button",
  "element_id": "btn-swap",
  "element_text": "Swap now"
}
page_scroll:
{
  "scroll_depth": 72,
  "max_scroll_reached": 72,
  "scroll_position": 2100,
  "document_height": 3200
}
Wallet lifecycle is not emitted as a built-in auto-event; track it explicitly with Cryptique.walletAddress() and Cryptique.track('wallet_connected', { ... }) if needed.

Property Data Types

TypeExampleNotes
String"ethereum"Max 255 chars for indexed fields
Number1500.50Integer or decimal
Booleantrue / false
Date"2024-01-15"ISO 8601 date
Datetime"2024-01-15T10:30:00Z"ISO 8601 with time
Array["ETH", "USDC"]Homogeneous type recommended
Object{name: "...", value: 100}Nested properties

Best Practices

Event Naming

Use snake_case with clear action verbs:
// ✅ Good
'swap_completed'
'nft_minted'
'liquidity_added'
'onboarding_step_completed'

// ❌ Avoid
'SwapCompleted'      // PascalCase
'swap-completed'     // kebab-case
'swap'               // Too vague
'user clicked swap'  // Spaces, unclear

Property Naming

// ✅ Good
{
  input_token: 'ETH',
  output_token: 'USDC',
  amount_usd: 1500.00,
  slippage_percent: 0.5
}

// ❌ Avoid
{
  inputToken: 'ETH',      // camelCase
  'Output Token': 'USDC', // Spaces
  amt: 1500.00,           // Abbreviated
  slippage: 0.5           // Missing unit
}

Property Values

// ✅ Good - Consistent, specific
{
  status: 'completed',     // Lowercase enum
  chain: 'ethereum',       // Lowercase
  amount: 1500.50,         // Number for math
  is_whale: true           // Boolean prefix
}

// ❌ Avoid
{
  status: 'COMPLETED',     // Inconsistent case
  chain: 'Ethereum',       // Inconsistent case
  amount: '1500.50',       // String for number
  whale: 'yes'             // String for boolean
}

High-Cardinality Properties

Avoid properties with unlimited unique values:
// ❌ High cardinality - Don't do this
{
  transaction_hash: '0xabc...',  // Unique per event
  user_input: 'arbitrary text',  // Unlimited values
  timestamp_ms: 1705312200000    // Use timestamp field
}

// ✅ Better - Category or bucket
{
  transaction_status: 'confirmed',  // Limited values
  input_length: 'medium',           // Bucketed
  // Use built-in timestamp instead
}

Limits

LimitValue
Event name length255 characters
Property name length255 characters
String property value8,192 characters
Properties per event255
Array items255
Object nesting depth5 levels

Next Steps

Track Events

Learn the track() method

Auto-Events

Automatic event names and configuration

Groups

Group keys, membership, and enrichment

Default Properties

Full property reference