---
title: addPollForElement
slug: js-api/addpollforelement
description: Overview of the Monetate JavaScript API addPollForElement method and how to use it
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-04-30T18:54:53.872Z
---

:::CodeblockTabs
addPollForElement Method

```javascript
// addPollForElement Method
window.monetateQ = window.monetateQ || [];
window.monetateQ.push(["addPollForElement",
  "selector string"
])
window.monetateQ.push(["trackData"]);
```
:::

The `addPollForElement` method is used to add a delay to the [trackData method](docId\:gcm0H169GurCQMv6sBota) call until some element on the page exists. This method is useful if you added calls to the Monetate JavaScript API in the page `<head>` element with the [Monetate tag](docId\:zcx_p3d6ND2Rr5bJLOyUG). This configuration could cause track to occur before a page loads, resulting in actions that don't execute on the page

Before implementing the `addPollForElement` method, be aware of these additional considerations:

- If you want to delay track with polling, you must call `addPollForElement` *before* you call `trackData`.
- You can pass any valid CSS selector as the second parameter in `addPollForElement`.
- When the polling function completes successfully, it's deleted and isn't evaluated again on subsequent [retracks](docId\:z7zs1BulqPT_0Z1CoYHww) unless you add another call to `addPollForElement`.
- `addPollForElement` polls every 50 milliseconds for 5 seconds or until the designated element is found. Monetate tracks regardless of whether the element is found or the poll times out.

## Code Sample

:::CodeblockTabs
addPollForElement Example

```javascript
// addPollForElement Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push(["addPollForElement",
  "#topNav .subnav span"
])
window.monetateQ.push([
  "trackData"
]);
```
:::

