Method Calls

addPollForElement

addPollForElement Method


The addPollForElement method is used to add a delay to the trackData method 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. 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 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

addPollForElement Example