Metadata

Additional information about users can be provided with metadata (also known as traits or user variables). They take the form of key/value pairs, and are useful for filtering and searching for specific session replays.

1. Explicitly specify the Metadata

Section titled 1. Explicitly specify the Metadata

Metadata must be explicitly specified from the dashboard from ‘Preferences > Metadata’. You can add up to 10 keys. In the below example, we use plan.

Add Metadata

2. Inject Metadata when recording sessions

Section titled 2. Inject Metadata when recording sessions

Once the key(s) added (in this example plan) then you can inject the metadata on tracker’ start in the form of a key/value pair (string).

Inject the metadata on tracker’ start (in this example plan).

const tracker = new OpenReplay({
  projectKey: PROJECT_KEY
});

tracker.start({
  userID: "john@doe.com",
  metadata: {
    balance: "10M",
    plan: "free"
  }
});

If that’s not possible (some or all metadata may be set/known only later in the navigation flow, so way after the tracker starts), then call the setMetadata method to do so:

tracker.setMetadata('plan', 'free'); // after tracker.start()

Below is an example on how to inject the metadata (in this example plan) using the snippet. Note the startOpts variable/line added, also the parameters change in the second line.

<!-- OpenReplay Tracking Code -->
<script>
var initOpts = { projectKey: "GxPpaDARdn2345fgt321" };
var startOpts = { userID: getUserID(), metadata: { plan: getPlan()} } // use startOpts variable to inject metadata
(function(A,s,a,y,e,r){
  r=window.OpenReplay=[e,r,y,[s-1, e]];
  s=document.createElement('script');s.src=A;s.async=!a;
  ...
})(0, "GxPpaDARdn2345fgt321", "//static.openreplay.com/3.5.0/openreplay.js",1,29);
</script>

If that’s not possible (metadata is known later in the navigation flow, so way after the tracker starts), then instead call the setMetadata method to identify your users. The identity of the user can be changed anytime during the session by calling setMetadata. However, OpenReplay will only keep the last injected user ID.

<!-- OpenReplay Tracking Code -->
<script>
var initOpts = { projectKey: "GxPpaDARdn2345fgt321" };
var startOpts = { userID: "" };
(function(A,s,a,y,e,r){
  r=window.OpenReplay=[e,r,y,[s-1, e]];
  s=document.createElement('script');s.src=A;s.async=!a;
  ...
})("//static.openreplay.com/latest/openreplay.js", 1, 0, initOpts, startOpts);
</script>
  ...
  OpenReplay.setMetadata("plan", "free"); // set metadata later in your code
  ...
import ORTracker

ORTracker.shared.setMetadata(key: String, value: String)

3. Search for Sessions Recordings using Metadata

Section titled 3. Search for Sessions Recordings using Metadata

Clicking on the omni-search bar will show you the list of available filters, including the metadata key(s) you added. You can now filter sessions recordings by any key/value.

Search using Metadata

4. See Metadata in Session Replay

Section titled 4. See Metadata in Session Replay

Metadata key/value pairs are displayed in the session replay page, in the user identification card. Sessions with similar metadata values can be found by clicking on the loop icon.

Metadata in Session Replay

If you have any questions about this process, feel free to reach out to us on our Slack channel.