This plugin provides flexible segmentation of subscribers when sending a campaign.
It allows you to filter the subscribers based on attribute values and subscriber data:
When the campaign is sent then only those subscribers who meet either any or all of the conditions will be selected.
The filtering of subscribers happens when phplist is actually sending the campaign. As phplist processes each subscriber it calls the plugin to decide whether or not to send to that subscriber. Therefore, when phplist starts to process a campaign it will appear that it is sending to the complete list because at that point it does not know which subscribers will be selected by the plugin.
To ensure that you understand this approach, you should send a test campaign to a small list to confirm that the correct subscribers are selected.
See the README file on the GitHub page https://github.com/bramley/phplist-plugin-segment for how to install and configure the plugin.
Please raise any questions or problems in the user forum https://discuss.phplist.org/
The text displayed by the plugin can be translated into other languages. See the file plugins/SegmentPlugin/lan/translations_en.php for the English version that can be used as the basis for another language. Each line in the file contains the English text then the equivalent text in the target language.
To create a new language file, copy translations_en.php to translations_xx.php, where xx is the language code, then change the texts for your target language. You can share your new language file by submitting it for inclusion in the plugin. Please create a topic in the user forum or an issue on GitHub.
The plugin adds a tab to the Send a campaign page on which you can create segment conditions to filter the subscribers who will receive the campaign.
You can choose whether subscribers must meet all conditions or any of the conditions. Then add one or more conditions:
Any number of conditions can be created but usually one or two should be sufficient. Then click the Calculate button to see how many subscribers will be selected when the campaign is actually sent.
The plugin calculates the number of subscribers using the lists chosen on the Lists tab. It selects only those subscribers who belong to the lists and who meet either any or all of the conditions. Also, it excludes unconfirmed or blacklisted subscribers, any subscribers who have already received the campaign, and subscribers who belong to excluded lists.
A warning will be displayed if there are any incomplete conditions, where the target value has not been selected.
The calculation provides an idea of the number of subscribers using the current data. When the campaign is actually sent the plugin selects the subscribers again. Therefore, if there have been new subscriptions, changes to attribute values etc. in the interim, then the number of subscribers actually selected can differ.
When the “after interval” operator is used for the Entered date or a date attribute, the calculation will include subscribers who meet the condition for the current day. That will be accurate if the campaign is sent on the same day, but the actual subscribers selected will definitely be different if the campaign is sent on a later day. Still, it is useful to see the number of subscribers for the current day in order to be confident of the calculation's accuracy.
To see the email addresses of the subscribers, you can run the query used by the plugin in phpmyadmin. To enable logging of plugin database queries see https://resources.phplist.com/plugin/common#logging_database_queries
If you find the query for the number of subscribers then you will need to change
COUNT(DISTINCT u.id) AS t
in order to see the email addresses.
|Field / Attribute type||Entering the target value|
|textline, textarea, hidden attributes, email address, subscriber id and unique id||Entered directly in the text field.|
|select, radio button attributes||Selected from the multi-select list box.|
|Entered date and date attributes||A date is selected using the date-picker control.
An interval is entered directly in the text field and can be a number of days, weeks, months, quarters or years. For example
|checkbox attributes||These do not have target values.|
|checkboxgroup attributes||Selected from the multi-select list box.|
|campaign activity||A prior campaign is selected from the drop-down list. The list contains only campaigns sent to the lists selected on the Lists tab.|
The target values for select, radio button, and checkbox group attributes are presented as a multi-select list. When target values have not yet been chosen then the list will be displayed similarly to this
To show the list of values you need to click the area
Then you can select one or more target values, after which they will be displayed similarly to this
|Operator||How the condition is evaluated|
|“is” and “is not”||The attribute value is compared directly with the target value.|
|“is blank” and “is not blank”||The attribute value is compared directly with an empty string.|
|“matches” and “does not match”||These operators use the mysql LIKE operator. This means that you need to include % or _ characters (sql wildcard characters) as necessary. See the mysql reference manual for guidance on using the LIKE operator.
As an example, to match email addresses on the gmail.com domain the target value should be
|“REGEXP” and “not REGEXP”||These operators use the mysql REGEXP operator. See the mysql reference manual for guidance on using regular expressions in mysql.
As an example, to match email addresses on the gmail.com or yahoo.co.uk domains the target value should be
Or to select an arbitrary 20% of subscribers using the subscriber id field the target value could be
|“is before” and “is after”||These operators compare the date part of the Entered date or attribute date with the target date, and test for being less than and greater than respectively.
Note that if you want to match subscribers who have subscribed since, and including, 1 January 2014 then the target date will need to be 31 December 2013 in order to include 1 January.
|“is between”||This operator compares the date part of the Entered date or attribute date with two target dates, and tests for it being greater than or equal to the first value, and less than or equal to the second value.|
|“after interval”||This operator tests whether the current date is equal to the Entered date or date attribute plus the target interval.
It uses the mysql DATE_ADD function, see the mysql reference manual for information. The target interval can be only a number of days, weeks, months, quarters or years.
For example, using the Entered date and a value of
The target value can be negative. This is useful only when a date attribute has a value in the future, and the plugin will select subscribers in advance of the date.
As another example, using a date attribute and a value of
|“is checked” and “is not checked”||These operators test whether the checkbox attribute is checked or not.|
|“one checked”, “all checked”, “none checked”||For a checkbox group these operators test whether the attribute value has at least one, all of, or none of the target values set.|
|“is one of”, “is none of”||For a select list or set of radio buttons the operators test whether the attribute value is one of, or none of, the target values.|
|“was sent”, “was not sent”||These operators test whether a subscriber was sent an earlier campaign.|
|“opened”, “did not open”||These operators test whether a subscriber was sent an earlier campaign and, respectively, opened or did not open the email.|
|“clicked”, “did not click”||These operators test whether a subscriber clicked any link, or did not click any link in an earlier campaign.|
The way that the plugin handles empty or missing attribute values varies slightly for each type of attribute and its operators.
|Attribute type||Missing, null or empty value|
|textline, textarea, hidden||Treated as an empty string. So, for example, the operator 'empty' will be true, and the operator 'not empty' will be false.|
|select, radio button||Treated as select list index of 0. So, for example, the operator 'is one of' will be false, and the operator 'is none of' will be true.|
|checkbox||Treated as being unchecked. So the operator 'checked' will be false.|
|checkboxgroup||Treated as all being unchecked. So the operators 'one checked' and 'all checked' will be false.|
|date||Values are ignored. So subscribers with these values will not be selected for any operator, 'is', 'is after', 'is before', or 'is between'.|
The current set of conditions can be saved for later use. Enter a name for the segment and click the Save segment button. If the segment name already exists then it will be replaced.
Saved segments appear in a drop-down list, from which one or more can be selected. When selected the conditions will be added to any current conditions.
A saved segment that is not needed any longer can be removed by editing a value on the Settings page within the Segmentation settings group. The field “Summary of saved segments” lists all of the saved segments. To remove a segment edit the field and delete the complete line.
You can use the plugin to create a simple autoresponder for a date attribute by using the “after interval” operator to select subscribers whose attribute value is the specified number of days before the current date.
On the Schedule tab set the campaign to requeue every day and set the embargo time to be the time of day that you want it to be sent.
Use a cron job that runs at least once a day just after the embargo time to process the queue.
The plugin adds a Segmentation group to the Settings page where you can enter:
See the GitHub page https://github.com/bramley/phplist-plugin-segment