I want to capture the current webpage URL where users interact with my VoiceFlow chatbot and include it in the conversation logs. This would help me track which pages generate the most questions.
The previous_event variable seems undefined and I’m not sure how this would actually add the URL to the transcript records. Any suggestions on the correct way to implement this?
Been dealing with VoiceFlow integrations for years and this URL tracking thing trips up everyone.
The problem? You’re capturing the URL at widget load time, but VoiceFlow processes that data before conversation logging even starts. You need to send the URL during an active conversation moment.
Here’s what works in production:
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production'
});
// After load, send URL as user message
window.voiceflow.chat.interact({
type: 'text',
payload: `PAGE_URL: ${window.location.href}`
});
Then in your VoiceFlow flow, add a Capture block right after the start that looks for messages containing “PAGE_URL:” and extracts the URL into a variable.
Conversation logs only capture things that happen during the actual conversation flow. Launch events and initial payloads happen before logging starts.
I’ve used this pattern across multiple projects and it’s rock solid for tracking user behavior patterns.
Your approach won’t work because the launch event payload doesn’t stick around in the conversation transcript. I hit this same issue six months ago when setting up analytics for our support chatbot. Here’s what actually worked: use window.voiceflow.chat.proactive.clear() then window.voiceflow.chat.proactive.push() to inject the URL data after the widget loads. You’ve got to pass the URL as metadata through the interact method, not the launch event. In your VoiceFlow project, drop a Set block at the start of your flow to grab this metadata and save it to a variable that gets logged with conversations. The trick is you must explicitly save the URL to a conversation variable inside your VoiceFlow logic - don’t just pass it in the initial payload. Also make sure your project settings have conversation logging turned on with custom variables included.
I faced a similar challenge a while back, and it took me some time to figure out the right approach. The launch event doesn’t automatically save the URL in the conversation logs. What worked for me was creating a custom action within VoiceFlow that specifically handles the URL data. You will need to define a variable dedicated to storing the page URL in your VoiceFlow settings. Then, utilize an API action block to capture the URL from your initial launch payload and assign it to that variable. The crucial part is ensuring the URL is recorded correctly in the conversation logs. Instead of only relying on the launch event, consider sending the URL as part of the user context via window.voiceflow.chat.interact(), which you can trigger after the widget loads. Furthermore, make sure your VoiceFlow project settings allow custom variables to appear in the transcripts, as there is an option for that in the project dashboard.