I want to capture the current page URL where users interact with my VoiceFlow chatbot and include it in the conversation transcripts. This would help me track which pages generate the most questions from users.
(function(document, scriptTag) {
var widget = document.createElement(scriptTag), firstScript = document.getElementsByTagName(scriptTag)[0];
widget.onload = function() {
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID_HERE' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production',
launch: {
event: {
type: "start",
payload: {
page_url: window.location.href
}
}
},
autostart: false
});
}
widget.src = "https://cdn.voiceflow.com/widget/bundle.mjs";
widget.type = "text/javascript";
firstScript.parentNode.insertBefore(widget, firstScript);
})(document, 'script');
I also tried this approach:
if (previous_event) {
page_url = previous_event.payload.page_url
} else {
page_url = "unknown page"
}
The variable previous_event seems undefined and I’m not sure how this connects to the transcript logging. Any ideas on the correct way to pass page URL data to VoiceFlow transcripts?