Quick Start
The Tinybird web analytics tracker (@tinybirdco/flock.js) is a lightweight JavaScript library that tracks page views, custom events, and web vitals on your website.Script Installation
Add the following script tag within your site’s<head> section:
Get your
tracker token from Tinybird Cloud under “Manage Auth Tokens”.Verification
Once the script is installed, you should immediately start receivingpage_hit events as visitors view and interact with your website. You can verify this in your Tinybird workspace by checking the analytics_events data source.
Configuration Parameters
The tracker script supports several configuration parameters that can be added as data attributes to the script tag.Required Parameters
Your Tinybird tracker token. Find it in the Tinybird UI under “Manage Auth Tokens”.
Optional Parameters
Tinybird host URL. Defaults to
https://api.tinybird.co/.Use this if you’re on a different region or a dedicated cluster:- US East:
https://api.us-east.tinybird.co - EU:
https://api.tinybird.co(default)
Override the default landing data source name. Defaults to
analytics_events.Use this if you’ve customized your data source or want to ingest events into a different one.Your domain URL to proxy tracking requests. Cannot be used together with
data-proxy-url.The tracker will automatically append /api/tracking to the domain.A complete proxy URL endpoint for tracking requests. Cannot be used together with
data-proxy.Use this when you need to specify a custom tracking endpoint beyond just the domain.Enable Web Vitals tracking. Set to See Web Vitals for more details.
true to track Core Web Vitals metrics.Storage method for session management. Options:
cookie, localStorage, sessionStorage.Whether to stringify the payload. Set to
false to send the payload as an object.Multi-tenancy and Multi-domain
The tracker supports collecting data from multiple tenants and domains in a single data source.Domain identifier for multi-domain tracking.
Tenant identifier for multi-tenancy support.
Filtering by Tenant
All endpoints can be filtered bytenant_id and domain. You can also use JWT tokens with fixed params:
Complete Example
Here’s a full example with multiple configuration options:Next Steps
Page Views
Learn how page view tracking works
Custom Events
Track custom events on your website
Web Vitals
Monitor Core Web Vitals metrics
Configuration
Advanced configuration options