External Page Tracker
The External Page Tracker is a lightweight JavaScript snippet that connects your external pages to the TagadaPay funnel system. It enables accurate analytics (device, browser, OS), session tracking, and funnel navigation on pages not hosted on TagadaPay.This is essential for WooCommerce stores, WordPress sites, custom landing pages, or any external page that is part of your funnel.
Without the tracker, analytics data will be inaccurate (e.g., showing the server’s User-Agent instead of the visitor’s browser).
Why You Need This
When a funnel includes steps hosted outside TagadaPay (e.g., your WooCommerce store), the TagadaPay platform has no visibility into what happens on those pages. The External Page Tracker solves this by:- Creating a session — authenticates the visitor and creates an anonymous token
- Tracking page views — records which funnel step the visitor is on
- Capturing real device data — sends the actual browser User-Agent, screen size, and device info (instead of a server-side PHP User-Agent)
- Enabling funnel navigation — allows the visitor to move to the next step via JavaScript
- Preserving identity — maintains the same customer identity across TagadaPay-hosted and external pages
Quick Start
Option 1: CDN (recommended for most sites)
Add this before the closing</body> tag on your external page:
Option 2: NPM Package
Configuration
Required Parameters
| Parameter | Type | Description |
|---|---|---|
storeId | string | Your TagadaPay store ID (e.g., store_019dd15cdb5b) |
accountId | string | Your TagadaPay account ID (e.g., acc_4ff19578aaa2) |
stepId | string | The funnel step ID this page represents (e.g., step_abc123) |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
funnelId | string | Auto-detected from URL | Funnel ID (if not in URL params) |
stepName | string | — | Human-readable step name for analytics |
stepType | string | — | Step categorization (landing, offer) |
apiBaseUrl | string | https://app.tagadapay.com | API base URL (only change for self-hosted or local dev) |
debug | boolean | false | Enable verbose console logging |
Callbacks
| Callback | Signature | Description |
|---|---|---|
onReady | (session: ExternalTrackerSession) => void | Called when the tracker is fully initialized |
onError | (error: Error) => void | Called on failure — when provided, init() will not throw |
API Reference
TagadaTracker.init(config)
Initialize the tracker. Must be called once per page load. Returns a Promise<ExternalTrackerSession | null>.
TagadaTracker.navigate(options)
Navigate to the next funnel step. By default, this redirects the browser automatically.
| Option | Type | Default | Description |
|---|---|---|---|
eventType | string | — | Event type (e.g., form.submitted) |
eventData | object | {} | Arbitrary event data |
autoRedirect | boolean | true | Auto-redirect to the next step URL |
returnUrl | string | — | Override the redirect URL |
TagadaTracker.trackEvent(options)
Track a custom event for analytics without navigating. Non-blocking — errors are silently swallowed.
TagadaTracker.buildUrl(baseUrl, params?)
Build a URL that preserves funnel session context. Use this when linking to other external pages within the same funnel.
TagadaTracker.reset(newStepId)
Reset the tracker to a different step without re-creating the session. Useful for single-page applications.
TagadaTracker.destroy()
Clean up the tracker, remove event listeners, and clear state. Call this when the tracker is no longer needed.
Utility Methods
| Method | Returns | Description |
|---|---|---|
isReady() | boolean | Whether the tracker is initialized |
getSession() | ExternalTrackerSession|null | Current session data |
getCustomerId() | string|null | Customer ID |
getFunnelSessionId() | string|null | Funnel session ID |
getClient() | TagadaClient|null | Underlying SDK client (advanced) |
version | string | Tracker version (e.g., 1.0.0) |
Examples
WooCommerce / WordPress
If you’re using the TagadaPay WooCommerce plugin, the tracker is injected automatically. No manual setup needed. For manual integration, add the tracker to your theme’sfooter.php:
Landing Page with CTA Button
Lead Capture Form
Single Page App (React)
How It Works Internally
init()is called — validates config, creates an anonymous session token viaPOST /api/v1/cms/session/anonymous- Session initialized — sends device/browser data via
POST /api/v1/cms/session/v2/init - Funnel registered — tells the orchestrator which step the visitor is on via
POST /api/v1/funnel/initialize onReadyfires — session is ready, page view is trackednavigate()called — sends navigation event, orchestrator determines the next step URL, browser redirects
Troubleshooting
Console shows 'storeId is required'
Console shows 'storeId is required'
Make sure you’re passing a valid
storeId string. Check the TagadaPay dashboard for your store ID.Console shows 'accountId is required'
Console shows 'accountId is required'
The
accountId parameter is required since v1.0.0. Find it in your TagadaPay dashboard under Settings → Account.Analytics show wrong OS (e.g., 'PHP/8.2')
Analytics show wrong OS (e.g., 'PHP/8.2')
This means session initialization is happening server-side (PHP) instead of client-side. Make sure the External Page Tracker script is loaded in the browser, not called from PHP.
Tracker shows 'No plugin config found - using defaults'
Tracker shows 'No plugin config found - using defaults'
The tracker bundle may be outdated. Make sure you’re using the latest version from the CDN. Clear your browser cache or add a version query parameter:
?v=1.0.0.Duplicate /api/v1/funnel/initialize calls
Duplicate /api/v1/funnel/initialize calls
Make sure you’re using the latest tracker version (1.0.0+). Older versions had a bug where both the tracker and the SDK client would independently initialize the funnel.
