You can define callbacks in callbacks option to customise the behaviour of Maître. Callbacks is a property of the global variable window.Maitre.
There are four available callbacks:
Is triggered before everything else.
Is triggered after the widget has been loaded.
Is triggered when the form has been succesfully submitted. It receives two parameters: data, which is a json object with the result, and form, which is the form element.
Is triggered after the form has been successfully submitted. It receives two parameters: data, which is a json object with the result, and form, which is the form element.
Is triggered when clicking on the cross to close the popup (if enabled).
Is triggered when an error occurs. It receives two parameters: errorThrown, which is the error that has forbidden the submission of the form, and form, which is the form element.
ⓘ When you initialise the
error callbacks, those will override the default ones. Therefore, if you use them make sure to write your own logic to hide the form and make the div [data-maitre-content] appear.
The json object of a successful form submission will contain the following properties:
Values can be:
Subscriber successfully created
Subscriber has checked the position in the list
Subscriber has already been accepted
Subscriber hasn't confirmed the email.
Email is not valid.
The name provided in the name field.
The email provided in the email field.
Subscriber's unique referral code.
If property "require_leaderboard" is set to "true" this value will contain an object with a timestamp of the last update to the list and an array of the top 10 subscribers in the list, otherwise NULL. For more information check this support article.
If the subscriber has been referred or not. Boolean.
Number of people referred by this subscriber.
Short link that can be used on Facebook and will track visits and conversions from Facebook.
Short link that can be used on Twitter and will track visits and conversions from Twitter.
Short link that can be used in the body of an email and will track visits and conversions from emails.
Subscriber's unique referral link.
URL used to generate the short links.
number of people in the list in front of the current subscriber. Please notice that when response is equal to "subscriber_accepted" or "subscriber_not_verified" this value will be null.
number of people in the list behind the current subscriber. Please notice that when response is equal to "subscriber_accepted" or "subscriber_not_verified" this value will be null.
If a user, checking his position in the list, enters an email that doesn't exist in the database, the json object will only contain response: "subscriber_not_found".
We take data security very seriously and have implemented an anti-spam system that verifies every single email, making sure it's a valid email, it doesn't come from a known disposable domain and it's not an alias.
If an email address doesn't pass our validation test, the json object will containt two properties:
- Email format is not valid.
If email format is not valid. Eg: myname@gmail
- Email can't be an alias.
If email address is an alias. Eg: email@example.com
- You can't use a disposable domain.
If email address uses a disposable domain. Eg: firstname.lastname@example.org
- Email format is not valid.