Google is committed to advancing racial equity for Black communities. See how.

Monitor custom attributes

With Performance Monitoring, you can use attributes to segment performance data and focus on your app's performance in different real-world scenarios.

Performance Monitoring provides a variety of default attributes:

  • For iOS and Android apps, default attributes include app version, country, operating system information, device, radio, and carrier.

  • For web apps, default attributes include browser, country, effective connection type, page URL, service worker status, and visibility state.

In addition to these default attributes, you can also create custom attributes on your custom traces to segment data by categories specific to your app. For example, in a game, you can segment data by game level.

Collecting user data

Create custom attributes

You can use custom attributes on specific traces. You can then use custom attributes as filters for your performance data in the Firebase console.

To use custom attributes, add code to your app defining the attribute and applying it to a specific trace. You can set the custom attribute anytime between when the trace starts and when the trace stops.

Note the following:

  • You're limited to 5 custom attributes per trace.

  • Names for custom attributes must meet the following requirements: no leading or trailing whitespace, no leading underscore (_) character, and max length is 32 characters.


var trace = Performance.sharedInstance().trace(name:"myTrace")
trace.setValue("A", forAttribute: "experiment")

// Update scenario.
trace.setValue("B", forAttribute: "experiment")

// Reading scenario.
let experimentValue:String? = trace.valueForAttribute("experiment")

// Delete scenario.

// Read attributes.
let attributes:[String, String] = trace.attributes;


FIRTrace *trace = [[FIRPerformance sharedInstance] traceWithName:@"myTrace"];
[trace setValue:@"A" forAttribute:@"experiment"];

// Update scenario.
[trace setValue:@"B" forAttribute:@"experiment"];

// Reading scenario.
NSString *experimentValue = [trace valueForAttribute:@"experiment"];

// Delete scenario.
[trace removeAttribute:@"experiment"];

// Read attributes.
NSDictionary <NSString *, NSString *> *attributes = [trace attributes];


Trace trace = FirebasePerformance.getInstance().newTrace("test_trace");

// Update scenario.
trace.putAttribute("experiment", "A");

// Reading scenario.
String experimentValue = trace.getAttribute("experiment");

// Delete scenario.

// Read attributes.
Map<String, String> traceAttributes = trace.getAttributes();


val trace = FirebasePerformance.getInstance().newTrace("test_trace")

// Update scenario.
trace.putAttribute("experiment", "A")

// Reading scenario.
val experimentValue = trace.getAttribute("experiment")

// Delete scenario.

// Read attributes.
val traceAttributes = trace.attributes


const trace = performance.trace('test_trace');
trace.putAttribute('experiment', 'A');

// Update scenario
trace.putAttribute('experiment', 'B');

// Reading scenario
const experimentValue = trace.getAttribute('experiment');

// Delete scenario

// Read attributes
const traceAttributes = trace.getAttributes();

Monitor custom attributes

  1. In the Firebase console, go to the Performance dashboard.

  2. Click the Traces tab.

  3. Each of your custom attributes has a card showing performance data for that segment. You can also filter by custom attributes.