Prerequisites
Before you begin, make sure you have:- A Tinybird account and workspace
- Node.js 22 or higher installed
- Git installed on your machine
analytics_events datasource to store your web eventsdashboard (for reading data) and tracker (for sending events)The deployment process creates all necessary resources including datasources, pipes, materializations, and endpoints defined in the
/tinybird/src directory.You can find these tokens in your Tinybird dashboard under Manage Auth Tokens.
Keep your tokens secure! The tracker token will be public (embedded in your website), while the dashboard token should remain private.
Add the following script within your website’s
<head> section, replacing YOUR_TRACKER_TOKEN with your actual tracker token:<script
defer
src="https://unpkg.com/@tinybirdco/flock.js"
data-token="YOUR_TRACKER_TOKEN"
></script>
Once the script is loaded, you’ll automatically start receiving
page_hit events as visitors view and interact with your website.The
defer attribute ensures the script doesn’t block page rendering, improving your site’s performance.<script
defer
src="https://unpkg.com/@tinybirdco/flock.js"
data-token="YOUR_TRACKER_TOKEN"
data-host="https://api.tinybird.co"
data-domain="example.com"
data-tenant-id="my-tenant"
web-vitals="true"
></script>
data-tokendata-hosthttps://api.tinybird.co/data-domaindata-tenant-idweb-vitals"true" to track Core Web Vitals metricsdata-datasourcedata-proxyVisit https://analytics.tinybird.live and enter your dashboard token to access your analytics immediately.
# Tinybird Configuration (server-only, required)
TINYBIRD_TOKEN=your-dashboard-token
TINYBIRD_HOST=https://api.tinybird.co
# Dashboard URL (public)
NEXT_PUBLIC_TINYBIRD_DASHBOARD_URL=http://localhost:3000
# Tracker token for analytics (public, optional)
NEXT_PUBLIC_TINYBIRD_TRACKER_TOKEN=your-tracker-token
# Dashboard Basic Auth (server-only, defaults to admin/admin if not set)
DASHBOARD_USERNAME=admin
DASHBOARD_PASSWORD=changeme
# Optional: Set to "true" to disable auth during development
DISABLE_AUTH=false
Open http://localhost:3000 to view your analytics dashboard.
Track custom events
Beyond automatic page views, you can track custom events for eCommerce, conversions, or any user interaction:payload column of the analytics_events datasource and can be queried through the Tinybird API.
Track Web Vitals
Monitor Core Web Vitals (LCP, FCP, TTFB, INP, CLS) by enabling theweb-vitals parameter:
Next steps
Multi-tenancy
Set up multi-tenant tracking for SaaS applications
Custom attributes
Add custom data attributes to every event
GDPR compliance
Implement privacy-first analytics with proxy tracking
API reference
Query your analytics data programmatically
Verify your setup
To confirm everything is working:- Visit a page on your website with the tracking script installed
- Open your dashboard (hosted or local)
- Check the Current Visitors widget for real-time data
- Navigate through the dashboard to see page views, traffic sources, and device breakdowns
Troubleshooting
Events not appearing in dashboard
Events not appearing in dashboard
- Verify your tracker token is correct in the script tag
- Check the browser console for any errors
- Ensure the script is loaded (check Network tab in DevTools)
- Confirm your dashboard token has read access to the endpoints
Deployment fails
Deployment fails
- Ensure you’re logged in with
npx tinybird login - Check that your admin token has deployment permissions
- Verify Node.js version is 22 or higher
- Try running
pnpm installagain to ensure dependencies are installed
Dashboard authentication issues
Dashboard authentication issues
- Default credentials are
admin/admin - Set custom credentials in
.env.localusingDASHBOARD_USERNAMEandDASHBOARD_PASSWORD - For local development, you can disable auth with
DISABLE_AUTH=true
Need more help? Join the Tinybird Community Slack or check the Tinybird Documentation.