---
url: /reference/items/Track.md
---
# Track
The `Track` components provide declarative analytics tracking, defined entirely in HTML/Twig/Liquid attributes — no custom JavaScript required. A provider-agnostic core (`AbstractTrack`) is shipped as two ready-to-use variants selected by component name:
* **`Track`** pushes the resolved payload to `window.dataLayer` (GTM / GA4).
* **`TrackShopify`** publishes it through `window.Shopify.analytics.publish`.
`TrackContext` lets you factor shared data out of individual events and inherit it from ancestors.
## Usage
Register the components you need in your application:
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Track, TrackShopify, TrackContext } from '@studiometa/ui';
registerComponent(Track);
registerComponent(TrackShopify);
registerComponent(TrackContext);
```
Then declare what to track with `data-track:` attributes. The value can be a bare event name (`data-track:click="add_to_cart"`) or, when an event needs its own structured data, a JSON payload whose `event` key holds the name. Data shared by every event on the element can be provided through a `