Filtering for / out vars in a data feed for multiple vars when you need "AND" matching

When creating a Content data feed, you have the option of filtering for or filtering our vars (these are the custom meta tags you may be passing on your content; they appear as "vars" in the data feed).

However, these filtering sections do a match for content that has ANY of the vars set. There currently is no drop down option to select and/any matching for any or all of the vars. If you have the use case where you need to filter for key-value #1 AND key-value #2, you would need to apply a workaround. 

Below are a couple of options that may work for you. 


Workaround 1: Consider using combination of filter for / filter out var

Take for example you have the vars:

domain = TM or TMP
landing:page = true

If you set the filter for vars to "domain" : "TM" and "landing:page" : "true" you can still get content that contains "domain" : "TMP" if the var "landing:page" : "true" is set on the content. With the ANY matching, content with "domain" : "TMP" AND "landing:page" : "true" meets the criteria for "filter for "landing:page" : "true". Content must have at least one of the filter for vars to satisfy the criteria. 

The workaround here would be to filter for "domain" : "TM" and "landing:page" : "true", and filter out "domain" : "TMP".


Workaround 2: Filter for a var in the feed, add further filtering on the template-level with Zephyr

The above use case can work for a simple scenario where the key doesn't have a wide range values. In the above example, "domain" can either be "TM" or "TMP", so it's easy to filter out the value you do not want included. However, there may be other use cases where the above does not work as smoothly. You can consider to filter for a var on the feed level, then apply further filtering on the template/campaign-level with Zephyr.

One common and easy solution here would be to set up the data feed to filter for one of the custom var (example: "landing:page" : "true") to only find content that has this custom var set. This var is the simplest var to start with because it can only be two values: true or false.

Then on the template level use the filter or filter_content (the newer filter function that works with pinning) function to filter the feed for only content that has the other custom var (example: "domain" : "TM").

For example:

{filteredContent = filter(content, lambda c: !contains(c.vars.domain,'TMP'))

In the above code, you are filtering the data feed for all content that does not have a var with "TMP". This filtered version of the feed will not be referenced with "filteredContent".

Please see a list of all the functions available: