# What is the best way to create a campaign with custom fields and tags data split by segments?

**URL:** <https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [March 18, 2022, 9:36am UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116 "2022-03-18T09:36:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 18, 2022, 9:36am UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/1 "2022-03-18T09:36:19Z")

</div>

**Your software**  
My Mautic version is: 4.1.2  
My PHP version is: PHP Version 7.4.28  
My Database type and version is: 10.3.34-MariaDB

**Your problem**  
My problem is:

Hello hello everyone!

We manage a community that runs several events, such as Startup Grind Lisbon, Coworking Thursdays, and others. For each event, we have a tick box “would you like to receive news from 351 community” and for the ones who ticks yes, we want [to send this email](https://crm.351.community/mautic/email/view/622e7f850fb8c342505302) and add " you are receiving this email as when you signed up for XXXXXX (event they signed up), you asked to receive news from us.

From your experience, what would be the best way to import and structure that campaing on Mautic? (I also want to track from which event they come, and if they join other kind of event from us, to don’t send twice the email)

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [March 18, 2022, 12:06pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/2 "2022-03-18T12:06:26Z")

</div>

So you want to give the ability to your contacts to save their interest and get content based on that?  
(maybe separate newlsletter?)  
Like a preference center where you can choose interest and subscribe / unsubscribe basically?

Joey

---

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 18, 2022, 3:17pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/3 "2022-03-18T15:17:09Z")

</div>

> [@joeyk](#):
>
> (maybe separate newlsletter?)

Hi Joek!

Thanks very much for your reply!

Yes, it is more or less it!! I would love to do something like this:

1. Participant join one of our events (creativemornings, startupgrind, Coworking Thursdays, etc)

2. If it is their first time in any of our events, they receive [the welcome newsletter,](https://crm.351.community/mautic/email/view/622e7f850fb8c342505302). That newsletter will state that they receive that email because they have joined that specific event

3. I want to be able to email them in many ways:

4. I also want to lead score people, on how many events they are attending

What do you think it could be the best set up for this?

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [March 23, 2022, 2:09pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/4 "2022-03-23T14:09:33Z")

</div>

Hi,  
I’ve got a new video on how to create an interest based preference center.  
It’s a long step by step tutorial. Enjoy.

[![](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/c/c3e6e32e287c4196495054b6c1d7eef3763fc5f0.jpeg "The one with the Multi-Topic preference center") ](https://www.youtube.com/watch?v=vHpto9lgNig)

Joey

---

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 23, 2022, 4:06pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/5 "2022-03-23T16:06:53Z")

</div>

Thanks very much Joey!

Does it work same way if I import a contact instead of feeling a form?

Regards.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [March 23, 2022, 4:22pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/6 "2022-03-23T16:22:21Z")

</div>

You can import these values via CSV or FORM as well.

---

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 23, 2022, 5:07pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/7 "2022-03-23T17:07:27Z")

</div>

Cheers my man, you rock !

I will pass on for my team, if they got questions I will let you know ((:

---

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 26, 2022, 10:11pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/8 "2022-03-26T22:11:16Z")

</div>

Hi @joeyk !

A quick question:

Let’s say I got a contact with the custom field “events:” and a value “Coworking Thrusdays”.

Once I am importing contacts, let’s say the same contact went to “Startup Grind”. When importing, does it overwrite the previous field or it just add on the top?

Regards

---

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 26, 2022, 11:56pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/9 "2022-03-26T23:56:19Z")

</div>

I guess what I really would like to ask is how can I lead score based on events.

I will impoort the contacts over every event we have it, and I would like to keep the track on what events they came, and also add some points for the ones who are attending it, but mautic got no “events” under “channels”, would you suggest any workaround?

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [March 28, 2022, 9:54am UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/10 "2022-03-28T09:54:56Z")

</div>

Hi, maybe @mzagmajster can answer that.

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [March 28, 2022, 1:53pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/11 "2022-03-28T13:53:34Z")

</div>

Hi @fernando_jardim ,

first if you import multiple times the value of multiple select field will get overriden or ignored if the contact exists and you do not give the permission to override.

there are several ways to go about this, I will assume you are after the one the requires the least technical knowledge.

Create fields on contacts:

- events - multiple select - - contains list of all events and you select only the ones contact has attended
- firstevent - string value of the event contact has attended first
- lastevent - string - same as first event only for the last event
- eventpoints - new points for the event - you specify how much points lead is getting because he/she attended some event

when you are importing contacts for specific event in csv you only specify first and last event and eventpoints and allow field override in import settings.

Once you have that structure and data in the database all you need to do is add extra cronjob that runs query like so: (not tested):

```auto
/usr/bin/mysql -e "UPDATE leads SET events = CONCAT(events, '|', lastevent), points = (points + eventpoints), eventpoints = NULL WHERE eventpoints IS NOT NULL; ";

```

What the above query is doing, is saying OK add last event the lead has been on to the list of all events user has been on add event points to overall lead score.

Even though we have a cronjobs here I think this is the easiest way to achieve what you are asking.

The more proper way of doing this would be to create a custom plugin with lead pre save event listener that checks these fields and adds points.

The most proper way (which I suspect is an overkill in your situation - although I might be wrong) is to extend Point actions and trigger the custom event action on import.

If you do decide to go with a custom plugin, here is the boilerplate I use: [GitHub - mzagmajster/plugin-helloworld: Hello World plugin built on the Integration framework](https://github.com/mzagmajster/plugin-helloworld)

Using the above you only need to add one event listener to LeadEvents::LEAD\_PRE\_SAVE event and do what I have done above with SQL query.

When you have the fields as the above I think you can easily use the segments to get:

- leads with specific first/last event
- all events the user has attended.

---

<div class="post-metadata">

**Author:** ![fernando\_jardim](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fernando_jardim/32/7099_2.png) [@fernando\_jardim](https://forum.mautic.org/u/fernando_jardim)\
**Post date:** [March 28, 2022, 2:25pm UTC](https://forum.mautic.org/t/what-is-the-best-way-to-create-a-campaign-with-custom-fields-and-tags-data-split-by-segments/23116/12 "2022-03-28T14:25:24Z")

</div>

Super thanks @mzagmajster !!  
I wil test it out and come back to you soon :DDD
