GuidesMarch 12, 20265 min read

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

AttributeDefaultDescription
data-capture-consolefalseCapture console.log/warn/error
data-capture-networkfalseCapture fetch/XHR requests
data-capture-clicksfalseCapture click events with selectors
data-capture-domfalseEnable DOM mutation recording for replay
data-live-streamfalseEnable live event streaming
data-environmentproductionEnvironment 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:

  1. Navigate to Dashboard > Monitoring > Uptime
  2. Click Create Monitor
  3. Enter the URL to monitor (e.g., https://api.yoursite.com/health)
  4. Configure check interval (1, 5, 10, or 30 minutes)
  5. Select check regions (US East, US West, EU West, AP Southeast)
  6. 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:

  1. Navigate to Dashboard > Monitoring > Alerts
  2. Click Create Rule
  3. Choose a metric (error rate, latency p95, uptime, etc.)
  4. Set threshold and duration
  5. 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:

  1. Navigate to Dashboard > Conversions
  2. Click Create Goal
  3. Define the conversion event (e.g., purchase, signup)
  4. Optionally set a monetary value
  5. View conversion rates, funnels, and attribution

Verify Your Setup

After completing setup, verify everything is working:

  1. Analytics: Visit your site, then check Dashboard > Real-Time. You should see your visit within seconds.
  2. Errors: Open browser console and run throw new Error('test'). Check Dashboard > Monitoring > Errors.
  3. Traces: Make an API request. Check Dashboard > Monitoring > Traces for the trace waterfall.
  4. Uptime: Your first uptime check runs within the configured interval.

Next Steps

Need help? Reach out to us at support@justanalytics.app.

RP
Rajat Pratap SinghFounder & CEO

Founder of JustAnalytics and CEO of Velocity Digital Labs LLC. Building the future of privacy-first observability.

@rajatpratapsingh

Related posts