1. Help Center
  2. Analyze
  3. Data Export and Integration

WATTS for Single Page Applications and Client Side Variations

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:

  1. Select SiteConfigurationSite Settings.
  2. Select the Features tab.
  3. 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 || [];

    ({
        'sscampaigns' :
        '__SS_LISTCAMPAIGNCOUNTED{SS__SS_TCID__:__SS_VGID__}{,}__'
    });
//WATTS JSON Structure in Site Features
{'sscountedcampaigns' :
        '__SS_LISTCAMPAIGNCOUNTED{SS__SS_TCID__:__SS_VGID__}{,}__'}
//Callback dataLayer Update on CSF Actions such as Campaign Counted.
    ss_dom_var.setAsmtCallback(function (watts_object)
    {
dataLayer['sscampaigns'] = watts_object['sscountedcampaigns'];
    });	

If the callback function is not defined, the data from the response can be accessed from SS.getAsmtData().