Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Removing or Updating Filter definitions with existing Segments


I have come across something that might be an unintended feature or bug.

I have created custom Filter Definitions using the Profile Store API. The customer has created some segments with these filters and then we discovered a bug in the KQL query the filter was using.  I resolved the query and then tried to remove or update the Filter Definition (using the DELETE or PUT options) but I received an error:
Profile Store API response: {"error":{"code":"409","message":"Filter definition cannot be altered because the following segments are defined by it: HM 3, HM 1","target":"","details":[]}}

Those segments were created by the editor, but produced no results and were archived by the user.  I know you cannot delete a segment.

So the problem is I want to update a Filter Definition, but the system won't let me because a segment exists even though those segments are archived.

Not sure if there is a way around this?  I could create a new Filter Definition, but this becomes very messy having redundant filters for the user to choose from in the UI.

Oct 28, 2020 17:48

This is the intended behavior. Changing filter definition may break any segment that already uses it and it's not easy to validate. That's why you can update the filter definition only if it is not referenced in any segment: 

Archived segments are still actionable, it may be used on your website or by some external tool, but you don't see archived segments in the list when creating a new or updating an existing visitor group. The fact that a segment doesn't include any profile doesn't mean that it is obsolete, it might be created for future purpose.

As a workaround, you can create a new proper filter definition, update segments to use the new filter, and then delete the old filter definition.

For the future, we would like to know your view on what is a good way to detect that a segment or filter definition can be deleted or updated, preferably safe, and not breaking for possible integrations?

Oct 29, 2020 19:15

Hi Dmytro,

If the segment is created by the user through InsightUI, you cannot update that segment with the profile API and that is the only way you can update it to use the new filter.  So I don't see how the old filter definition can be retired?

I believe if the segment is aware it is both "Not in use" and "Not available in visitor groups" then it could be Deleted by the user.

Oct 30, 2020 18:01

Hi @Dmytro a quick update on this.  I was able to use the REST API to replace (PUT) a Segment and remove the filter.  This allowed me to remove all references and then update the filter definitions.  I would still suggest an easier way to Remove old segments that are not used as this would simplify things further.

Nov 02, 2020 13:45

Ok, this is basically what I meant, you should be able to update any segment based on filter definition in Profile Store API, no matter if it was created by API or in UI.

I agree that it is a bit tricky, however, the reason is to ensure that developer doesn't break any existing integration. We will see how we can improve it.

Nov 02, 2020 15:45
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.