Implementation on SPA-enabled sites
Triggering Experiences for SPA Sites
The triggering of experiences depends on the browser generating a "pageload," as most experiences are rendered when an appropriate page is loaded. However, SPA (Single Page Application) sites do not generate traditional pageloads. As a result, Gravity Field cannot launch a campaign without receiving information about pageviews.
To run a campaign on an SPA page, it is necessary to notify Gravity Field through an API call whenever the content on the SPA page changes. This includes not only complete page reloads, but also events triggered by changes to specific portions of the page, such as expanding a collapsed section, or opening a modal.
Sending Pageview Using API
Front-end API Call Format:
Parameters
context
object
url
Provide the current URL (it can be either the actual URL if the application changes the URL, or a virtual URL if the page URL remains constant). The URL is crucial to target campaigns to specific screens. If virtual URLs are used, their names must be clear to the business users of the platform.
string
countAsPageView
This parameter is used for analytics. Set it to true
every time the entire content of the screen changes (a new page from the user's/analytics perspective), and set it to false
when only a portion of the page changes.
boolean
This approach enables Gravity Field to track changes and trigger campaigns effectively on SPA pages.
Last updated
Was this helpful?