Use the activate() API to ensure variation delivery on single-page apps.
Important
All JavaScript APIs in Optimize must be wrapped in a .ready() callback to run properly.
If your site uses single-page app (SPA) routing, the Optimize snippet won’t automatically re-trigger when the URL or state changes. The activate() API lets you manually activate the snippet so visitors see the correct variation after navigation.
activate()
intellimize.activate();
SPA-only API
This API is only intended for single-page apps (SPAs). If your site loads new pages through traditional full-page refreshes, you don’t need to use this — the Optimize snippet activates automatically. Using this API on non-SPA sites can cause issues like duplicate activations or unexpected behavior.
Use the activate() API only when:
- Your site is a single-page app (SPA)
- The URL or state changes without a full page reload
Ideal sequence to avoid flicker
- Change the URL
- Call
activate() - Mutate the DOM