/** * TagadaPay External Page Tracker * * Standalone script for tracking users on external pages that are part of a * TagadaPay funnel but not hosted on the TagadaPay platform. * * Use cases: * - WooCommerce / WordPress storefronts * - Custom landing pages * - Any external page that is a funnel step * * @example CDN usage * ```html * * * ``` */ import type { TagadaClient } from '../core/client'; export declare const TRACKER_VERSION = "1.0.0"; export interface TagadaTrackerConfig { /** Store ID (required) */ storeId: string; /** Account ID (required — session init will fail without it) */ accountId: string; /** Funnel ID (optional — can be extracted from URL param) */ funnelId?: string; /** Step ID (required for external pages — URL-to-step mapping only works for TagadaPay-hosted pages) */ stepId: string; /** Step name (optional — for analytics/debugging) */ stepName?: string; /** Step type (optional — e.g., 'landing', 'offer', 'external') */ stepType?: string; /** API base URL (defaults to https://api.tagada.io) */ apiBaseUrl?: string; /** Enable debug logging */ debug?: boolean; /** Callback when session is ready */ onReady?: (session: ExternalTrackerSession) => void; /** Callback on error — when provided, init() will NOT throw */ onError?: (error: Error) => void; } export interface ExternalTrackerSession { sessionId: string; customerId: string; storeId: string; funnelId?: string; currentStepId?: string; cmsToken?: string; } export interface NavigateOptions { /** Event type for navigation (e.g., 'offer.accepted', 'form.submitted') */ eventType: string; /** Event data */ eventData?: Record; /** Override return URL */ returnUrl?: string; /** Whether to auto-redirect after navigation (default: true) */ autoRedirect?: boolean; } export interface TrackEventOptions { /** Event name (e.g., 'button_click', 'scroll_depth', 'video_play') */ name: string; /** Arbitrary event data */ data?: Record; } declare class TagadaExternalTracker { private config; private client; private initialized; private initializing; private unsubscribe; /** Tracker version */ readonly version = "1.0.0"; /** * Initialize the tracker. * When `onError` is provided, errors are passed to the callback and init() * resolves to `null` instead of throwing. */ init(config: TagadaTrackerConfig): Promise; /** Get current session data. */ getSession(): ExternalTrackerSession | null; /** Whether the tracker is fully initialized and ready. */ isReady(): boolean; /** * Navigate to the next step in the funnel. * By default, auto-redirects the browser window. */ navigate(options: NavigateOptions): Promise<{ url: string; } | null>; /** * Track a custom event (e.g., button click, scroll depth, video play). * Events are sent through the funnel orchestrator for unified analytics. */ trackEvent(options: TrackEventOptions): Promise; /** Get customer ID. */ getCustomerId(): string | null; /** Get funnel session ID. */ getFunnelSessionId(): string | null; /** * Build a URL that preserves funnel session context. * Use this to link to other external pages within the same funnel. */ buildUrl(baseUrl: string, additionalParams?: Record): string; /** Get the underlying SDK client (advanced usage). */ getClient(): TagadaClient | null; /** * Reset the tracker to a new step without re-creating the session. * Useful for SPAs that navigate between funnel steps client-side. */ reset(newStepId: string): Promise; /** * Destroy the tracker, clean up event listeners and state. * Call this when the tracker is no longer needed (e.g., SPA teardown). */ destroy(): void; private waitForClientReady; private initializeFunnel; } declare const TagadaTracker: TagadaExternalTracker; export { TagadaTracker, TagadaExternalTracker };