SPA ViewChange Anomaly | Community
Skip to main content
Level 2
January 30, 2026
Question

SPA ViewChange Anomaly

  • January 30, 2026
  • 0 replies
  • 8 views

In our SPA, we observed a specific behavior of Target activities:

  • Even with renderDecisioning=false, some activities continued to trigger.

  • The activities are present but not rendered.

  • Since this is a SPA and there is no page refresh, in the subsequent Rule Page View we could not find the activities with the key expected by Target.

  • Important: before user login, there were no Rule Page Views. Activities were therefore only processed after login, and everything worked correctly in that phase.

Implemented Solution

To properly handle the SPA flow without page refresh, the following was implemented:

  1. In the Rule Page View, after login, a custom code was added to handle view changes:
     

    function onViewChange() {
      var viewName = window.location.pathname || 'viewNamePage';

      if (viewName.startsWith('/')) {
        viewName = viewName.substring(1);
      }

      alloy("sendEvent", {
        renderDecisions: true,
        xdm: {
          eventType: "view",
          web: {
            webPageDetails: {
              name: viewName,
              url: window.location.href
            }
          }
        }
      });
    }

  2. Then a sendEvent was triggered with the requestDefaultPersonalization flag enabled for SPA.

  3. After this change, the interact payload is displayed correctly.

Anomalies Observed After the Change

  • Some console logs that are populated with user profile attributes (sent via destination and mapped according to activity documentation) are no longer populated.

    • Previously, after login, the attributes were correctly populated.

    • The change with requestDefaultPersonalization seems to have altered this behavior.

  • No activity associated with an audience the user belongs to is displayed.

Verifications Performed

  • Checks on datastream confirm that user attributes and audiences are correctly projected to the edge.

 

Could you provide some guidance on where I should focus my attention?