Skip to main content

When to load test: choose when Mida applies your variant

Use page load, URL Change, DOM Change, Wait for an element or manual code to control when your variant is applied.

Mida normally applies your variant as soon as the page loads. Some pages load content late, or change the URL without a full page reload, like single-page apps (SPAs) and multi-step checkouts. For these, you can choose when Mida applies your variant.

Where to find it

Open your test and go to the Configuration step. Under When to load test?, choose one of three options:

  • When the page loads: best for most tests. Mida applies your variant right away. Use it when the element you're testing is already in the page HTML.

  • When a condition is met: pick a condition from the dropdown (see below). Useful for single-page apps and for content that loads late.

  • Manually with code: the test doesn't run until your developer calls mida.execute(TEST_ID). Mida shows the code with your test ID. Use it after a login, cookie consent or a custom event.

Conditions you can choose

  • URL Change: Mida runs your test again when the URL changes without a page reload. Example: a checkout where each step changes the URL.

  • DOM Change: Mida waits for any change on the page, then applies your variant. Use it when content updates often and there's no single reliable element to wait for. Example: a product grid that re-renders when filters change.

  • Specific DOM Change: Mida waits until one specific element appears or changes. Example: a recommendation widget that replaces a placeholder.

  • Wait for an element: Mida waits until your target element exists, then applies the changes. Example: a popup, sticky bar or section added by JavaScript after the page opens.

  • When URL Change and Wait For An Element: Mida runs again after a URL change and waits for a specific element before applying. Best when the element only exists on certain routes, for example a button that only appears on /pricing after navigating from the homepage.

For Specific DOM Change, Wait for an element and When URL Change and Wait For An Element, enter the element's CSS selector in DOM Element Path (CSS Selector), for example #checkout-button.

How URL Change works

Mida detects URL changes made by the browser history (the way most single-page apps navigate), the back and forward buttons, and changes to the part of the URL after #.

After each URL change, Mida checks your URL targeting rules again against the new URL. If the new URL doesn't match your targeting, the test's custom CSS and JS are removed, so they don't stay on pages that aren't part of the test.

Which option should I choose?

  • Most tests: keep When the page loads.

  • Content that loads late (popups, carousels, lazy sections): use Wait for an element.

  • Single-page apps: use URL Change, or When URL Change and Wait For An Element if the element only appears on some routes.

  • Your developer decides when: use Manually with code.

Related articles

Did this answer your question?