Yes, this typically can't be done unless you dissect the form and find the
form action.
In this case, it looks like they use a company called Cyberimpact:
<form class="ui form"
action="
https://app.cyberimpact.com/optin" method="post" accept-charset="utf-8">
So when the submit button is pressed, the form content is sent to that web address using a post method.
Then if you look at the rest of the form items, you can see they are looking for the first, last, and email (as you know). But they are also looking for other content, like the
account (which I'm guessing is the company where the form resides (Bouret)).
You can research how to do a http post method elsewhere, but if you build an object with the expected content, you should be able to use Apps script like this.
If you define the firstName, lastName and email, you can then pass them to a function like this (untested--just theory):
function makeRequest(firstName, lastName, email) {
var url = "
https://app.cyberimpact.com/optin";
var options = {
method: 'post',
headers['Content-Type']: 'application/json',
ci_firstname: firstName,
ci_lastname: lastName,
ci_email: email,
ci_groups: '2',
ci_account: '12911cea-1ee8-4fa5-edfa-5b87ccd958e0',
ci_language:'en_ca',
ci_sent_url: '',
ci_error_url: '',
ci_confirm_url: ''
};
return JSON.parse(UrlFetchApp.fetch(url, options)); //whatever response you get will be logged in the apps script console
}
var
firstName = "John"
console.log( makeRequest(firstName, lastName, email) )
Anyway, some mix of the above is how I would go about doing it. Much of this I learned watching this one video from Coding Garden:
https://www.youtube.com/watch?v=QcaO1a-x0aQ where he orders a Dominos pizza with javascript. It shows how he derives all the info needed.