Ajax tracking can be used when an element, form, or page state is loaded, or refreshed on a webpage using Ajax, and the updated tracking information needs to be sent to the Optimizely Recommendations tracking system. As a response to this request, Optimizely returns any widgets configured for the page. When the recommendations are ready, they are passed to the `
smartRecs` callback function in the form of JSON data.
## Tracking requests
The implementation of Ajax tracking consists of three stages:
**Stage 1** – An updated version of the tracking needs to be stored in a variable.
**Stage 2** – The contents of the variable need to be encoded by calling the encodeURIComponent method.
**Stage 3** – Send the updates to the Optimizely Personalization tracking system by calling Peerius.sendAjax("rest.pagex?jd="+json)