Initialize OnVoard object
Specify the following snippet once before you add any javascript API code so that OnVoard object is initialized.
<script>
(function() {
window.OnVoard = window.OnVoard || function() {
(window.OnVoard.q = window.OnVoard.q || []).push(arguments);
};
})();
</script>
Below are available methods for Prompt's Javascript API.
Set Custom Properties
Set custom properties. When setting up prompts, you can specify display conditions to filter by custom properties.
OnVoard('prompt', 'setCustomProperties', {
'logged_in': false,
'source': 'google',
});
On Ready Event
Execute a callback function when prompt scripts are loaded and ready.
const promptReadyCallback = () => {
console.log("Prompt is ready");
};
OnVoard('prompt', 'onReady', promptReadyCallback);
Prompt Display Event
Execute a callback function when prompt is display. This will be executed everytime a prompt is display.
const promptDisplayCallback = (promptId) => {
console.log(`Prompt display: ${promptId}`);
};
OnVoard('prompt', 'onPromptDisplay', promptDisplayCallback);
Prompt Close Event
Execute a callback function when prompt is close. This will be executed everytime a prompt is close.
const promptCloseCallback = (promptId) => {
console.log(`Prompt close: ${promptId}`);
};
OnVoard('prompt', 'onPromptClose', promptCloseCallback);
Track Prompt Impression Event
Execute a callback function to track prompt impression metric. You can use this to trigger pixels for analytics platforms like Google Analytics. The difference between this callback and onPromptDisplay
is that this callback will automatically excludes duplicate impressions.
const trackPromptImpressionCallback = (promptId) => {
yourTrackingScript(promptId);
};
OnVoard('prompt', 'onTrackPromptImpression', trackPromptImpressionCallback);
Track Prompt Engagement Event
Execute a callback function to track prompt engagement metric. You can use this to trigger pixels for analytics platforms like Google Analytics.
const trackPromptEngagementCallback = (promptId) => {
yourTrackingScript(promptId);
};
OnVoard('prompt', 'onTrackPromptEngagement', trackPromptEngagementCallback);
Track Prompt Close Event
Execute a callback function to track prompt close metric. You can use this to trigger pixels for analytics platforms like Google Analytics. The difference between this callback and onPromptClose
is that this callback will automatically excludes duplicate closes.
const trackPromptCloseCallback = (promptId) => {
yourTrackingScript(promptId);
};
OnVoard('prompt', 'onTrackPromptClose', trackPromptCloseCallback);