The trackData
method initiates the process of sending data to Monetate. This method can be called as many times as necessary to give the most current picture of a customer's experience to the Monetate platform.
Using the trackData Method
Each time the trackData
method is called, the monetateQ
array is cleared so that new data can be pushed to it. 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.
For example, if the site content changes via an AJAX request, the trackData
method can be called.
Multiple Track Requests in Monetate Inspector
You may notice more than one call to track on a page when you check the Monetate Inspector browser plug-in. 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.
Code Example
// trackData Method 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" ]); }