Identify a User
Video Tutorial
Watch how to Identify users in your replays
If you don't like reading, you can follow this video tutorial showing you how to associate your replays to your users.
Associate your internal-user-id with the session being recorded by following the below steps.
With NPM
Section titled With NPMInject the userID on tracker’ start:
const tracker = new OpenReplay({
projectKey: PROJECT_KEY
});
tracker.start({
userID: "john@doe.com",
metadata: {
balance: "10M",
plan: "free"
}
});
If that’s not possible (userID is known later in the navigation flow, so way after the tracker starts), then call the setUserID
method to identify your users. The identity of the user can be changed anytime during the session by calling setUserID
. However, OpenReplay will only keep the last injected user ID.
tracker.setUserID('john@doe.com'); // after tracker.start()
With JavaScript snippet
Section titled With JavaScript snippetBelow is an example on how to inject the userID using the snippet. Note the startOpts
variable/line to inject the userID.
<!-- OpenReplay Tracking Code -->
<script>
var initOpts = { projectKey: "GxPpaDARdn2345fgt321" };
var startOpts = { userID: getUserID() }; // use startOpts variable to inject 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>
If that’s not possible (userID is known later in the navigation flow, so way after the tracker starts), then instead call the setUserID
method to identify your users. The identity of the user can be changed anytime during the session by calling setUserID
. 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.setUserID("john@doe.com"); // set the userID later in your code
...
With iOS app
Section titled With iOS appJust call setUserID(String)
at any point during your replay.
import ORTracker
// ... your code
ORTracker.shared.setUserID(_ userID: String)
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.