Vai al contenuto
Home / Blog /In depth / Customer segments and automation: from a rule to an email, without extensions

Customer segments and automation: from a rule to an email, without extensions

Since 25.9 customers are grouped by behaviour rules, and since 25.11 those rules send email sequences with generated coupons.

Marketing on a store has one underlying problem: lists age the day after you export them. The customer who bought three times at Christmas sits in the same list as the one who filled a cart and walked away, and the same email reaches both. Segments solve the part that matters, meaning the definition: instead of a list, a rule that recalculates itself. Since 25.9 segments are in the core, and since 25.11 those rules can start email sequences with a coupon generated on the fly.

A segment is a rule, not a list

A segment is defined by conditions on the customer and on their behaviour, and it recalculates on a schedule. The conditions available cover everything the store knows:

  • personal details: name, email, group, registration date, gender, birthday;
  • address: country, region, city, postcode;
  • lifetime value, computed from orders and amounts;
  • newsletter subscription;
  • shopping cart: total, item count, created and updated dates;
  • cart items, with product, category, quantity and price;
  • orders: count, amount, status, payment and shipping method;
  • order items, meaning the product and the category bought;
  • products viewed and products in the wishlist;
  • combining several conditions, with nesting.

The last two are the ones that change the result. “Viewed this product at least three times and did not order” is a useful segment. “Viewed this product” is not.

📮 Note in the post: a segment that is too wide is not a segment, it is the whole customer base with a new name. If the counter hands you ninety percent of the subscribers, the condition is selecting nothing.

Building the first segment

Everything starts from Customers > Customer Segments > Add Segment. Fill in name, internal description, status, the websites the segment applies to and the refresh mode, automatic or manual. Then, on the Conditions tab, add conditions with the + button, choosing type, operator and value.

One choice worth making immediately: Refresh Mode set to Auto. With automatic refresh the segment recalculates once a day, by default at five in the morning, and the schedule is changed in customer/customer_segments/cron_schedule.

A manual refresh is not instant: it runs in the background through the queue, the segment moves to Pending, and when the work is done a message arrives in System > Notifications with the number of customers found. When something goes wrong the message carries the error. The queue retries when the problem is not in the data, such as a lost database connection.

One behaviour detail that saves pointless clicks: press Refresh while a refresh is waiting and Maho does not queue a second one; press it while a refresh is running and it queues one more after it, because the running one read the customers when it started.

📮 Note in the post: the difference between a segment and a hand written query is that the segment refreshes even when you are not thinking about it. If cron stops, it becomes a stale photograph again.

What it costs

Refresh times depend on how many customers the conditions have to evaluate. The module documentation gives clear orders of magnitude: under a thousand customers it is less than a second, between one and ten thousand it is one to five seconds, up to a hundred thousand it is half a minute, and beyond that a couple of minutes. A segment built on viewed products is heavier than one built on personal details, because it reads event tables.

The practical advice: few segments, tight conditions, and no urge to recalculate them all by hand every hour.

Where a segment gets used

The first use is the cart rule: in Promotions > Shopping Cart Price Rules you create or edit a rule and, on the conditions tab, add Customer Segment > Matches with the segments you want. From there the rest is normal: discount, free shipping, conditions on products.

This is where a segment stops being a report and becomes a commercial action: a discount reserved for one group, free shipping for a certain lifetime value, a category promotion for whoever already bought in that category.

Automation: enter and exit

Since 25.11 a segment can also send email. The edit page has two tabs, Enter Segment and Exit Segment, so the same segment can carry one sequence for whoever joins and one for whoever leaves. That is not a detail: “joined the abandoned cart segment” and “left because they bought” ask for two different messages.

In each tab you add steps with Add Email Step: pick the newsletter template, set the delay in minutes and, when needed, enable coupon generation by choosing the sales rule, the code prefix and the validity in days. Templates are created in Newsletter > Newsletter Templates and carry their own variables, such as the customer first name and the coupon details.

# email processing: every five minutes
*/5 * * * * /path/to/maho cron:run customersegmentation_process_emails

# or by relying on the main cron job
*/5 * * * * /path/to/maho cron:run

📮 Note in the post: the coupon generated on the fly is the part people open. A unique code per customer also tells you who used what, which a shared code will never tell you.

The five sequences that work

The module documentation proposes five, and they are the ones you see around because they work: abandoned cart recovery, a welcome series for a new customer, win-back for whoever has not bought in months, birthday greetings, and nurturing the high value customers.

They all share the same shape: a condition defining the moment, a short sequence, and an exit that stops everything when the customer does what you hoped.

📮 Note in the post: the most effective sequence is almost always the shortest one. The third reminder about the same cart does not recover the order, it convinces somebody to unsubscribe.

What to check before switching it on

  1. Cron is running: without cron segments do not refresh and emails do not leave.
  2. The segment is tight: read the counter after the first refresh, do not trust the rule.
  3. The sequence is short: two or three steps, with different delays.
  4. The coupon expires: a code without an expiry date stays around for years.
  5. The exit exists: whoever buys has to leave the sequence, otherwise the second email reaches somebody who is already satisfied and reads as if written by someone who is not watching.

Text prepared with the help of AI and checked against the source before publication. It can still contain mistakes: if you find one, report it.Read the manifesto

Does your store still sell?

Tell us where you are starting from: we reply with a first assessment, no strings attached.

Ask for the store assessment