Subscribe to Newsletter
How to implement a 'Subscribe to newsletter' feature and automate user group management for email-campaigns
When users sign up on a website, they can often choose to receive newsletters by checking a box during registration. This guide will walk you through a simple example of how to implement this feature using DynamicWeb. This guide assumes that you have some sort of Create a user-template. In case you don't, we recommend taking a look at the Extranet documentation first.
Here are the steps to creating a "subscribe to newsletter" functionality on your solution:
- Find the page, where you have your Create user Extranet app paragraph
- Open the paragraph settings and go to the App section
We need to update the template, to be able to render the "Newsletter" check box, in this example the code below is added to the template, but feel free to modify it to your liking:
<div class="form-group">
@{
var groups = GetLoop("SelectableGroups");
if (groups.Count > 0)
{
<div class="form-group">
<label class="col-sm-2 control-label">@Translate("Sign up for", "Sign up for")</label>
<div class="col-sm-10">
@foreach (var group in groups)
{
<input name="@group.GetValue("UserManagement:User.SelectableGroup.InputName")" type="checkbox" id="@group.GetValue("UserManagement:User.SelectableGroup.InputName")" value="@group.GetValue("UserManagement:User.SelectableGroup.Name")" />
<label for="@group.GetValue("UserManagement:User.SelectableGroup.InputName")"> @group.GetValue("UserManagement:User.SelectableGroup.Name")</label>
}
</div>
</div>
}
}
</div>
Before the changes are visible, we need to configure the Extranet app further.
- For "Groups for new users", select the group(s), new customers should always be added to, this could be the overall "Customers" group
- For "User selectable groups", select the group(s) you want new customers to be able to select, e.g. "Newsletters". Note, this group needs to be created beforehand in the Users-area
Now when users are signing up, they are always added to the customer-group and only added to the newsletter-group if they check that box.
With these changes, all customers who want to receive newsletters are grouped in a user group called "Newsletter". This allows us to easily target them when sending out newsletters by selecting them as "Recipient group". You can learn more about emails and how to use them here.