Version:

Events Filtering in JavaScript SDK

Filter events sent to downstream destinations using the JavaScript SDK.

This guide covers the following event filtering use cases:

Filter destinations while loading SDK

You can filter all events sent to web device mode destinations by passing an integrations object in the load API options. RudderStack then loads and sends events only to the allowed (and enabled) destinations.

info

The integrations object in the load API only controls the loading of the device mode destinations. The data is not propagated to the individual event payloads automatically.

To use the globally-defined integration options at the event level, set the useGlobalIntegrationsConfigInEvents option of the load API to true.

A sample snippet to send event data only to the Amplitude and Intercom destinations:

rudderanalytics.load(WRITE_KEY, DATA_PLANE_URL, {
    integrations: {
        All: false,
        "Amplitude": true,
        "Intercom": true
    }
});

Filter destinations at event level

You can control filtering a single event to the allowed (and enabled) destinations.

A sample track event instrumentation to send the event only to the Amplitude destination:

rudderanalytics.track(
    "Order Completed", {
        revenue: 30,
        currency: "USD",
        user_actual_id: 12345
    }, {
        integrations: {
            All: false,
            "Amplitude": true
        }
    }
);
warning

The destination name in the integrations object should match the name exactly as displayed in the RudderStack dashboard. It should not be the name that you assigned to the destination while setting it up in RudderStack.

You can also use the useGlobalIntegrationsConfigInEvents option of the load API to use the globally-defined integrations object (in the load API) at the event level if it is not present in the event.

info
The SDK gives precedence to the integrations object defined at the event level over the globally-defined integrations object.

Client-side event filtering

When you send events to a destination via web device mode, you can use the Client-side Events Filtering feature to configure the track events that should be discarded or allowed to flow through.


Questions? Contact us by email or on Slack