Power BI User Activity Tracker

The Power BI User Activity Tracker is a custom visual component designed to help you analyze how users interact with reports published in Power BI Online. This visual component sends usage information to an instance of Azure Application Insights, which needs to be configured beforehand.

To effectively use Power BI User Activity Tracker, you will need to modify the report to include specific measures based on the data you want to track. These measures should be text measures returning a single value.

Diagram

Review or download the visual from Microsoft

Current context of Power BI usage metrics

Power BI has different options for getting usage metrics:

But none of these options provide enough information to perform advanced usage analytics within a report. Power BI User Activity Tracker enhances this information and makes possible to calculate advanced usage metrics such as:

  • Total session duration
  • Number of filter interactions
  • Interactions by session
  • Bounce rate
  • Report visible in foreground session duration
  • Click-through rates
  • Etc.

You can see an example of Power BI User Activity Tracker data usage in this report: Link to example

Requirements

In order to configure Power BI User Activity Tracker you must have access to an existing Application Insights resource. You can also create a new Application Insights resource by following the steps in the link below.

Create an Application Insights resource

To configure Power BI User Activity Tracker you will need the connection string to your Application Insights resource.

Configuration

Setting up the model

Before utilizing Power BI User Activity Tracker, the report's model needs modification to include a few new measures based on the data to be tracked. Create measures for the following purposes.

Alternative measures can be created for different purposes.

User identification measures

Use DAX functions like USERNAME(), USERPRINCIPALNAME(), or USEROBJECTID() to create a measure that returns the current user. For example:

$USERNAME = USERNAME()

Filter tracking measures

Create measures for each filter you want to track. For example:

Measure1 = IF(ISFILTERED(TableName[FilterColumn]), CONCATENATEX(VALUES(TableName[FilterColumn]), TableName[FilterColumn], ","))

Adding Power BI User Activity Tracker to your report

You can get the Power BI User Activity Tracker visual from Microsoft's AppSource Marketplace (link ) or from Power BI Marketplace. Once installed, you should see the following icon on your Power BI visualizations panel.

The Power BI User Activity Tracker visual should be added to every report page you want to track usage for. Place Power BI User Activity Tracker anywhere on the page.

Adding data fields to Power BI User Activity Tracker

Once the desired tracking measures are created in the model, add them as fields to the Power BI User Activity Tracker visual.

Configuring Power BI User Activity Tracker settings

The Power BI User Activity Tracker offers various settings to customize usage tracking:

Property Required Description
Tracker Name No Optional identifier for the Power BI User Activity Tracker. Helps distinguish the source of log records and identify the report page. Example: Corporate Spend@IT Spend Trend. This value will be used as a name for the page view and custom event telemetry records. If a value isn't provided the tracker name will be the concatenation of the report Id and the section Id.
AccountId Measure Yes Measure name in the model returning the user name. This measure's value is used to set the authenticatedAccountId and accountId properties in Application Insights. Default value: $USERNAME
Measure Delimiter Yes Delimiter used to concatenate multiple values for a tracked measure. Default value: ,
Log to console If enabled, Power BI User Activity Tracker also sends log events to the browser's console.
Display info If enabled, the visual will display some debug information such as the report id, user name, fields, etc.
AppInsights connection Yes Application Insights connection string for collecting usage information. Example: InstrumentationKey=xxx;...
Heartbeat freq. (ms) Yes Time interval (in milliseconds) between Heartbeat events. Default value: 5000

Data collected

This section details the data elements collected and submitted to Application Insights. There are four different types of telemetry records captured by Power BI User Activity Tracker:

  • Page views
  • Custom events
  • Metrics
  • Trace messages

Page views

Table: pageViews

Whenever a user displays a new report page, a page view is logged with the following additional custom properties:

Property Description
duration Time in milliseconds since the Power BI User Activity Tracker visual was initialized until the first update event is invoked.
visualGuid Power BI User Activity Tracker GUID generating the entry.
visualVersion Power BI User Activity Tracker version generating the log entry.

It will also include default properties collected for this event type by Application Insights.

Custom events

Table: customEvents

As the user interacts with a report, a custom event will be logged every time the values for the tracked measures change. The name of the custom event will be a concatenation of the report ID, page ID, and the values of the tracked measures.

{reportId}@{sectionId}[?{measure1}=value1,value2...[&{measure2}=value3,value4...]]

Custom events may include the following properties:

Property Description
instanceId A unique GUID used to identify the session for a particular report page. Each visit to the same report page will produce a unique value for this property.
url The URL for the report, typically in the format: https://app.powerbi.com/groups/xxx/reports/xxx/ReportSection...
visualGuid Power BI User Activity Tracker GUID generating the entry.
visualVersion Power BI User Activity Tracker version generating the log entry.
userAgent Browser's user agent.
language Browser's language.
locale Power BI user's locale.
timezone Browser's default time zone.
hostMode Power BI hosting mode. Possible values: Online, Public, Desktop, Embedded, or Unknown
tenantId Power BI tenant ID.
groupId Power BI workspace ID where the report is located. This property can also have the value me to specify that the report is the user's workspace.
reportId Power BI report ID.
sectionId Power BI report page ID. In some cases the value default will be used to represent the first page of the report.
userName User identifier returned by the configured "user name" measure. See the "Configuration" section for more information.
screenResolution Browser's screen resolution.
eventType Type of trace message this record represents. Possible values are: Initialize, Update, Heartbeat or Destroy. For custom events this property will always have the value Update.
visibilityState Indicates if the browser's tab where the report is loaded was visible to the user when the event was produced.
editMode Power BI report edit mode. Possible values: Default or Advanced.
viewMode Power BI report view mode. Possible values: View, Edit, or InFocusEdit.
updateType Power BI report update type. Possible values: Data, Resize, ViewMode, Style, ResizeEnd, FormattingSubSelectionChange, FormatModeChange, or FilterOptionsChange. The same log record can contain multiple update type operations, in which case the value undefined will be used.
updateTypeArray In case event was the result of multiple update types, this array will contian all of all them.
operationKind Power BI operation type. Possible values: Create, Append, or Segment.
localTime Browser's local time.
trackMeasuresUpdated This will contain an array with the names of all the measures that have changed value since the previous user interaction.
trackMeasures This will contain an object with all the measures and their values, in the form of arrays, at the time the event was generated.

Metrics

Table: customMetrics

Power BI User Activity Tracker outputs several Application Insights metrics:

Name Description
totalDuration Milliseconds a user has had a report page open.
visibleDuration Milliseconds a report page has been visible to the user.
dataOperations Number of data operations triggered by user interactions.
trackedDataOperations Number of data operations where any of the tracked measures value changed.
tdo_<MeasureName> Number of data operations resulting in a change of value for a specific measure.

Trace messages

Table: traces

There are four types of trace messages that Power BI User Activity Tracker outputs:

Type Description
Initialize Logged when the report page is first initialized (once per page view).
Update Logged whenever the report updates due to data load, changed filters, report resize, etc.
Heartbeat Logged every X milliseconds while the report session is active.
Destroy Logged when the report is closed (usually not invoked by Power BI).

The type of trace message will be specified by the property eventType.

Trace messages may include the same properties than custom events, and will also include these measurements: totalDuration, visibleDuration, dataOperations, and trackedDataOperations.

Analyzing the usage data

Using Application Insights

You can do some usage analysis with the functionality that Application Insights provides. There are a few caveats:

  • A new session will be recorded in Applcation Insights every time the user navigates to a report page.
  • A new auto generated "User Id" will be created for each new session, to identify users use the authenticated users instead (fields "Account Id" and "Auth Id").
  • A page view will be recorded in Application Insights every time the user navigates to a report page. The name of the page view will be the value specified as the "Tracker Name" property.
  • A custom event will be recorded in Application Insights every time there is a change in the value of the monitored filters, after a user interaction. The name of the custom event will be the value specified for the "Tracker Name" property concatenated with the selected filters in a URL query string format: ?prop1=val1&prop2=val2...

For more information regarding usage analysis with Application Insights follow the link below:

NOTE: Application Insights will not analyze user sessions across different reports and report pages, in order to do that one must write custom Kusto queries against the Log Analytics workspace.

Writing custom Kusto queries (KQL)

Using your own Kusto queries against the data collected in the Log Analytics workspace enables one to performance more advanced usage analytics.

For instance, with the following Kusto query we are aggregating user sessions across report pages for an inactivity window of 30 minutes:

traces 
| where isnotempty(user_AccountId) and isnotempty(customDimensions.reportId)
| extend PartitionKey = strcat(user_AccountId, ":", customDimensions.reportId)
| partition hint.strategy=shuffle by PartitionKey
(
    order by timestamp asc
    | extend SessionIndex = row_cumsum(iff(timestamp - prev(timestamp) > 30m, 1, 0))
    | summarize arg_min(timestamp, session_Id)
        , AccountId = min(user_AccountId)
        , ReportId = toguid(min(tostring(customDimensions.reportId)))
        , SessionStart = min(timestamp)
        , SessionEnd = max(timestamp)
        , PageViewCount = count_distinct(session_Id)
        , TraceRecordCount = count()
        , TotalDuration = sum(toint(customDimensions.totalDuration))
        , VisibleDuration = sum(toint(customDimensions.visibleDuration))
        , DataOperations = sum(toint(customDimensions.dataOperations))
        , TrackedDataOperations = sum(toint(customDimensions.trackedDataOperations)) 
        by SessionIndex
    | extend PartitionKey, SessionDateDiff = datetime_diff('millisecond', SessionEnd, SessionStart)
    | project-reorder PartitionKey
)

For more information about how to write your own Kusto queries:

Creating a Power BI report

It would be very easy to build a Power BI report like the one below, by leveraging the results returned by Kusto query in the previous section: