aw2.subscribe
Syntax
[aw2.subscribe main email=’[email protected]’ ] { Additional subscriber metadata is to passed as valid JSON object. } [/aw2.subscribe]
Description
This shortcode is used to subscribe to third-party newsletter service providers like MailChimp, GetResponse e.t.c.
To use aw2.subscribe shortcode parameters such as the API key, List-Id or List Name of third-party newsletter service are required so as communicate with them.
This shortcode does the heavy lifting for us to add the subscriber to the specified list of specified third party newsletter service provider. Furthermore, we can also add custom fields such as First Name, Last name, Phone no. e.t.c. along with subscriber email address to these Contacts.
Currently following third-party newsletter service providers are supported,
- MailChimp
- GetResponse
- ElasticEmail
Parameters
#main
(string) (required) The name of the third party newsletter service for which the user is to be subscribed.
Currently supports mailchimp, getresponse & elasticemail
(string) (Required) The email address which is to be added to the third party newsletter service.
#api_key
(string) (required) The API key which is to be used to communicate to the third party newsletter service.
#list_id (Mailchimp Parameter) | #campaign_id (GetResponse Parameter) | #list_name (Elastic Email parameter )
(string) (required) Used to specify the list to which the subscriber is to be added. If this parameter is not set [aw2.subscribe] looks for this parameter into the settings panel (under the hood into site options) of the specific third party newsletter service provider.
#public_account_id (Only Elastic Email parameter)
(string) (required)This Id is required for ElasticEmail API to work. Which is unlike other Email service providers. All the other API’s like MailChimp, GetResponse uses API key to work.
Usage
1)Adding a Subscriber to MailChimp:
a)Basic usage of [aw2.subscribe] shortcode with MailChimp
In the example below, we are getting an email address from a form submitted by the user to subscribe to MailChimp. The main parameter specifies the shortcode to add the subscriber to MailChimp.
[aw2.subscribe mailchimp email='{{aw2.get request.newsletter|meta|email}}' ] [/aw2.subscribe]
Code snippet 1: Basic usage of [aw2.subscribe] shortcode with MailChimp
The parameters api_key and list_id are required. If these parameters are not set in the [aw2.subscribe] , it will look into MailChimp settings Panel. If it’s not found even in Mailchimp Settings panel, the shortcode will return with error doing nothing.
b)Override parameters list_id and api_key set globally into settings panel
In the Code snippet 2 below, we have specified the list_id so that we can subscribe the user to some other list other than globally set list_id. Also, we can set API key which will override the default global API key set from the settings panel.
[aw2.subscribe mailchimp email='{{aw2.get request.newsletter|meta|email}}' list_id="f47302e65b" api_key="f47302e65b"] { "fname":"[aw2.get request.newsletter|meta|email /]" } [/aw2.subscribe]
Code snippet 2: Override parameters list_id and api_key set globally into settings panel
c)Passing extra metadata of subscriber to MailChimp:
[aw2.subscribe mailchimp email='{{aw2.get request.newsletter|meta|email}}' ] { "first_name":"[aw2.get request.newsletter|meta|first_name /]" [/aw2.subscribe]
2)Adding a Subscriber to GetResponse:
a)Basic usage of [aw2.subscribe] shortcode with GetResponse
The process is very similar for nearly every third-party newsletter service provider. In this case, the main parameter changes to “getresponse” as shown below,
[aw2.subscribe getresponse email='{{aw2.get request.newsletter|meta|email}}'] [/aw2.subscribe]
Code snippet 3: Basic usage of [aw2.subscribe] shortcode with GetResponse
The required parameters for the GetResponse API are campaing_id and api_key. Since these parameters are not passed in above syntax, [aw2.subscribe] will look if these parameters are set into settings panel (under the hood in the site options) and retrieve from it. If these parameters are not set in settings panel and are also not passed as shortcode parameters, this shortcode will return with error doing nothing.
b)Override parameters campaign_id and api_key set globally into settings panel
If we want to override the global api_key and campaign_id, which is set from the Settings Panel, pass these parameters to the shortcode as shown below
Note: In GetResponse the list_id parameter is called campaign_id.
[aw2.subscribe getresponse email='{{aw2.get request.newsletter|meta|email}}' campaign_id="insert_your_campaign_id" api_key="insert_your_api_key" ] [/aw2.subscribe]
Code snippet 4: Override parameters campaign_id and api_key set globally into settings panel
c)Passing extra metadata of subscriber to GetResponse:
To add extra metadata to a subscriber of GetResponse we have to first create the required metadata called as custom fields, in the GetResponse backend. After that, we can then pass the field name (in lowercase ) into the JSON data inside the [aw2.subscribe] shortcode as shown below,
[aw2.subscribe getresponse email='{{aw2.get request.newsletter|meta|email}}' ] { "first_name":"[aw2.get request.newsletter|meta|first_name /]", "city":"[aw2.get request.newsletter|meta|city /]", /* In built custom field of GetResponse */ } [/aw2.subscribe]
Code Snippet 5: Passing extra metadata of subscriber to GetResponse
Note: Getresponse has some built-in custom fields in the backend. If the custom field which needs to be captured is not available in the backend, only then new create custom fields.
For more a detailed tutorial on how to configure GetResponse to work with [aw2.subscribe] shortcode please visit GetResponse Tutorial
3)Adding a Subscriber to Elastic Email:
The process for Elastic Email is slightly different. In Elastic Email, Public Account Id is used to perform various actions such as adding a subscriber to the Elastic Email lists.
Also in other third-party newsletter service provider, we have to pass list_id as a parameter to [aw2.shortcode] . In Elastic Email, list_id is not available directly from the backend (It can be made available through an Extra API call) instead list_name is directly available in the backend hence we are using it.
a)Basic usage of [aw2.subscribe] shortcode with Elastic Email
In this case, the main parameter changes to “elasticemail ” as shown below.
[aw2.subscribe elasticemail email='{{aw2.get request.newsletter|meta|email}}'] [/aw2.subscribe]
Code snippet 6: Basic usage of [aw2.subscribe] shortcode with Elastic Email
b)Override parameters list_name, api_key and public_account_id set globally into settings panel
[aw2.subscribe getresponse email='{{aw2.get request.newsletter|meta|email}}' list_name="insert_your_list_name" api_key="insert_your_api_key" public_account_id="insert_your_public_account_id"] [/aw2.subscribe]
Code snippet 7: Override parameters campaign_id and api_key set globally into settings panel
c)Passing extra metadata of subscriber to ElasticEmail
Elastic Email gives us the ability to add extra metadata to a single contact. By default, it gives use following metadata to attach to contact
- title: Title of the Contact
- first_name: First name of the contact
- last_name: Last name of the contact
- phone: Phone no of the contact
- mobile_number: Mobile number of the contact
- notes: Notes if any of the contact
- gender: Gender of the contact
- birth_date: Birth date of the contact
- city: City in which the contact lives
- state: State in which the contact lives
- postal_code: postal code of the contact
- country: Country of the contact
- organization_name: Organization name in which the contact works or owns,
- website: Website of the contact
- annual_revenue: Annual revenue of the contact
- industry: Industry in which the contact works
- number_of_employees: Number of Employees of the company in which the contact works or owns
To add additional contact metadata, we can pass it as similar to inbuilt parameters, [aw2.shortcode] will internally handle it.
The syntax to add metadata of a contact use following syntax,
[aw2.subscribe elasticemail email='{{aw2.get request.newsletter|meta|email}}' elasticemail ] { "first_name":"[aw2.get request.newsletter|meta|first_name /]", "last_name":"[aw2.get request.newsletter|meta|last_name /]" "address":"[aw2.get request.newsletter|meta|address/]" } [/aw2.subscribe]
Code snippet 8: Passing extra metadata to subscriber of Elastic Email
As seen from above code snippet first_name and last_name is default metadata of the contact in Elastic Email and address is custom metadata that we want to store the information with the contact.
For more a detailed tutorial on how to configure Elastic Email to work with [aw2.subscribe] shortcode please visit Elastic Email Tutorial
Other shortcodes
Conditionals (7)
Core (11)
- aw2.run
- aw2.return
- aw2.template
- aw2.module
- aw2.raw
- aw2.get
- aw2.set_array
- aw2.set
- aw2.echo
- aw2.shortcode
- aw2.part
CRM (1)
Database (1)
Design & JavaScript (3)
- aw2.enqueue
- aw2.client
- aw2.spa
E-commerce (1)
Excelsheet (1)
- excel.write_bulk
Form Handling (3)
- aw2.sideload
- aw2.save_form
- aw2.upload
Mailing & SMS (3)
- aw2.subscribe
- aw2.sms
- aw2.wp_mail
PDF (1)
Utility (6)
- aw2.register
- aw2.register_handler
- aw2.reset_password
- aw2.login_handler
- app.restore
- app.backup
Latest Blogs
And there’s one thing I keep noticing: Everyone's obsessed with growth hacks.