APiGen Analytics
Multi-provider analytics platform with event tracking, user analytics, conversion funnels, retention cohorts, user journey mapping, and A/B testing.
🎯 Features
- 5 Analytics Providers: Google Analytics 4, Mixpanel, Amplitude, Segment, PostHog
- Event Tracking: Rich event context with device, geo, and page data
- User Management: Identification, properties, aliases, cross-device tracking
- Conversion Funnels: Multi-step funnel analysis with drop-off tracking
- Retention Cohorts: User retention and lifetime value (LTV) analysis
- User Journeys: Track user progression through application stages
- A/B Testing: Feature flags and multivariate testing (PostHog)
- Batch Processing: Efficient multi-event submission
- Resilience: Circuit breakers, retries, health monitoring
- Multi-Tenant: Track events across different providers simultaneously
🚀 Quick Start
1. Configuration
yaml
apigen:
analytics:
enabled: true
# Tracking settings
tracking:
batchSize: 100
flushInterval: 10s
timeout: 30s
persistEvents: true
# Google Analytics 4
googleAnalytics:
enabled: true
measurementId: "G-XXXXXXXXXX"
apiSecret: "${GA4_API_SECRET}"
# Mixpanel
mixpanel:
enabled: true
projectToken: "${MIXPANEL_TOKEN}"
apiSecret: "${MIXPANEL_SECRET}"
# Amplitude
amplitude:
enabled: true
apiKey: "${AMPLITUDE_API_KEY}"
# Segment (CDP)
segment:
enabled: true
writeKey: "${SEGMENT_WRITE_KEY}"
# PostHog (A/B Testing & Feature Flags)
posthog:
enabled: true
apiKey: "${POSTHOG_API_KEY}"
host: "https://app.posthog.com"🏗️ Architecture
Multi-Provider Pattern
All analytics events are sent to all enabled providers simultaneously:
Provider Features
| Feature | GA4 | Mixpanel | Amplitude | Segment | PostHog |
|---|---|---|---|---|---|
| Event Tracking | ✅ | ✅ | ✅ | ✅ | ✅ |
| User Properties | ✅ | ✅ | ✅ | ✅ | ✅ |
| Batch Tracking | ✅ | ✅ | ✅ | ✅ | ✅ |
| User Aliases | ❌ | ✅ | ✅ | ✅ | ✅ |
| A/B Testing | ❌ | ❌ | ❌ | ❌ | ✅ |
| Feature Flags | ❌ | ❌ | ❌ | ❌ | ✅ |
| Health Checks | ✅ | ✅ | ✅ | ✅ | ✅ |
📊 Core Features
Event Tracking
Single Event
java
CompletableFuture<TrackingResult> result = analyticsService.track(
AnalyticsEvent.builder()
.eventName("Button Clicked")
.userId("user_123")
.category("engagement")
.properties(Map.of("button", "signup", "page", "/landing"))
.build()
);User Journeys
Start Journey
java
userJourneyService.startJourney(
"user_123",
"Onboarding Journey",
"Google", // acquisition source
"CPC", // acquisition medium
"summer_campaign" // acquisition campaign
);Advance Through Stages
java
userJourneyService.advanceStage(journeyId, "Profile Created");
userJourneyService.advanceStage(journeyId, "First Purchase");
userJourneyService.advanceStage(journeyId, "Power User");