Hi, I am needing help figuring out a way to track the page a form was submitted on. "Page" referring to the site content shown on a dynamic page.
Context: We host hundreds of IT events across 22 cities each year, and in order to get information on our attendees to communicate important info, we send landing pages which contain event details, location, and a *form submission*.
In the past I have created all these pages manually one by one but every page is practically identical except for what the text/images etc. are. The layout itself is identical across all pages which is why I've been transitioning over to Dynamic Pages.
Problem: I have created a dynamic page that contains all elements described above, shown based on a site content collection, but the issue I'm running into is regarding form submissions. I am trying to find a way to track the page (Page being in regards to what site content is shown, top right on image, whether it is "Nashville or Phoenix") the form was submitted on.
Ideas: I am curious to see what people think but some ideas I've come up with that would work that I just don't know how to setup:
P.S I have a Zapier subscription too, in case that influences any ideas.
#1 Some sort of text box linking to the site content collection which would receive a title different for each page that could link to the form submission and add to the contacts data. The part I am struggling with on that idea is linking the text box to the form submission to add to the contacts data.
#2 Setting up the form title itself to link to the site content collection. The part that I struggle with here is the possibility of having to manually recreate the form as code. (I am a code noob 😆, I only know HTML, CSS, some Python. JavaScript is now on my to-do list for sure!)
#3 Or if there's a way to dynamically add forms to a page from the content collection itself.
Please, if you know how to accomplish one of the ideas above or have an idea of your own, I am in need of help with this and would greatly appreciate it!
Parker Hemming
National IT Manager | C10 Inc.
@Velo-Ninja Yes, re-adding, but hiding the submit button just solved everything! It is all working perfect!
THANK YOU SO MUCH! For all you help with this! I definitely couldn't have accomplished this without you! I know it's probably not the cleanest method to achieve this but all I need is for it to work and it does! I will be continuing my JavaScript/coding journey more outside this project! I have learned so much talking with you!
To any one trying to accomplish this same task here is the code (Thanks to @Velo-Ninja):
#dynamicDataset is the site content
link-registration-1-title is the ID for the URL in site content
#dataset2 is the collection where the form submissions are stored (You will want to change these to your desired fields)
#btnSubmit is the new submit button, the real submit button is hidden (To preserve required fields being required etc.)
dataToBeSaved is where the fields in the form are saved to
P.S I am using a multi-step form for this, hence the states being called for the new submit button (To preserve Thank you Page)
$w.onReady(function() { $w("#dynamicDataset").onReady(() => { let currentItem = $w("#dynamicDataset").getCurrentItem(); console.log("ITEM: ", currentItem); let title = currentItem.title; console.log("Title: ", title); let ID = currentItem._id; console.log("ID: ", ID); let mySearchedValue = currentItem["link-registration-1-title"]; console.log(mySearchedValue) $w("#dataset2").onReady(() => { $w('#btnSubmit').onClick((event) => { console.log("Submit-Clicked!"); let dataToBeSaved = { "title": "Executive Registration", "pageSubmitted": mySearchedValue, "firstName": $w('#fName').value, "lastName": $w('#lName').value, "position": $w('#title').value, "company": $w('#company').value, "email": $w('#email').value, "personalEmail": $w('#personalEmail').value, "phone": $w('#workPhone').value, "phone2": $w('#cellPhone').value, "copyOfCopyOfAddAnswerHere": $w('#hobby').value, "copyOfWeLikeToGetToKnowThePersonBehindTheTitleSoThatWeCanBetterConnectYouWithPeersWhatAreSomeOfYourHobbiesPassionsOutsideOfWor": $w('#charity').value, "copyOfOurTeamAtC10NeedsHelpBecomingBetterConnectedWithTrustedVendorsAndBusinessPartnersInTheCommunityWhoAreSomeVendorsThatYouWorkW": $w('#vendors').value, "copyOfToBetterHelpExecutivesConnectWithPeersWithSimilarChallengesWhatTopicsOfConversationOrInitiativesAreMostImportantToYouRightNow": $w('#topics').value } $w("#dataset2").setFieldValues(dataToBeSaved); $w("#dataset2").save() .then((item) => { console.log(item); }) .catch((err) => { let errMsg = err; }); $w("#statebox1").changeState("stateboxFormState1"); }); }); $w("#dataset2").onAfterSave(() => { console.log("After-save running!") }); }); });