Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trodo.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Agentic setup

Install the Trodo AI skill to let your coding agent install Trodo automatically. It detects your frontend framework, backend runtime, and auth provider, then wires Trodo.init, identify, groups, sessions, and a starter custom-event set — using the user identifier your app already keys on.
Point your agent at the skill repository and ask it to install events. Replace YOUR_SITE_ID with the value from app.trodo.ai → Settings → Sites:
Install the Trodo AI skill from https://github.com/trodoai/skills and use it to enable tracking and events to this application, with siteId YOUR_SITE_ID.
The skill works with Cursor, Claude Code, Windsurf, and any other assistant that can read files in your repo or fetch from GitHub. For agent analytics (LLM and tool spans), use the Agent Analytics Quickstart — the same skill repo handles both tracks.
Prefer to do it by hand? The manual instructions below cover every surface.

Overview

Trodo ships three browser install methods (CDN script, Google Tag Manager, npm) and two server SDKs (Node.js, Python). Pick one per surface; you can mix them in the same project against the same Site ID.
Browser vs. server. The browser SDK is stateful — after Trodo.identify(...) the distinct id lives in session/localStorage and every subsequent call uses it automatically. The server SDKs are statelessdistinctId (Node) or distinct_id (Python) is required as the first argument on every call. See Server SDKs below.

Client SDK

Server SDKs

For backend services, background workers, and any environment where you control the runtime, use the Node.js or Python SDK. Both are stateless — you pass the end-user’s distinctId (Node) / distinct_id (Python) as the first argument on every call. The SDK does not maintain an implicit “current user” across calls the way the browser does.
Pass the distinct id on every call. There is no session cookie on the server — if you omit it, Trodo cannot attribute events to a user. If you’re making several calls in a row for the same user, bind once with forUser(distinctId) / for_user(distinct_id) and call methods on the returned context.

Install

npm install trodo-node
Node 16+ (18+ recommended for built-in fetch). TypeScript types ship with the package.

Initialise once at boot

import trodo from 'trodo-node';

trodo.init({
  siteId: process.env.TRODO_SITE_ID,
  autoEvents: true, // capture uncaught exceptions as `server_error`
});
Use the same Site ID as your browser install. Both surfaces feed the same dashboards.

First call

// Direct style — distinct id as first arg
await trodo.track('user-42', 'invoice_paid', { amount_cents: 9999 });

// Bound style — bind once, call many
const user = trodo.forUser('user-42');
await user.track('invoice_paid', { amount_cents: 9999 });
await user.people.set({ plan: 'pro' });

Configuration options

Pass these only when you need to change defaults. Everything below is optional.
OptionNodePythonDefault
Site IDsiteIdsite_idrequired
Server auto-eventsautoEventsauto_eventsfalse
API baseapiBaseapi_basehttps://sdkapi.trodo.ai
Request timeouttimeout (ms)timeout (s)10 s
Retriesretriesretries2 (backoff on network / 5xx)
Batch modebatchEnabledbatch_enabledfalse
Batch sizebatchSizebatch_size50
Flush intervalbatchFlushIntervalMsbatch_flush_interval5000 ms / 5 s
Error callbackonErroron_errornone
Verbose logsdebugdebugfalse

Shutdown

When batching or auto-events are enabled, call flush() / shutdown() on process exit so queued events are not dropped:
process.on('SIGTERM', async () => {
  await trodo.shutdown();
});

Verification

After installation, verify it’s working:

1. Check Browser Console

Open developer tools (F12) and look for:
[Trodo] Initialized successfully
[Trodo] Session started: abc123
[Trodo] Event tracked: page_view

2. Check Live Events

  1. Go to your Trodo dashboard
  2. Navigate to Live Events or Debugger
  3. Perform actions on your site
  4. Events should appear within 60 seconds

3. Network Tab

In browser dev tools → Network tab, look for requests to:
  • api.trodo.ai/events
  • api.trodo.ai/sessions

Troubleshooting

Add these domains to your CSP:
script-src 'self' https://cdn.trodo.ai;
connect-src 'self' https://api.trodo.ai;
  1. Verify Site ID is correct
  2. Check domain is whitelisted in settings
  3. Disable ad blockers temporarily
  4. Check browser console for errors
Ensure the script is only loaded once. If using both CDN and npm, choose one.
The CDN script is ~15KB gzipped. If performance is critical:
  1. Use async loading (default)
  2. Consider npm package for bundling
  3. Load after critical resources

Next Steps

Auto-Events

Configure automatic event tracking

Track Custom Events

Learn the track() method