---
title: trackData
slug: js-api/trackdata
description: Overview of how the trackData method in the Monetate JavaScript API works along with code samples
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-05-20T16:13:32.070Z
---

:::CodeblockTabs
trackData Method

```javascript
// trackData Method
window.monetateQ.push([
 "method",
 "data"
]);
window.monetateQ.push([
 "trackData"
]);
```
:::

The `trackData` method sends all data from the [monetateQ](docId\:Jt7O1LQ8aUTjhFOLknLnV) array asynchronously to Monetate. This method takes no arguments. Place it at the bottom of the page after all other content has been loaded and relevant information has been added to `monetateQ`.

Call this method as many times as necessary to give the most current picture of a customer's experience to the Monetate platform.

:::hint{type="info"}
Each time the `trackData` method is called, the `monetateQ` array is cleared so that new data can be pushed.
:::

The `trackData` method can be used in many instances, such as when a customer views a set of products, filters those products, and is shown a new filtered set. If the site content changes via an AJAX request, the `trackData` method can be called. See [Page Retracks](docId\:z7zs1BulqPT_0Z1CoYHww) for more information.

When you call `trackData` more than once because major elements or content on the site have changed (for example, on a single-page application), you must resend all the data to Monetate, including the page type.

## Monetate Inspector View

This screenshot shows the **Components** tab of the [Monetate Inspector browser plug-in](https://docs.monetate.com/docs/install-the-monetate-inspector-browser-plug-in). It shows that two calls to track on the page have been made.

![Callout of the track selector in Monetate Inspector](https://dyzz9obi78pm5.cloudfront.net/app/image/id/643ecc42542e83681f5d65b8/n/monetate-inspector-track-tab-track-selector.png)

Sometimes the additional call to track on a page appears in Monetate Inspector because a fallback track added to the Monetate tag fires if Monetate doesn't receive a `trackData` call before the `DomContentLoaded` browser event. This fallback track is likely what causes the second track due to the use of polling on the fully defined track. Ensure that your API methods and the Monetate tag are installed and defined directly in the page markup and as high in the page header as possible to ensure the `trackData` call is sent prior to the `DomContentLoaded` browser event.

:::CodeblockTabs
trackData Example

```javascript
// trackData Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
  "setPageType",
  "index"
]);
window.monetateQ.push([
  "addProducts", ["aaa", "bbb", "ccc", "ddd"]
]);
window.monetateQ.push([
  "trackData"
]);

function filterProducts() {

  // Hides products aaa, bbb, ccc, and ddd.
  // Shows products eee, ddd, and fff.

  window.monetateQ = window.monetateQ || [];
  window.monetateQ.push([
    "setPageType",
    "index"
  ]);
  window.monetateQ.push([
    "addProducts", ["eee", "ddd", "fff"]
  ]);
  window.monetateQ.push([
    "trackData"
  ]);
}
```
:::

