Callbacks

You can define callbacks in callbacks option to customise the behaviour of Maître. Callbacks is a property of the global variable  window.Maitre.

<script type="text/javascript">

  window.Maitre = {
    uuid: "MFXXXXX",
    callbacks: {
      onLoad: function() {
         ... your logic ...
      },
      afterLoad: function() {
         ... your logic ...
      },
      success: function(data, form) {
         ... your logic ...
      },
      afterSuccess: function(data, form) {
         ... your logic ...
      },
      popupClosed: function() {
         ... your logic ...
      },
      error: function(errorThrown, form) {
         ... your logic ...
      }
    }
  };

</script>

There are four available callbacks:

  • onLoad
    Is triggered before everything else.
  • afterLoad
    Is triggered after the widget has been loaded.
  • success
    Is triggered when 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.
  • afterSuccess
    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.
  • popupClosed
    Is triggered when clicking on the cross to close the popup (if enabled).
  • error
    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 success or 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:

  • response
    Values can be:
    • subscriber_created
      Subscriber successfully created
    • subscriber_retrieved
      Subscriber has checked the position in the list
    • subscriber_accepted
      Subscriber has already been accepted
    • subscriber_not_verified
      Subscriber hasn't confirmed the email.
    • email_not_valid
      Email is not valid.
  • name
    The name provided in the name field.
  • email
    The email provided in the email field.
  • code
    Subscriber's unique referral code.
  • leaderboard
    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.
  • referred
    If the subscriber has been referred or not. Boolean.
  • people_referred
    Number of people referred by this subscriber.
  • facebook_short_link
    Short link that can be used on Facebook and will track visits and conversions from Facebook.
  • twitter_short_link
    Short link that can be used on Twitter and will track visits and conversions from Twitter.
  • email_short_link
    Short link that can be used in the body of an email and will track visits and conversions from emails.
  • referral_link
    Subscriber's unique referral link.
  • host
    URL used to generate the short links.
  • people_ahead
    number of people in the list in front of the current subscriber. Please notice that when the response is equal to "subscriber_accepted" or "subscriber_not_verified" this value will be null.
  • people_behind
    number of people on the list behind the current subscriber. Please notice that when the 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".

Email validation

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 contain two properties:

  • response
    email_not_valid
  • reason
    • Email format is not valid.
      If email format is not valid. Eg: myname@gmail
    • Email can't be an alias.
      If the email address is an alias. Eg: myname+test@gmail.com
    • You can't use a disposable domain.
      If email address uses a disposable domain. Eg: myname@xyzfree.net

Still need help? Contact Us Contact Us