Join the Webstudio community

Updated 4 weeks ago

Workaround for Dynamic Redirect for a Webhook Form

As mentioned by @Oleg Isonen on Github I created the workaround for a redirect of a webhook form.

→ So I added an HTML embed inside the webhook form's success box with this code (and changing it to my path).

<script> location.href = '/whatever' </script>

This worked great for a static link/slug/redirect.

Now I wanted to make it dynamic based on the Slug in AirTable (think redirection based on a specific product for example).

In the Webstudio University its documented how to create dynamic links for the filtering of the Airtable data by the slug (which worked perfectly).

https://example.com?filterByFormula={YOUR_COLUMN_NAME}="${system.params.YOUR_DYNAMIC_PATH}"


Now I wanted to do the same (creating a dynamic URL with the slug) and add it into Oleg's workaround code mentioned above (inside of an HTML embed in the success box of the webhook form).

It always says: "Unexpected token".

I guess it doesn't work the same way because the Airtable integration in the Variables panel is based on JSON and the embed on HTML?
I tried every method that came to mind (and from ChatGPT)… still doesn't work.

Does anyone has an idea? Any solution is much appreciated since this is a core part of my next project I am working on right now.
Attachments
image.png
image.png
J
H
O
22 comments
You would need to drill down into the json object and get just the value you need.

Let's see what you've tried and I'll provide feedback based on that
Hey John!

Thanks for the fast reply. How can I provide you useful data on that so you can give me feedback?
A screenshot of the HTML embed where you are attempting this with the expression
I guess it's wrong how I concatenate
I tried multiple versions, this is one of them
Attachment
image.png
The whole thing needs to be in backticks not quotes
let me see if docs have an example
That worked John, thanks…
Attachments
image.png
image.png
Unfortunately it doesn't redirect the form now 😂 😅
script is not correct 🙂

<script>
your code
</script>

you currently are placing location in the script tag like <script YOUR CODE>should actually be here</script>
🤦‍♂️😅 You are obviously right

Fixed it… it still doesn't redirect the form
Attachment
image.png
looks right. can you screenshot what that looks like in the right sidebar in setting? ie the computed expression
Weird… now it doesn't even work with the static URL

<script> location.href = /go/landing-1a/video </script>
you don't have regular quotes around path
path is a string
you will see the error in the dev tools console
Plain Text
`<script> 
  location.href = "/go/landing-1a/video"
</script>`
When I use the dynamic link with backticks and the ${} it transforms it from image 1 to image 2 (looks good, but doesn't redirect)
Attachments
image.png
image.png
What am I missing here for dynamic redirects of the webhook forms?
Oleg, you say the link is with "/slug"? Let me try…
Thanks! That worked!
Already a great start! Now let's get to work and something great
Add a reply
Sign up and join the conversation on Discord
This worked great for a static link/slug/redirect.Now I wanted to make it dynamic based on the Slug in AirTable (think redirection based on a specific product for example).In the Webstudio University its documented how to create dynamic links for the filtering of the Airtable data by the slug (which worked perfectly).https://example.com?filterByFormula={YOUR_COLUMN_NAME}=\"${system.params.YOUR_DYNAMIC_PATH}\"Now I wanted to do the same (creating a dynamic URL with the slug) and add it into Oleg's workaround code mentioned above (inside of an HTML embed in the success box of the webhook form). It always says: \"Unexpected token\".I guess it doesn't work the same way because the Airtable integration in the Variables panel is based on JSON and the embed on HTML? I tried every method that came to mind (and from ChatGPT)… still doesn't work. Does anyone has an idea? Any solution is much appreciated since this is a core part of my next project I am working on right now.","answerCount":22,"upvoteCount":0,"datePublished":"2025-03-17T17:41:39.912Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"},"suggestedAnswer":[{"@type":"Answer","text":"You would need to drill down into the json object and get just the value you need.Let's see what you've tried and I'll provide feedback based on that","upvoteCount":0,"dateCreated":"2025-03-17T18:09:04.216Z","datePublished":"2025-03-17T18:09:04.216Z","dateModified":"2025-03-17T18:09:04.216Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#39e9ed46-02d4-4193-ac00-a89b470b8db6","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"Hey John!Thanks for the fast reply. How can I provide you useful data on that so you can give me feedback?","upvoteCount":0,"dateCreated":"2025-03-17T18:43:11.302Z","datePublished":"2025-03-17T18:43:11.302Z","dateModified":"2025-03-17T18:43:11.302Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#6c21ffc9-2c58-4bac-93e2-a891dff7efef","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"A screenshot of the HTML embed where you are attempting this with the expression","upvoteCount":0,"dateCreated":"2025-03-17T18:43:55.460Z","datePublished":"2025-03-17T18:43:55.460Z","dateModified":"2025-03-17T18:43:55.460Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#08228a96-88ff-4e86-8644-6e17af63d9db","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"I guess it's wrong how I concatenateI tried multiple versions, this is one of them","upvoteCount":0,"dateCreated":"2025-03-17T18:49:16.838Z","datePublished":"2025-03-17T18:49:16.838Z","dateModified":"2025-03-17T18:49:17.138Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#60708701-7950-47fe-bace-8d71349eb1b9","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"The whole thing needs to be in backticks not quotes","upvoteCount":0,"dateCreated":"2025-03-17T18:49:48.165Z","datePublished":"2025-03-17T18:49:48.165Z","dateModified":"2025-03-17T18:49:48.165Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#4bd7b350-2e83-4509-b7f0-ee037a89e299","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"let me see if docs have an example","upvoteCount":0,"dateCreated":"2025-03-17T18:49:58.223Z","datePublished":"2025-03-17T18:49:58.223Z","dateModified":"2025-03-17T18:49:58.223Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#953e3b1e-e028-47e7-9c06-ff28a95ad38e","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"basically this https://docs.webstudio.is/university/foundations/expression-editor#schemabackticks and the ${}","upvoteCount":0,"dateCreated":"2025-03-17T18:50:26.248Z","datePublished":"2025-03-17T18:50:26.248Z","dateModified":"2025-03-17T18:50:27.231Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#ccf09a2e-a1ac-4449-ab58-96fde2afd8a6","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"That worked John, thanks…","upvoteCount":0,"dateCreated":"2025-03-17T19:01:37.521Z","datePublished":"2025-03-17T19:01:37.521Z","dateModified":"2025-03-17T19:01:37.910Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#7fe898f3-7ff0-42fd-96cc-bbf0c4124d19","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"Unfortunately it doesn't redirect the form now 😂 😅","upvoteCount":0,"dateCreated":"2025-03-17T19:03:07.738Z","datePublished":"2025-03-17T19:03:07.738Z","dateModified":"2025-03-17T19:03:07.738Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#f851e4ef-5339-46c3-9862-d5d4e37f087c","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"script is not correct 🙂you currently are placing location in the script tag like ","upvoteCount":0,"dateCreated":"2025-03-17T19:35:54.002Z","datePublished":"2025-03-17T19:35:54.002Z","dateModified":"2025-03-17T19:36:05.094Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#514fef27-4a23-4453-a408-2b147929b103","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"🤦‍♂️😅 You are obviously rightFixed it… it still doesn't redirect the form","upvoteCount":0,"dateCreated":"2025-03-17T21:45:27.016Z","datePublished":"2025-03-17T21:45:27.016Z","dateModified":"2025-03-17T21:45:27.279Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#696d88e4-dcee-47e6-a8a3-ebb55f63b7ec","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"looks right. can you screenshot what that looks like in the right sidebar in setting? ie the computed expression","upvoteCount":0,"dateCreated":"2025-03-17T21:48:34.177Z","datePublished":"2025-03-17T21:48:34.177Z","dateModified":"2025-03-17T21:48:34.177Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#237b6c05-8820-491b-90c3-168ff01babfc","author":{"@type":"Person","url":"https://help.webstudio.is/members/a3a85f00-1132-4262-8176-1ff92ab9d883","name":"John Siciliano","identifier":"a3a85f00-1132-4262-8176-1ff92ab9d883","image":"https://cdn.discordapp.com/avatars/1141467296532009071/8c83067a661d2916bfb8be5a37677463.webp?size=256"}},{"@type":"Answer","text":"Weird… now it doesn't even work with the static URL","upvoteCount":0,"dateCreated":"2025-03-17T22:02:46.724Z","datePublished":"2025-03-17T22:02:46.724Z","dateModified":"2025-03-17T22:02:46.724Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#f690d604-b802-4bdc-a308-4eed8493cce8","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"you don't have regular quotes around path","upvoteCount":0,"dateCreated":"2025-03-17T22:05:53.792Z","datePublished":"2025-03-17T22:05:53.792Z","dateModified":"2025-03-17T22:05:53.792Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#ab250764-4030-4ed6-a56a-e93236098d97","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"path is a string","upvoteCount":0,"dateCreated":"2025-03-17T22:05:58.281Z","datePublished":"2025-03-17T22:05:58.281Z","dateModified":"2025-03-17T22:05:58.281Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#15f9b5e9-8d55-4d92-8986-9c694e78bcf4","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"you will see the error in the dev tools console","upvoteCount":0,"dateCreated":"2025-03-17T22:06:18.597Z","datePublished":"2025-03-17T22:06:18.597Z","dateModified":"2025-03-17T22:06:18.597Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#53d551d5-8d75-4dfc-8fce-c74632350a00","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"``","upvoteCount":0,"dateCreated":"2025-03-17T22:09:01.827Z","datePublished":"2025-03-17T22:09:01.827Z","dateModified":"2025-03-17T22:09:01.827Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#abe85bec-05de-420c-bd91-df98caaea4fd","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"When I use the dynamic link with backticks and the ${} it transforms it from image 1 to image 2 (looks good, but doesn't redirect)","upvoteCount":0,"dateCreated":"2025-03-17T22:13:52.055Z","datePublished":"2025-03-17T22:13:52.055Z","dateModified":"2025-03-17T22:13:52.486Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#8107dab9-3984-462c-a8f8-5dc2c4a73dd5","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"What am I missing here for dynamic redirects of the webhook forms?","upvoteCount":0,"dateCreated":"2025-03-17T22:14:31.618Z","datePublished":"2025-03-17T22:14:31.618Z","dateModified":"2025-03-17T22:14:31.618Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#ca17a284-e7f3-46b3-828b-fd7e76f116fc","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"Oleg, you say the link is with \"/slug\"? Let me try…","upvoteCount":0,"dateCreated":"2025-03-17T22:15:52.422Z","datePublished":"2025-03-17T22:15:52.422Z","dateModified":"2025-03-17T22:15:52.422Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#57aa5840-167e-40ed-8601-fdeaa2bd930c","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"Thanks! That worked!","upvoteCount":0,"dateCreated":"2025-03-17T22:16:53.867Z","datePublished":"2025-03-17T22:16:53.867Z","dateModified":"2025-03-17T22:16:53.867Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#aa7a753a-e4b5-47bb-9648-a0d7310e28de","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}},{"@type":"Answer","text":"Already a great start! Now let's get to work and something great","upvoteCount":0,"dateCreated":"2025-03-17T22:20:23.995Z","datePublished":"2025-03-17T22:20:23.995Z","dateModified":"2025-03-17T22:20:23.995Z","url":"https://help.webstudio.is/workaround-for-dynamic-redirect-for-a-webhook-form-8LmShH5lrN9K#419a93d9-030e-41dd-97de-95b89e8064ad","author":{"@type":"Person","url":"https://help.webstudio.is/members/db8330ae-72ac-4bdf-9d5c-edd35893c070","name":"Hiram Broemme","identifier":"db8330ae-72ac-4bdf-9d5c-edd35893c070","image":"https://cdn.discordapp.com/avatars/1350432881742188565/2eabe117f7614223f047e82adf35b8c0.webp?size=256"}}]}}