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.
Example: window.dataLayer = window.dataLayer || ;
//WATTS JSON Structure in Site Features
//Callback dataLayer Update on CSF Actions such as Campaign Counted.
dataLayer['sscampaigns'] = watts_object['sscountedcampaigns'];
If the callback function is not defined, the data from the response can be accessed from SS.getAsmtData().