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 projectTo set up metadata keys:
- Navigate to Preferences > Metadata in OpenReplay.
- Choose the project to which you want to add metadata.
- Click Add Metadata.
- Enter the desired key name in the Field Name input.
- Click Add to save the metadata key.
Limit: You can add up to 10 metadata keys per project.
Injecting Metadata into Session Replays
Section titled Injecting Metadata into Session ReplaysOnce your metadata keys are defined, you can send metadata when recording sessions. Below are the available implementation methods:
1. Using NPM
Section titled 1. Using NPMInject 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()
2. Using JavaScript Snippet
Section titled 2. Using JavaScript SnippetTo 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>
3. Using iOS SDK
Section titled 3. Using iOS SDKInject 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 MetadataMetadata keys allow you to filter and search sessions in OpenReplay:
- Open the Omni-Search in the Sessions view.
- Select your metadata key (e.g.,
plan
). - Enter the metadata value (e.g.,
free
) to filter session recordings.
This feature enables quick and precise identification of sessions based on user-specific details.
Have questions?
Section titled Have questions?If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.