Postcode based targeted email marketing for events using Mautic

Mautic, Open Source marketing software, can be used to send targeted emails about events to people on your mailing list who live within a radius of that event.

For example, my partner and I attend vegan fairs all over the country and like to invite our customers to attend: they can buy postage free, access special offers and of course we get to put a face to a name.

The best thing about this process is the lists will always be up to date when you need them: each new contact you get who lives in the specified radius will be added to the list. Next time an event is in the same area you have a list ready and waiting.

Here’s how it’s done.


  • You need the postcode of your event
  • You need the postcodes of those on your email lists
  • You need mautic installed and working

Get the postcode data

Find the postcode of your event, for example, we are attending the Glasgow Vegan Festival at the Trades Hall Of Glasgow, G1 1UH.

example of events on the Ethical Pets blog

Use a postcode radius tool to get a list of all the postcodes within a radius of the venue. I used and set the radius, in this case, at 60 miles.

create postcode list in freemaptools

Clean up data

For the sake of simplicity, we will only use the first two letters of the postcode – while this will widen the area somewhat, it’s much quicker to set up in Mautic. It’s the difference between adding hundreds of filters to a list, or just a handful.

Remove extraneous data

The list of postcodes produce looks like this: DG10,93.50,58.10 so we need to remove the one or two numbers after the letters, plus the coordinates after that.

To do this I used find and replace with various regex strings in a text editor. For detailed instructions, you can read more about this kind of process here.

find and replace regex

You can run replace [0-9] with blank and then replace ,.,. with blank, it’s the quickest way, but I did things the long way round to allow me to be sure I wasn’t removing things inadvertently.

I ran:

  1. ,[0-9][0-9].[0-9][0-9],[0-9][0-9].[0-9][0-9] replace with blank
  2. ,[0-9][0-9].[0-9][0-9],[0-9].[0-9][0-9] replace with blank
  3. ,[0-9].[0-9][0-9],[0-9].[0-9][0-9] replace with blank
  4. and finally [0-9] replace with blank**

** before you do step 4, just check there are no single letter postcodes in your list – these are like G83. These need to be dealt with separately. If you have them, continue as directed, but there will be an extra step at the end.

Now, our list looks like this:

EH etc.

Each letter string is replicated many times. We want to condense that,  LibreOffice is best for this – I used a filter to remove the duplicates. You can read a detailed example here.

At this point, if you have single letter postcodes like G38 you will end up with a single letter like G in the list. These need to be added in a different way. This is because G is the start of many other post codes in the UK, like GU, which are not in the same area as G. More on this later…

Set up the segment in mautic

Create your list with a clear name for future use, for example, I called mine “Glasgow postcode list” and added a description, As these lists are designed to be used many times, it’s important to document them.

creating a segement in mautic

Next, on the Filters tab, add the filter Zip Code

TIP: make sure to choose Zip code contact (little guy icon) not zip code business (building icon)

Then select Starts with from the dropdown

TIP: Rather than scrolling down the list each time, you can hit the s key then hit enter and it will select Starts with.

zipcode starts with filter in mautic

Add all the two letter codes, with or as the separator (rather than and).

postcode filters in mautic segement starts with

Finally, if you have single letter postcodes, these need to be added with letter-first-number. Like G1, G2, G3 etc.

G1 - G10 postcode filters mautic

Check all is correct

It’s worth taking a few moments to check that

  • All the fields are contact zip (little person icon) not company zip (building icon)
  • All are set as or not and (and will be indented)
  • All are starts with not anything else

When you have checked, Save the segment and wait for it to fill up (this depends on your cron schedule).

Leave a Reply

Your email address will not be published. Required fields are marked *