← Integrations
Analytics
Seshn + Segment
Pipe every booking event to Segment. From there, fan out to Mixpanel, Amplitude, BigQuery, your data warehouse — or all of them at once.
Install
1npm install @segment/analytics-nodeWhy Segment
One integration, 300+ destinations. Instead of wiring each analytics tool individually, send Seshn events to Segment and route them to wherever they need to go — analytics, marketing, data warehouse, CRM.
Webhook handler
Forward all Seshn webhook events to Segment as track calls.
app/api/webhooks/seshn/route.ts
1import { Analytics } from '@segment/analytics-node';2import { createHmac } from 'crypto';34const analytics = new Analytics({5 writeKey: process.env.SEGMENT_WRITE_KEY!,6});7const WEBHOOK_SECRET = process.env.SESHN_WEBHOOK_SECRET!;89export async function POST(req: Request) {10 const body = await req.text();11 const signature = req.headers.get('x-webhook-signature');1213 const expected = 'sha256=' +14 createHmac('sha256', WEBHOOK_SECRET).update(body).digest('hex');1516 if (signature !== expected) {17 return new Response('Invalid signature', { status: 401 });18 }1920 const event = req.headers.get('x-webhook-event')!;21 const payload = JSON.parse(body);2223 // Map Seshn contact to Segment user24 const userId = payload.contact?.id ?? payload.contactId ?? 'anonymous';2526 // Forward every Seshn event as a Segment track call27 analytics.track({28 userId,29 event: `Seshn ${event}`,30 properties: {31 bookingId: payload.id,32 serviceId: payload.serviceId ?? payload.service?.id,33 serviceName: payload.service?.name,34 seats: payload.seats,35 amount: payload.amount ?? payload.payment?.amount,36 currency: payload.currency ?? payload.payment?.currency,37 slotStartTime: payload.slot?.startTime,38 locationId: payload.locationId ?? payload.location?.id,39 // Include the raw event type for downstream filtering40 seshnEvent: event,41 },42 timestamp: new Date(),43 });4445 // Identify the user if we have contact details46 if (payload.contact) {47 analytics.identify({48 userId: payload.contact.id,49 traits: {50 name: payload.contact.name,51 email: payload.contact.email,52 phone: payload.contact.phone,53 },54 });55 }5657 return new Response('OK', { status: 200 });58}Register the webhook
Subscribe to all events so your analytics pipeline has the full picture:
terminal
1curl -X POST https://api.seshn.net/v1/webhooks \2 -H "Authorization: Bearer sk_live_..." \3 -H "Content-Type: application/json" \4 -d '{5 "url": "https://yourdomain.com/api/webhooks/seshn",6 "events": [7 "booking.created",8 "booking.confirmed",9 "booking.cancelled",10 "booking.rescheduled",11 "booking.checked_in",12 "booking.hold_expired",13 "booking.series_created",14 "booking.series_cancelled",15 "payment.succeeded",16 "payment.failed",17 "payment.refunded",18 "entitlement.issued",19 "entitlement.expired",20 "waitlist.joined",21 "waitlist.promoted",22 "waitlist.expired"23 ]24 }'Example funnel
With all events flowing to Segment, you can build a booking conversion funnel in any analytics tool:
1
Seshn booking.created2
Seshn payment.succeeded3
Seshn booking.confirmed4
Seshn booking.checked_inNext steps
- Enable Segment destinations like Mixpanel, Amplitude, or BigQuery to start analyzing immediately.
- Use Segment Protocols to define a tracking plan and validate Seshn events against your schema.
- Build a "booking health" dashboard tracking creation-to-checkin conversion rates.