Optimising tracking for Single Page Applications

GoSquared tracking typically relies upon page refreshes. When a page refresh occurs, the GoSquared script loads and updates the user’s feed.

This is also the basis for updating GoSquared Smart Groups, particularly Smart Groups which use the ‘Viewed URL’ filter.

With Single Page Applications, there is no page refresh when a user navigates to another page, therefore the snippet will not normally detect updated movement, unless in the case of a manual refresh.

This would cause issues with tracking user behaviour, as well as updating Smart Groups and triggering Automated Messages in SPAs.

✅ In order to resolve the issue, please follow the steps below:

  1. Turn off GoSquared’s automatic pageview tracking

Within your GoSquared snippet, you will find your project token.

  1. In order to disable automatic tracking, add the code false to the project token. For example:
_gs(GSN-1234567-A, false);
  1. For each page you need to track, add the custom code below:
_gs(‘track’, ‘/custom-path’, ‘Custom title’);

This will ensure that SPAs are able to detect pageviews without refresh. This allows user feeds and Smart Group filters to update correctly, and enables associated Automated Messages to trigger successfully 🚀.

Have any questions about setting up GoSquared features in Single Page Applications? Just send us a message here!