Our website has multiple calls to action, but to give a more personalised experience, I want the contact us form to pre-fill with set info from the page or anchor from which the user has clicked through (e.g. ‘Find out more’ ‘Book an appointment’ - etc) - so it’s clear to us what the user wants and it’s clear to the user what they’ve submitted a request for. Any ideas?! Thanks!
I think you could use wix-storage for this. See documentation here .
What I’m thinking is that you put “on click” handlers on your buttons, which would put a string into storage (probably session storage for this case), identifying which page/location the user is coming from, before sending the user to the contact page:
import { session } from 'wix-storage';
import wixLocation from 'wix-location';
export function learnMore_click(event) {
session.setItem("contactSubjectLine", "Whatever you want subject line to be");
wixLocation.to("/contact");
}
Then, on your contact page, in the onReady function you can load the string from storage to see where the user came from, and use this to pre-load the subject line as appropriate:
import { session } from 'wix-storage';
$w.onReady(function () {
let subjectLine = session.getItem("contactSubjectLine");
let subjectField = $w("#subjectFieldId");
subjectField.value = subjectLine;
});