Getting Started with JustAnalytics: A Complete Setup Guide
A step-by-step guide to setting up JustAnalytics for frontend analytics, error tracking, server-side tracing, and uptime monitoring. From zero to full observability in 15 minutes.
Prerequisites
Before you begin, make sure you have:
- A JustAnalytics account (sign up free)
- At least one site created in your dashboard
- Your Site ID (found in Dashboard > Sites > Settings)
- For server-side features: an API key (Dashboard > Settings > API Keys)
Step 1: Frontend Analytics
Add the tracking script to your HTML. It's under 5KB, loads asynchronously, and has zero impact on your Core Web Vitals.
<script
defer
src="https://justanalytics.app/tracker.js"
data-site-id="YOUR_SITE_ID"
/>
What Gets Tracked Automatically
Once installed, JustAnalytics automatically captures:
- Pageviews with URL, referrer, and UTM parameters
- Sessions using cookieless heuristics (no consent banner needed)
- Device data -- browser, OS, screen size, viewport
- Geographic location from anonymized IP geolocation
- Traffic sources -- direct, referral, search, social, campaign
- Custom events via the
justanalytics.track()API
Tracking Custom Events
// Track a button click
justanalytics.track('cta_click', {
button: 'hero-signup',
variant: 'blue',
});
// Track a purchase
justanalytics.track('purchase', {
plan: 'pro',
amount: 49,
currency: 'USD',
});
Step 2: Error Tracking and Session Replay
Add the monitoring script alongside the tracker for error tracking, performance monitoring, and session replay:
<script
defer
src="https://justanalytics.app/monitor.js"
data-site-id="YOUR_SITE_ID"
data-capture-console="true"
data-capture-network="true"
data-capture-clicks="true"
data-live-stream="true"
data-capture-dom="true"
data-environment="production"
data-release="1.0.0"
/>
Configuration Options
| Attribute | Default | Description |
|---|---|---|
data-capture-console | false | Capture console.log/warn/error |
data-capture-network | false | Capture fetch/XHR requests |
data-capture-clicks | false | Capture click events with selectors |
data-capture-dom | false | Enable DOM mutation recording for replay |
data-live-stream | false | Enable live event streaming |
data-environment | production | Environment tag for filtering |
data-release | - | Release version for regression detection |
Step 3: Server-Side Instrumentation
Install the Node.js SDK for server-side tracing, error tracking, and log collection:
npm install @justanalyticsapp/node
Initialize Early
The SDK should be initialized before any other imports in your application entry point:
// server.ts or app.ts -- must be the first import
import { init } from '@justanalyticsapp/node';
init({
apiKey: process.env.JUSTANALYTICS_API_KEY!,
serviceName: 'my-api-server',
environment: process.env.NODE_ENV,
autoInstrument: {
http: true, // Auto-trace HTTP requests
postgres: true, // Auto-trace database queries
redis: true, // Auto-trace Redis operations
},
});
// Now import your application
import './app';
Manual Spans
For custom business logic tracing:
import { trace } from '@justanalyticsapp/node';
async function processOrder(orderId: string) {
return trace.startSpan('process-order', async (span) => {
span.setAttribute('order.id', orderId);
const order = await fetchOrder(orderId);
span.setAttribute('order.total', order.total);
await chargePayment(order);
await sendConfirmation(order);
return order;
});
}
Structured Logging
The SDK integrates with your existing logger or provides its own:
import { logger } from '@justanalyticsapp/node';
logger.info('Order processed', {
orderId: '12345',
total: 99.99,
items: 3,
});
logger.error('Payment failed', {
orderId: '12345',
error: 'Card declined',
gateway: 'stripe',
});
Logs are automatically correlated with the active trace and span.
Step 4: Uptime Monitoring
Set up uptime monitors from the dashboard:
- Navigate to Dashboard > Monitoring > Uptime
- Click Create Monitor
- Enter the URL to monitor (e.g.,
https://api.yoursite.com/health) - Configure check interval (1, 5, 10, or 30 minutes)
- Select check regions (US East, US West, EU West, AP Southeast)
- Set alert thresholds
Monitor Types
- HTTP/HTTPS -- check response status codes and latency
- TCP -- verify port connectivity
- Keyword -- check that response body contains expected content
Step 5: Set Up Alerts
Configure alert rules to get notified when things go wrong:
- Navigate to Dashboard > Monitoring > Alerts
- Click Create Rule
- Choose a metric (error rate, latency p95, uptime, etc.)
- Set threshold and duration
- Select notification channels (email, push)
Example Alert Rules
- Error spike: Error rate > 5% for 5 minutes
- Slow responses: p95 latency > 2000ms for 10 minutes
- Downtime: Any uptime monitor fails for 2 consecutive checks
- Traffic drop: Pageviews drop > 50% compared to same hour yesterday
Step 6: Conversion Tracking
Set up conversion goals to measure business outcomes:
- Navigate to Dashboard > Conversions
- Click Create Goal
- Define the conversion event (e.g.,
purchase,signup) - Optionally set a monetary value
- View conversion rates, funnels, and attribution
Verify Your Setup
After completing setup, verify everything is working:
- Analytics: Visit your site, then check Dashboard > Real-Time. You should see your visit within seconds.
- Errors: Open browser console and run
throw new Error('test'). Check Dashboard > Monitoring > Errors. - Traces: Make an API request. Check Dashboard > Monitoring > Traces for the trace waterfall.
- Uptime: Your first uptime check runs within the configured interval.
Next Steps
- Explore the Trace Explorer to debug slow requests
- Set up conversion funnels to track user journeys
- Review Web Vitals for performance optimization
- Configure user segments for targeted analysis
Need help? Reach out to us at support@justanalytics.app.
Founder of JustAnalytics and CEO of Velocity Digital Labs LLC. Building the future of privacy-first observability.
@rajatpratapsingh