This article covers a Bloomreach Experience Manager version 13. There's an updated version available that covers our most recent release.

Visitor Data Filters

Introduction

Collectors collect the data that is used by scorers to calculate the characteristics of a visitor. Not all data collected by the collector will be relevant to the scorer of that data. To prevent irrelevant data from being stored and to keep the visitor data to a manageable size a scorer may implement an additional interface: TargetingDataFilter

/**
 * Allows request data collected by {@link Collector}s to be filtered before
 * the {@link TargetingData} is updated with it.
 *
 * @param <T>  the type of request data filtered by this class.
 */
public interface TargetingDataFilter <T> {

    /**
     * Determine whether the <code>requestData</code> is relevant or must be
     * filtered out.
     * If it is filtered out it will not become part of the {@link
     * TargetingData}.
     *
     * @param requestData  the request data that was collected
     * @return  {@code true} if this data must be filtered out {@code false}
     * otherwise.
     */
    public boolean filter(T requestData);

    /**
     * Get the type of {@link TargetingData} this class filters for.
     *
     * @return  the type of {@link TargetingData} this class filters for.
     */
    public Class<? extends TargetingData> getTargetingDataClass();

}

Multiple scorers can consume the same type of visitor data. For any one piece of request data, if any filter for the corresponding visitor data returns false from the filter method, the visitor data is updated with the request data.

As of version 13.0.0, make sure the TargetingDataFilter implementations end up in the CMS (platform) webapp (in previous version, they lived in the HST site webapp).

Example

An example of visitor data that is filtered by a scorer is the PageViewsTargetingData. Targeting currently provides one scorer that consumes such data: the PageViewsScorer. This scorer is used to determine whether a visitor has visited a certain page. The scorer is configured with the set of pages to match the visitor data against. If the visitor data contains the configured page, the scorer return a value of 1.0 to reflect that. This scorer also implements the TargetingDataFilter interface:

public class PageViewsScorer implements Scorer<PageViewsTargetingData>,
                                        TargetingDataFilter<String> {

...

    @Override
    public boolean filter(final String page) {
        return !configuredPages.contains(page);
    }

    @Override
    public Class<? extends TargetingData> getTargetingDataClass() {
        return PageViewsTargetingData.class;
    }
}

If the page views would not be filtered the visitor data would grow indefinitely and with every request.

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?