I’ve got the sendgrid integration working nicely to send me an email each time someone submits one of my custom forms, but I would also like the information I’m receiving to include the current page URL they are on (I’m using a lightbox form connected to all my pages, so the page will vary).
I’ve been able to get the URL sent to the WIX database via additional coding, but I can’t seem to figure out how to include it in the email notification I receive.
My current working code is below. The red arrow notates where I believe the URL code should go
I would recommend declaring your path variable ad assigning the latest URL to it the assigning it to the URL variable in the sendFormData function. See code below:
let path = wixLocation.onChange((location) => {
return location.path;
})
function sendFormData(){
.
.
.
\URL: path
.
.
}
The \URL: on the form is now just returning the word “path”. Is there additional code I need to add under the sendFormData function to get the actual URL?
The reason is because the sendFormData() functions runs before the value of path is retrieved. You can try using async/ await promise to make sure that the value of the path is returned from the wixLocation.onChange event.
Also, please note that path returns just the last part of the URL. To return full URL, you better use wixLocation.url .
Should you need further assistance, please paste your code with the modifications into the thread.
Also, as stated in the API info, make sure that your site is published first before testing it - If the site is not yet published, the function returns null.
@givemeawhisky I really appreciate all of your help with this. I matched the full code you sent above, but still am receiving just the word “path” (see pic for visual). Everything else is functioning as it should. Any other ideas?
You might need to actually include it into the form so that you can simply use the element in the form like all the others, or have it as a hidden user input so that only you know that it is there.
So you can add something like this into your page code where your user input form is and have the url user input as a read only element, which gets the url added to it automatically.