Analytics
Raven Client includes built-in analytics tracking for CTAs and user interactions.
Overview
The SDK automatically tracks:
- CTA processing events
- State machine transitions
- Action executions
- User interactions
- Error events
Event Types
CTA Processing Events
NudgeCtaProcessingStart: CTA processing startedNudgeCtaStateTransition: State machine transition occurredNudgeCtaStateTransitionAction: Action executedNudgeCtaStateMachineReset: State machine resetNudgeCtaInValid: CTA validation failedNudgeCtaEventProcessingFailed: Event processing failed
Template Events
NudgeCtaTemplateFetch: CTA template fetched
Sending Events
Automatic Events
The SDK automatically sends analytics events. Configure the appEvent listener:
ravenClient.init({
listeners: {
appEvent: (eventName, props) => {
// Send to your analytics service
yourAnalyticsService.track(eventName, props)
},
// ...
},
})
Manual Events
Send custom analytics events:
import {sendNudgeAppEvent} from '@dreamhorizonorg/raven-client'
sendNudgeAppEvent('BUTTON_CLICKED', {
buttonId: 'signup',
timestamp: Date.now(),
})
Event Properties
Events include contextual information:
{
appEventName: string; // Original app event name
ctaId: string; // CTA ID
stateMachineId: string; // State machine ID
currentState: string; // Current state
prevState?: string; // Previous state
nudgeShownCount: number; // Number of times shown
ctaValidTill?: number; // CTA expiration
reason?: string; // Failure reason (if applicable)
errorMessage?: string; // Error message (if applicable)
}