Answered

Get the URL of the typeform page to results

  • 1 February 2023
  • 32 replies
  • 1415 views


Show first post

32 replies

You can create a url_form hidden field in your form, and then pass the URL of the page when loading the form dynamically.

 

<div id="tf"></div>
<link rel="stylesheet" href="//embed.typeform.com/next/css/widget.css" />
<script src="//embed.typeform.com/next/embed.js"></script>
<script>
window.tf.createWidget('<form-id>', {
container: document.getElementById('tf'),
hidden: { url_form: window.location.href }
});
</script>

 

 

@jeremielp thank you very much, that works. But I would like my form to be embedded in a slider format. My slider view code is:

<div data-tf-live="01HM2CYB1HZV6VWWG3XYTK4K7D"></div><script src="//embed.typeform.com/next/embed.js"></script>

How can I make it so that after filling out my form from this view, it automatically collects information about the page on which the form is being filled out?

Userlevel 7
Badge +5

Cześć @maksrybicki 

this is possible only by using the Typeform Embed SDK directly, not via snippet from the share page (the code you shared).

You can use a code like this to embed your typeform as slider:

<a href="#" id="tf">Aplikuj</a>
<link rel="stylesheet" href="//embed.typeform.com/next/css/slider.css" />
<script src="//embed.typeform.com/next/embed.js"></script>
<script>
document.querySelector('#tf').onclick = (event) => {
event.preventDefault()
window.tf.createSlider('fhRL6nmN', {
hidden: { url_form: window.location.href }
}).open()
}
</script>

Hope this helps. 

Cześć @maksrybicki 

this is possible only by using the Typeform Embed SDK directly, not via snippet from the share page (the code you shared).

You can use a code like this to embed your typeform as slider:

<a href="#" id="tf">Aplikuj</a>
<link rel="stylesheet" href="//embed.typeform.com/next/css/slider.css" />
<script src="//embed.typeform.com/next/embed.js"></script>
<script>
document.querySelector('#tf').onclick = (event) => {
event.preventDefault()
window.tf.createSlider('fhRL6nmN', {
hidden: { url_form: window.location.href }
}).open()
}
</script>

Hope this helps. 

@mathio It works! Thank you very much!!! :)

Hello @mathio thanks a lot for the proposed solutions so far.

However, I’m looking for a way to make it work using a popup, not just a regular embed or slider. What would be the modifications needed to make this work?

Thanks a lot!

Userlevel 7
Badge +5

Hello @Robbie7 

you can do that by reusing the very same code. All you need to do is replace the “createSlider” method name with “createPopup” in the JavaScript code (and of course using you own form ID instead of “fhRL6nmN”).

Good luck!

Hello @Robbie7 

you can do that by reusing the very same code. All you need to do is replace the “createSlider” method name with “createPopup” in the JavaScript code (and of course using you own form ID instead of “fhRL6nmN”).

Good luck!

You’re the best, thanks so much!

Userlevel 7
Badge +5

Let us know how it goes, @Robbie7 !

Reply