Filter out bots
How to filter out third-party bot data that may skew your experiment results in Optimizely Feature Experimentation.
Third-party bots can skew your experiment results by crawling your website and triggering events you only want to count for "real" visitors. Optimizely Feature Experimentation solves this by filtering out bots on the IAB/ABC blocklist. To block bots, include the user agent for an event when you send that event to Optimizely.
For information on how Optimizely filters bots, see Filter bots and spiders.
Note
Bot filtering does not apply to past bot events, so you should configure it before you start the experiment. Otherwise, if you enable filtering halfway through an experiment, you might have to discard (or export and manually filter) any bot-contaminated event data from the start of the experiment.
Enable bot filtering
To exclude bot traffic, first enable the feature in the UI. Then, when you track user events depending on which SDK you are using and where, you may need to send additional information. If you are using the JavaScript SDK client side, you are done. Otherwise, you must send the reserved $opt_user_agent
attribute containing the user agent to the user context. See the following sections for step-by-step instructions.
Enable bot filtering in the UI
First, go to Settings > Advanced > Bot Filtering in the Optimizely Feature Experimentation app to toggle bot filtering on or off.
Client-side JavaScript events
No additional JavaScript code is required to enable bot filtering for events sent from browsers. When you track an event by calling the JavaScript SDK's Track Event
method, the SDK automatically includes the user's user agent in the outbound request. If bot filtering is enabled for your project, Optimizely Feature Experimentation applies bot filtering automatically.
All other events
When you track events with an SDK from somewhere other than a web browser, you must pass the user agent to the user context to filter it with your event. You should pass it using the reserved $opt_user_agent
attribute in user-based methods. If bot filtering is enabled for your project and the user agent is passed this way, Optimizely Feature Experimentation applies bot filtering.
Important
Before implementing the
$opt_user_agent
attribute, Enable bot filtering in your Feature Experimentation project first.
The following code example shows how to pass the $opt_user_agent
attribute:
// Get the user agent and pass it to the Optimizely user context
// as the attribute $opt_user_agent
let user_agent = "this_could_be_a_bot"
let attributes = ["device" : "iphone",
"location" : "Chicago",
"$opt_user_agent" : "this_could_be_a_bot"]
user = optimizely.createUserContext(userId: "test-user-id", attributes: attributes)
// now any user-based call filters out the bot
let decision = user.decide(key: "flag_1")
try? user.trackEvent(eventKey: "my_purchase_event_key")
Updated about 1 month ago