Getting Started with Clayva Analytics
Clayva is a unified analytics platform that brings all your product data together on an infinite canvas. This guide will help you get up and running in minutes.
Installation
Choose your preferred package manager to install the Clayva SDK. We support all major JavaScript environments including Node.js, browsers, and edge runtimes.
npm install @clayva/analytics yarn add @clayva/analytics pnpm add @clayva/analytics <script src="https://cdn.clayva.com/analytics/v1/clayva.min.js"></script> Quick Start
Once installed, you can start tracking events and identifying users immediately. Here's a complete example to get you started:
Configuration
The Clayva SDK offers extensive configuration options to customize its behavior for your specific needs.
API Keys
Your API key is available in the Clayva dashboard. We recommend using environment variables to store sensitive credentials:
// .env
CLAYVA_API_KEY=your_api_key_here
// Your application
const clayva = new Clayva({
apiKey: process.env.CLAYVA_API_KEY
}); Environments
Clayva supports multiple environments to separate your development, staging, and production data:
Core Concepts
Understanding these core concepts will help you make the most of Clayva's powerful analytics platform.
Events
Events are the foundation of analytics in Clayva. Every user interaction, system action, or business metric can be tracked as an event. Events consist of a name and optional properties:
clayva.track('Product Viewed', {
productId: 'SKU-123',
productName: 'Wireless Headphones',
category: 'Electronics',
price: 99.99,
currency: 'USD'
}); Users
Users represent the people using your application. You can identify users and attach properties to build rich user profiles:
clayva.identify('user_123', {
email: 'user@example.com',
plan: 'premium',
company: 'Acme Corp',
role: 'admin'
}); Properties
Properties provide context to your events and users. Clayva automatically captures common properties and allows you to add custom ones:
Best Practices
- Consistent Naming: Use a consistent naming convention for events (e.g., "Product Viewed" not "product_viewed" or "ProductViewed")
- Meaningful Properties: Include properties that will help you answer business questions
- Batch Events: The SDK automatically batches events for optimal performance
- Error Handling: Always handle errors gracefully in production
- Test Thoroughly: Use development environment to test your implementation
Troubleshooting
If you're experiencing issues, here are some common solutions: