If you are using WATTS with a Single-Page Application, you can use an API call to request WATTS data. By default, the SiteSpect SPA SDK pings SiteSpect asynchronously (using /__ssobj/asmt_update) when a change is applied to update assignment data. This ping also updates the counted state for a visit if the Client-Side Factor is set to Count User when Triggered. By default, the ping returns an empty body and a 204, but it can be used to return updated assignment and WATTS variables.
To configure this call, you can define the WATTS macros in a JSON structure for the AJAX response as follows:
- Select Site, Configuration, Site Settings.
- Select the Features tab.
- Scroll down until you see Client-Side WATTS Template. Use this text area to define your WATTS macros.
A callback function is called with the data in the response so that a data layer on the page can be updated with an updated assignment. The callback function name is defined via ss_dom_var.setAsmtCallback; we recommend that you define this function in the WATTS Site Variation.
An example of the WATTS JSON Structure in Site Features
How a rewrite of ss_dom_var.setAsmtCallback would look
If the callback function is not defined, the data from the response can be accessed from SS.getAsmtData().
The reference to ss_watts variable assumes that it has been defined at the window scope, Most clients declare this within the head tag like
This declaration is generally referred to as the WATTS Site Variation noted above.