How to integrate Stackdriver with OpenReplay and see backend errors alongside session recordings.

1. Create Google Cloud Service Account

Section titled 1. Create Google Cloud Service Account
  1. In the GCP Console, go to the Create Service Account Key page.
  2. From the Service account list, select New Service Account.
  3. In the Service account name field, enter “openreplay-stackdriver”.
  4. From the Role list, add Logging > Logs Viewer and Stackdriver > Stackdriver Accounts Viewer.
  5. Click Create to download the JSON file that contains your key.

2. Enable Stackdriver in OpenReplay

Section titled 2. Enable Stackdriver in OpenReplay

Paste your Log Name and openreplay-stackdriver credentials in OpenReplay dashboard under ‘Preferences > Integration’.

Stackdriver Integration in OpenReplay

3. Propagate openReplaySessionToken

Section titled 3. Propagate openReplaySessionToken

To link a Stackdriver event with the recorded user session, a unique token has to be propagated from your frontend to your backend on each request you want to track. This can be done using a custom HTTP header. In the below example, we use the fetch function to send that header.

const headers = {
  Accept: 'application/json',
  'Content-Type': 'application/json',
if (tracker.getSessionToken()) { // or window.OpenReplay instead of tracker if you're using the snippet
  headers['X-OpenReplay-SessionToken'] = tracker.getSessionToken(); // Inject openReplaySessionToken
fetch('', {

In order for OpenReplay to associate a Stackdriver log entry with the recorded user session, a unique token has to be propagated as a label to each backend error you wish to track.

Below is an example in Stackdriver’s Python API.

google_logger.log_text("A LOG ENTRY", severity='ERROR', labels={"openReplaySessionToken": OPENREPLAY_SESSION_TOKEN})


google_logger.log_struct({"message": "A LOG ENTRY"}, severity='ERROR', labels={"openReplaySessionToken": OPENREPLAY_SESSION_TOKEN})

The name of the tag openReplaySessionToken is case sensitive.

If you encounter any issues, connect to our Slack or check out our Forum and get help from our community.