Adding own user ID to UserReport

Roman Gomolko Updated by Roman Gomolko

Suppose are working with ID-management systems or you have login functionality, you can provide user IDs you have on a visitor to UserReport, so they are associated with the interviews users are completing on your website.

The functionality consists of two parts:

  1. pass your user IDs when initialising the UserReport snippet
  2. Getting access to collected responses connected to passed user IDs

This document focuses on the first part - passing user IDs to UserReport. The access part depends on your pipeline of accessing interview results.


UserReport can work with multiple ID spaces. When passing a user ID, you must pass the ID space to which it belongs. Imagine you have your first-party ID, login ID and external probabalistic ID (e.g. ID4), then you need to assign an alphanumeric identifier to each ID-space, like this:

  • pseudononymous_id
  • login_id
  • id4_id

You need to pass ID-space/ID-value pairs to UserReport on each pageview. User IDs provided on a pageview that leads to an invitation and completed survey will be stored in connection to survey results for subsequent access.

Pass user ID using JavaScript

To pass User IDs from your code to UserReport, you need to use the following code:

window.audienceProjectLayer = window.audienceProjectLayer || [];
window.audienceProjectLayer.push(['setUserId', 'ID-space', 'ID-value']);

ID-space and ID-value must be replaced with the actual ID-space and user IDs.

This must be invoked before an invitation is shown, which may be non-trivial to achieve if you are working with an asynchronous ID-provider. To guarantee that you can suppress the invitation before user ID provided and then attempt to invite. This is an example code:

window.audienceProjectLayer = window.audienceProjectLayer || [];
window.audienceProjectLayer.push(['muteInvitation']); // disable invitation
window.audienceProjectLayer.push(['setUserId', 'pseudononymous_id', window.userId]); // pass 1-st party ID
if (window.loginId) {
window.audienceProjectLayer.push(['setUserId', 'login_id', window.loginId]); // pass login ID, if present
id4.getId(function(id4id) {
if (id4id) {
window.audienceProjectLayer.push(['setUserId', 'id4_id', id4id]); // pass ID4 ID
window.audienceProjectLayer.push(['attemptToInvite']); // try to invite

How did we do?

Configure Google Tag Manager to resolve media dynamically