Send Metadata

Metadata allows you to add additional information about users to session replays in the form of key-value pairs. This feature enhances your ability to filter and search session recordings, making it easier to identify relevant sessions. Refer to this tutorial for more details on how to send metadata.

Adding Metadata keys to a project

Section titled Adding Metadata keys to a project

To set up metadata keys:

  1. Navigate to Preferences > Metadata in OpenReplay.
  2. Choose the project to which you want to add metadata.
  3. Click Add Metadata.
  4. Enter the desired key name in the Field Name input.
  5. Click Add to save the metadata key.
Send Metadata

Limit: You can add up to 10 metadata keys per project.

Injecting Metadata into Session Replays

Section titled Injecting Metadata into Session Replays

Once your metadata keys are defined, you can send metadata when recording sessions. Below are the available implementation methods:

Inject metadata when starting the tracker:

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

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

If metadata is only available after the tracker starts, use the setMetadata method:

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

To include metadata with the snippet, modify the startOpts variable:

<!-- OpenReplay Tracking Code -->
<script>
  var initOpts = {
    projectKey: "project_key",
    defaultInputMode: 2,
    obscureTextNumbers: false,
    obscureTextEmails: true,
  };
  const yourMetadata = { yourKey: 'yourValue' };
  var startOpts = { userID: "", metadata: yourMetadata };
  (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>

If metadata becomes available later:

<script>
  OpenReplay.setMetadata("plan", "free");
</script>

Inject metadata in your iOS app:

import ORTracker

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

Filtering and searching sessions with Metadata

Section titled Filtering and searching sessions with Metadata

Metadata keys allow you to filter and search sessions in OpenReplay:

  1. Open the Omni-Search in the Sessions view.
  2. Select your metadata key (e.g., plan).
  3. Enter the metadata value (e.g., free) to filter session recordings.
Filter Metadata

This feature enables quick and precise identification of sessions based on user-specific details.

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