Track your website with DATALYR and see which channel, campaign and ad drove every conversion.
- Attribution. Click IDs, UTMs and ad cookies are captured on landing and kept with the visitor.
- One customer, every visit. Anonymous visits join the signed-in user when you call
identify(). - Better ad signal. Conversions reach your ad platforms with the data they need to optimize.
- Privacy built in. Consent, Global Privacy Control and opt-out are respected.
Use one of these two options. If you load both, one visitor gets two visitor_id values.
Script tag (no build step):
<script defer src="https://track.datalyr.com/dl.js"
data-workspace-id="YOUR_WORKSPACE_ID"></script>npm:
npm install @datalyr/webFind your workspace ID in DATALYR under Settings → Tracking → Install.
import datalyr from '@datalyr/web';
datalyr.init({ workspaceId: 'YOUR_WORKSPACE_ID' });
// Page views are tracked for you, including SPA route changes.
// Track an action
datalyr.track('signup_started', { plan: 'pro' });
// Tie the visitor to your user after sign-in
datalyr.identify('user_123', { email: 'user@example.com' });
// Record a conversion with its value
datalyr.track('purchase', { value: 49.0, currency: 'USD' });
// On logout only
datalyr.reset();With the script tag, the SDK calls init() for you. The same methods are on window.datalyr.
- Open your site in a private window.
- In DATALYR, open Events.
- Confirm that a
pageviewwith your URL arrives within 30 seconds.
If no event arrives, add debug: true to init(). Then read the browser console.
Your AI agent can install the SDK for you. Connect the agent to the DATALYR MCP server at https://mcp.datalyr.com/mcp. Then ask it to install tracking. See DATALYR MCP.
- Web SDK reference: every method, option and event
- Changelog
- Other SDKs: React Native · iOS (Swift) · Node
- Bugs and feature requests: open an issue
- Security reports: see SECURITY.md
- Other questions: datalyr.com
MIT. See LICENSE.