Embedding a newsletter subscription form onto an external page

  • Updated

A newsletter subscription form can be embedded onto your homepage in addition to the actual subscription page. The form should include at least a field for email and the identification number of the list that that the subscriber joins.

Basic form

<form method="post" action="http://customer.mailpv.net/account" class="lianamailer" id="lianamailer">
<input name="email" type="text">
<input type="hidden" name="join" value="12345">
<input value="Subscribe" type="submit">
  • In the form element, the word "customer" is substituted with the subscription page's name in the action section's web address. The subscription page name can be seen when clicking "settings" on the main navigation bar and then clicking "sites". Also this name can be checked from browsers address bar after sending a preview and clicking the "web version"-link.
  • Email's name field's value varies according to the language of subscription and unsubscription page, options are below the form.
  • A hidden input element's value field must be either list id (a series of numbers that can be found in the URL on the edit page of this list, at the end of the URL) or a name and the list must be subscribable (instructions below the form). The list ID can be also seen when doubleclicking the list and checking from the "list information"-tab.
  • The page that contains the form should use utf8 character coding.
  • If the account has several lists that can be subscribed, the value of a list's name field must be "join[]". If there is only one list to subscribe, the value can be "join".
  • Success_url and failure_url in order for the user to return to the site (Thank you page and failure page).

List subscribability

  • choose "Lists"
  • choose the list that you want to set as subscribable
  • choose "Can be subscribed to" and "Yes" from list information
  • press "Save"

A more advanced form where joining multiple lists can be chosen and "property" fields that can be saved.

<form action="http://customer.mailpv.net/account" method="post">
<input type="text" name="firstname" value=""> 
<input type="text" name="lastname" value="">  
<input type="text" name="email" value="">
<input type="checkbox" name="join[]" value="List id"> 
<input type="checkbox" name="join[]" value="List id"> 
<input type="submit" value="Submit">
  • List name or id in checkbox's value field
  • Using additional fields (such as "first name" and "last name") is possible when the necessary properties have been created for the subscribers in the system and subsequently the form element name corresponds tothe property in the system. The properties in the form element name are always written in lower case and words with many parts are written together with no special characters. For example, "Gender (Male / Female)" property would be put on the form in the following format: "< input type="radio" name="gendermalefemale" value="male" checked="checked" />". See below for instructions on creating properties:

Creating properties

  • choose "Settings"
  • choose "Preferences" tab
  • choose "New property"
  • give a name in the popup window that opens and press "New property". After this the property has been created and you can use it on the subscription form.

Form that directs the subscriber to a certain page

<form action="http://customer.mailpv.net/account" method="post">
<input type="hidden" name="success_url" value="http://thank-you-page">
<input type="hidden" name="failure_url" value="http://error-page">
<input type="text" name="sahkoposti" value="">
<input type="checkbox" name="join[]" value="12345"> 
<input type="submit" value="Submit">

Using AJAX request for the subscription function

Sending the subscription can also be done as an AJAX request. The request must be aimed at your own subscription page and the parameter "ajax" must be included. For example, http://customer.maillm.net/account/?ajax. Other properties' information can also be included in the request, such as first name, last name, age. But these must be included on the LianaMailer account.

Below is an example of of an AJAX request made with jQuery

$(function() {
    $('button.join').on('click', joinList);

    function joinList() {
        // subscription page url. Remember to add parameter 'ajax' in the end
        var url = 'http://customer.mailpv.net/account/?ajax', 
        post_data = {
            // email of the subscriber
            email: ’firstname.lastname@domain.com', 
            // Defining the property ’Firstname’
             firstname: ’Firstname’, 
            // List id where the subscriber is added to 
            join: 68,
            // Consent value if it is set on the subscription page
            consent: '123-1-en'

            url: url,
            method: 'POST',
            data: post_data,
            complete: function(data) {
                if (data.responseJSON.success) {
                    // request was successful
                else {
                    // request was not successful

<button class="join">Join</button>

AJAX request returns the information about subscription in JSON format and this enables giving the user a proper notification about the subscription.

The reply message's structure is the following

  • success => (Bool) true on successful subscription
  • error_key => Error code
  • error_msg => Error message

The following error codes could be included:

  • adding-recipient-failed => Adding subscriber failed
  • email-already-registered => Subsciber has already registered
  • email-cannot-be-null => Email address field cannot be empty
  • invalid-email => Faulty email address
  • member-limit-exceeded => The member limit of the account has exceeded
  • missing-registration-fields => Required subscription data is missing
  • must-select-list =>No list has been selected for the subscription

AJAX or the subscription form don't reveal who are already on the list. All email addresses that appear to be valid email addresses are accepted and added on the list.

Google reCAPTCHA
We recommend protecting your forms against robots that fill out forms. This can be done with Google's reCAPTCHA, for example, which enables distinguishing a robot and a real user without questions that the user often finds annoying.

Read Google's instructions on how to render the reCAPTCHA field here.

Ask our support for more info, if needed. 

Was this article helpful?

0 out of 0 found this helpful



Article is closed for comments.