Overview

The Usage Attribution page provides information and functionality related to data usage and usage types. By default, the data usage can be viewed and filtered by broader categories such as product, organization, or tag keys. This guide describes how to configure RUM usage attribution so it can be viewed by custom categories on the Usage Attribution page (accurate to +/- 20% of the actual value). This can help you track RUM sessions and costs for different departments, products, or other categories, instead of viewing a single aggregate number.

As an example, this guide walks through how to track RUM usage by department.

Set up RUM usage attribution

Check your tags

Categories for usage are determined by tags. Before setting up your RUM usage attribution, make sure that the tags you want to use are configured on the Usage Attribution page. Click Edit tags, then select the tags that you want to use to view usage and click Save. In this example, we’ve added “department” as a tag.

Check your tags on the Usage Attribution page

Add tags to your RUM sessions

Once your usage attribution tags have been configured, you can tag your RUM sessions with them.

To set tags for browser sessions, set the RUM global context at the start of the session (right after calling datadogRum.init) using the setGlobalContextProperty method. For example, here’s how we would tag sessions so they can be tracked for the marketing department:

datadogRum.setGlobalContextProperty('department', 'marketing');

To set tags for mobile sessions, use the addAttribute method. Here’s an example:

//Android
GlobalRumMonitor.get().addAttribute("department", "marketing")

//iOS
RumMonitor.shared().addAttribute(forKey: "department", value: "marketing")

Note: A few tags are included by default (service, env, version, application.id, and application.name). For anything else, set the global context using the method above.

Once you’ve deployed this step, new RUM sessions are tracked according to the tags you added.

View RUM usage

The newly tagged sessions are displayed on the Usage Attribution page. When you review the RUM with Session Replay Sessions and RUM Sessions columns, you can see the number of sessions by department.

View RUM usage by department

Usage information is also available through the GetHourlyUsageAttribution endpoint.

Further reading

Additional helpful documentation, links, and articles: