Campaign Manager
Send professional campaign messages to your subscribers.
Mail Tags
Plugins can add their own mail tags to the content editor. Add a registerMailCampaignTags method to the plugin registration file that returns an array of tags, keyed by the tag name.
| Option | Description |
|---|---|
| value | The value of the tag. A string, or a closure that returns a string. The closure receives the $tagData object, which includes the subscriber and message models. |
| preview | The value used when previewing the message. A string or a closure, like value. |
| description | A description shown as a tooltip in the tag legend of the content editor. |
public function registerMailCampaignTags()
{
return [
'occupation' => [
'value' => function ($tagData) {
return $tagData->subscriber->meta_data['occupation'] ?? '';
},
'preview' => 'Web Developer',
'description' => 'The subscriber occupation.',
],
'city' => [
'value' => function ($tagData) {
return $tagData->subscriber->meta_data['city'] ?? '';
},
'preview' => 'Milan',
'description' => 'The city where the subscriber lives.',
],
];
}
The tags are then used in the content as {occupation} and {city}.
Sharing Tag Data
When several tags need the same data, listen to the responsiv.campaign.extendTagdata event to load it once and add it to the $tagData object. The object is passed by reference, so include the ampersand (&) in front of the parameter.
public function boot()
{
Event::listen('responsiv.campaign.extendTagdata', function(&$tagData) {
if (!$tagData->subscriber || !$tagData->subscriber->email) {
return;
}
if ($user = User::where('email', $tagData->subscriber->email)->first()) {
$tagData->orders = $user->orders;
}
});
}
public function registerMailCampaignTags()
{
return [
'order_count' => [
'value' => function ($tagData) {
return (string) count($tagData->orders ?? []);
},
'preview' => '3',
'description' => 'The number of orders placed by the subscriber.',
],
];
}
Previous: Recipient Groups