# Segment filter not working correctly

**URL:** <https://forum.mautic.org/t/segment-filter-not-working-correctly/23446>\
**Category:** Product Support\
**Created:** [April 1, 2022, 5:47am UTC](https://forum.mautic.org/t/segment-filter-not-working-correctly/23446 "2022-04-01T05:47:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gathh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gathh/32/6515_2.png) [@gathh](https://forum.mautic.org/u/gathh)\
**Post date:** [April 1, 2022, 5:47am UTC](https://forum.mautic.org/t/segment-filter-not-working-correctly/23446/1 "2022-04-01T05:47:39Z")

</div>

**Your software**  
My Mautic version is: 4.1.2  
My PHP version is: 7.4

**Your problem**  
My problem is:  
I have setup the following filter for a dynamic segment:  
Visited URL contains vietnam  
AND  
Visited URL count is greater than or equal to 5

My logic says that anyone who has visited a URL with the word ‘vietnam’ in it more than 5 times should be added to this segment.

What is actually happening is that anyone who visited any URL more than 5 times is being added to the segment, regardless of it being ‘vietnam’ or not.

Why is this happening and how can I fix it so that it only adds those who visited a URL with ‘vietnam’ more than 5 times.

 ![1648790885454](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/9/92331cd1431d5d745b463001a0bbde19b4c46615.jpeg)

Thank you for any pointers.

---

<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:** [April 1, 2022, 5:49am UTC](https://forum.mautic.org/t/segment-filter-not-working-correctly/23446/2 "2022-04-01T05:49:07Z")

</div>

Hi, this is not what the filter does.  
This is what you set up:  
**Visited URL that contains ‘vietnam’ AND visited ANY page at least 5 times.**

And I agree with you it should work as you expected, but this is not how it’s coded.

---

<div class="post-metadata">

**Author:** ![gathh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gathh/32/6515_2.png) [@gathh](https://forum.mautic.org/u/gathh)\
**Post date:** [April 1, 2022, 5:51am UTC](https://forum.mautic.org/t/segment-filter-not-working-correctly/23446/3 "2022-04-01T05:51:12Z")

</div>

Thanks for your super quick response.  
Do you know if there any way to achieve what I’d like to do?

---

<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:** [April 1, 2022, 5:52am UTC](https://forum.mautic.org/t/segment-filter-not-working-correctly/23446/4 "2022-04-01T05:52:49Z")

</div>

Not in segments. You can use the sql conditions plugin, and have a campaign step that checks “5 visits for vietnam?” - if yes do this, if no, do that.  
But it1s cumbersome.

> **[GitHub - mtcextendee/mautic-sql-conditions-bundle: Custom SQL condition for...](https://github.com/mtcextendee/mautic-sql-conditions-bundle)**
>
> Custom SQL condition for campaigns. Contribute to mtcextendee/mautic-sql-conditions-bundle development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![gathh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gathh/32/6515_2.png) [@gathh](https://forum.mautic.org/u/gathh)\
**Post date:** [April 1, 2022, 6:07am UTC](https://forum.mautic.org/t/segment-filter-not-working-correctly/23446/5 "2022-04-01T06:07:34Z")

</div>

Thank you, I will give it a look.
