Documentation

Integration Guide

Track where your trial users drop off and what drives conversions. This guide walks you through the complete integration.

1. Overview

Prexel tracks your trial-to-paid conversion funnel by monitoring four key events in your users' journey. We analyze this data to tell you why users don't convert and what to fix first.

The integration is simple: you send us events via a POST request whenever something important happens. We handle the analysis and show you insights on your dashboard.

What we measure:

  • Activation Rate — What percentage of signups experience value?
  • Conversion Rate — What percentage of trials become paid?
  • Time to Value — How quickly do users reach their "aha moment"?

2. The Four Events

You only need to track four events. Each represents a key moment in the trial user's journey.

signup

Send when a user creates an account and starts their trial. This marks the beginning of their journey.

Trigger: After successful registration

activation

Send when the user completes your defined "aha moment" — the action that makes them realize the value of your product. You define this during setup.

Trigger: When user experiences core value

Examples: Created first project, sent first email, invited teammate, completed onboarding

upgrade

Send when a user converts to a paid plan. This is your success event.

Trigger: After successful payment (e.g., in Stripe webhook)

trial_expired

Send when a trial ends without the user upgrading. This helps calculate your conversion rate accurately.

Trigger: Via daily cron job checking trial end dates

3. Getting Started

  1. Create an account

    Sign up at Prexel using Google or email/password.

  2. Define your activation event

    Choose what action represents your "aha moment" — when users experience real value.

  3. Get your API key

    Go to Settings in your dashboard and copy your project API key.

  4. Store it as an environment variable

    Add it to your .env file as PREXEL_API_KEY. Never expose it in client-side code.

4. Adding Tracking

API Endpoint

POST https://your-prexel-url.com/api/events

Headers:
  Content-Type: application/json
  X-API-Key: YOUR_API_KEY

Body:
{
  "event_type": "signup",        // signup, activation, upgrade, trial_expired
  "trial_user_id": "user_123",   // Your database user ID
  "metadata": {}                 // Optional
}

Important: User ID Consistency

The trial_user_id must be the same across all events for each user. Use your database user ID, not random values. If the ID changes between events, we can't link the user's journey.

5. Code Examples

Helper Function

Add this to your project and call it whenever you need to track an event:

// lib/prexel.js

const PREXEL_API_KEY = process.env.PREXEL_API_KEY;
const PREXEL_URL = 'https://your-prexel-url.com/api/events';

export async function trackEvent(eventType, userId, metadata = {}) {
    try {
        const response = await fetch(PREXEL_URL, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'X-API-Key': PREXEL_API_KEY
            },
            body: JSON.stringify({
                event_type: eventType,
                trial_user_id: userId,
                metadata
            })
        });
        return response.ok;
    } catch (error) {
        console.error('Prexel error:', error);
        return false;
    }
}

Usage Examples

In your signup handler:

import { trackEvent } from './lib/prexel';

async function handleSignup(email, password) {
    const user = await createUser(email, password);
    await trackEvent('signup', user.id);
    return user;
}

When user activates:

// Example: first project created
async function createProject(userId, data) {
    const project = await db.projects.create(data);
    const count = await db.projects.count({ userId });
    
    if (count === 1) {
        await trackEvent('activation', userId);
    }
    return project;
}

In your payment webhook:

// Stripe webhook example
if (event.type === 'checkout.session.completed') {
    const userId = session.client_reference_id;
    await trackEvent('upgrade', userId);
}

Daily cron for expired trials:

async function checkExpiredTrials() {
    const expired = await db.users.findMany({
        where: { trialEndsAt: { lt: new Date() }, plan: 'trial' }
    });
    
    for (const user of expired) {
        await trackEvent('trial_expired', user.id);
    }
}

6. Troubleshooting

Events not appearing

  • • Check that your API key is correct
  • • Ensure you're using the X-API-Key header
  • • Verify the event_type is one of: signup, activation, trial_expired, upgrade

Invalid API key error

  • • Copy the API key again from Settings
  • • Check for extra whitespace
  • • If you regenerated it, update your environment variables

Metrics not showing

  • • You need at least 10 signup events
  • • Click Refresh on the dashboard to trigger computation

Ready to get started?

Create your account and start tracking trial conversions.

Create Account