Optimizely will be sunsetting Full Stack Experimentation on July 29, 2024. See the recommended Feature Experimentation migration timeline and documentation.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySumbit a ticketLog In
GitHubNuGetDev CommunitySumbit a ticket

Pass in audience attributes

This topic describes possible user attribute values you can send to Optimizely through the Optimizely Python SDK.

You can pass strings, Booleans, integers, floating point values, and None as user attribute values. If you want to target audiences based on the version of your application that they are using, you can also pass in a string formatted as a semantic version, then define a version audience condition in the Optimizely app. The examples below show how to pass in attributes.

attributes = {
  'device': 'iPhone',
  'lifetime': 24738388,
  'is_logged_in': True,
  'app_version': "4.3.0-beta",
}

enabled = optimizely_client.is_feature_enabled('new_feature', 'user123', attributes)

🚧

Important

During audience evaluation, note that if you do not pass a valid attribute value for a given audience condition—for example, if you pass a string when the audience condition requires a Boolean, or if you simply forget to pass a value—then that condition will be skipped. The SDK logs will include warnings when this occurs.