Jump to content

Custom re-direct based on form answers from users

Recommended Posts

Site URL: https://coral-amphibian-g9w7.squarespace.com/

Hi all!
I'm trying to find a way to custom re-direct users to pages based on their inputs to the form. I saw other posts on this forum which enable a way to do this. This one is particularly helpful: 

The catch is, we want to to re-direct users to different pages based on a small matching algorithm that we run on the user's responses. Essentially, the algorithm will create a combined score based on inputs into the form, and based on that score, the algorithm will re-direct to a custom page. We know how to code the algorithm in python, but we don't know how to integrate a python script with Squarespace. Is there a way we can call a Squarespace link in a python script on  Squarespace.

If that's not possible, is there simple way by which we can integrate the algorithm into the script presented above? Thanks for the help!!

Link to comment
  • Replies 1
  • Views 365
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

python is a server-side language so you won't be able to execute it client-side (which is where squarespace custom code can be injected and executed). in the post you reference they are using javascript (with jquery too) which executes on the client.

I think your best bet is to rewrite your algorithm in javascript and inject it into the page, then use a little bit more javascript to find the form button and intercept the click handler to edit where the page goes. You could do this with an existing form, or just design your own in a code block.

If that doesn't suit you, you might find there is an external provider that would support something liek this e.g. google forms and maybe you could design your algorithm on there, and embed it. If you must use python, then you'll need to stand up your own webserver to process the form results and then redirect accordingly. probably not worth it unless your python algorithm is extremely complicated.

Dave Hart. Software/Technology Consultant living in London. buymeacoffee 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.