Audiences

Audiences allow you to target specific users based on various conditions. You can create and manage audiences through the organization sidebar by navigating to Audiences > Create Audience.

Available Audience Types

Custom JS

Custom JS audiences allow you to write JavaScript code that returns a boolean value. The code will be evaluated in the browser context, and the user will be included in the audience if the code returns true.

Example:

// Returns true if the user's viewport is wider than 1024px
window.innerWidth > 1024

Cookie

Cookie audiences let you target users based on browser cookies. You can check for:

  • Cookie existence
  • Specific cookie values
  • Numeric comparisons

Supported comparisons:

  • any: Cookie exists with any value
  • eq: Cookie equals specific value
  • neq: Cookie does not equal specific value
  • gt: Cookie value greater than
  • gte: Cookie value greater than or equal to
  • lt: Cookie value less than
  • lte: Cookie value less than or equal to

Locale

Locale audiences target users based on their browser’s language settings. You can specify one or more locale codes (e.g., “en-US”, “es”, “fr”) to match against the user’s navigator.language value.

Device Type

Device Type audiences allow you to target users based on their device’s user agent string. You can specify keywords to match against the user agent (e.g., “Mobile”, “iPhone”, “Android”).

Query Parameters

Query Parameter audiences target users based on URL query parameters. You can specify parameter name-value pairs that must match exactly for the user to be included in the audience.

Example: Matching ?version=beta

  • Parameter: “version”
  • Value: “beta”

Combining Conditions

When creating an audience with multiple conditions, you can combine them using either:

  • OR logic: User matches if any condition is true
  • AND logic: User matches if all conditions are true

Best Practices

  1. Always test your audiences with various user scenarios
  2. Use meaningful names and descriptions for your audiences
  3. For Custom JS audiences, keep the code simple and focused
  4. Consider performance impact when using multiple conditions
  5. Verify cookie names and values when using cookie conditions