umami
Product
DocsDevelopersPricing
16.8kLog inSign up
General
About
FAQ
Useful links
Getting started
Getting started
Install
Login
Add a website
Collect data
Basics
Add a user
Enable share URL
Track events
Teams
Updates
Languages
Advanced
Tracker configuration
Tracker functions
Environment variables
Reference
API
Authentication
Users
Teams
Websites
Website stats
Sending stats
Event Data
API Client
Cloud
Overview
API key
Import data
Guides
Migrating v1 to v2
Hosting
Running on DigitalOcean
Running on Vercel
Running on Neon Postgres
Running on Netlify
Running on Heroku
Running on Railway
Running on Supabase
Running on PlanetScale
Running on Qovery
Running on CapRover
Running on Koyeb
Running on Forge
Running on Fly.io
umami
Product
FeaturesPricing
Resources
DocsGuidesAPI ReferenceRelease Notes
Community
Get InvolvedGitHubDiscordTwitter
Company
AboutContactPrivacyTerms
© 2023 Umami Software, Inc.

Tracker functions

The Umami tracker exposes a function that you can call on your website if you want more control over your tracking. By default everything is automatically collected, but you can disable this using data-auto-track="false" and sending the data yourself. See Tracker configuration.

Functions

umami.track([payload]);
 
umami.track(event_name, [event_data]);

Pageviews

Tracks a page view.

umami.track();

By default the tracker automatically collects the following properties:

  • hostname: Hostname of server
  • language: Browser language
  • referrer: Page referrer
  • screen: Screen dimensions (eg. 1920x1080)
  • title: Page title
  • url: Page url
  • website: Website ID (required)

If you wish to send your own custom payload, pass in an object to the function:

umami.track({ website: 'e676c9b4-11e4-4ef1-a4d7-87001773e9f2', url: '/home', title: 'Home page' });

The above will only send the properties website, url and title. If you want to include existing properties, pass in a function:

umami.track(props => ({ ...props, url: '/home', title: 'Home page' }));

Events

Tracks an event with a given name.

umami.track('signup-button');

Event Data

Tracks an event with dynamic data.

umami.track('signup-button', { name: 'newsletter', id: 123 });

When tracking events, the default properties are included in the payload. This is equivalent to running:

umami.track(props => ({
  ...props,
  name: 'signup-button',
  data: {
    name: 'newsletter',
    id: 123,
  },
}));

Event Data Limits

Event Data can work with any JSON data. There are a few rules in place to maintain performance.

  • Numbers have a max precision of 4.
  • Strings have a max length of 500.
  • Arrays are converted to a String, with the same max length of 500.
  • Objects have a max of 50 properties. Arrays are considered 1 property.