Tanmay Posted October 11, 2021 Share Posted October 11, 2021 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
iamdavehart Posted October 11, 2021 Share Posted October 11, 2021 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment