Fixing Tracking Discrepancies in Single Page Applications (SPAs)

Created by Donald Ng, Modified on Tue, 30 Dec, 2025 at 2:10 PM by Donald Ng

This article explains how to ensure Mida correctly tracks visitors and conversions on websites that use dynamic navigation instead of full page reloads.


The Problem


Visitors to Single Page Applications (SPAs) often go unrecorded in experiments after they navigate away from the initial landing page. This results in low visitor counts and inaccurate conversion data because the test does not automatically re-evaluate when the URL changes.


Why This Happens


Mida typically triggers when a page finishes loading. Since SPAs update content dynamically without a browser refresh, the script may not recognize that a user has moved to a new URL that meets your test targeting criteria.


Solution


To resolve this, you must notify the Mida script that your site operates as an SPA by setting a global variable.


1. Locate the area of your site code where the Mida tracking script is installed.

2. Add the following code snippet immediately before the Mida script: 

<script>window.isSPA = true</script>

3. If you use Google Tag Manager, add this snippet as a Custom HTML tag and set it to trigger before the Mida script tag.

4. Save your changes and publish the update.


Quick Reference


Setting window.isSPA to true enables Mida to monitor the browser history API and retrigger experiments automatically whenever the URL changes.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article