Populating userState
By incorporating UserState in your script, the AI Paywall can identify whether a visitor is anonymous, registered, or a subscriber.
Both client-side and server-side implementations require userState to be included in each event payload. This variable identifies the user's status.
- Client-side implementation: The retrieveUserStatus function within the JavaScript automatically populates this value.
- Server-side implementation: You must manually populate userState. If this data is not already stored in the dataLayer, window object, or cookies, you can extract it from the Zephr object using the logic outlined below.
The following table outlines the valid userState values and how to determine the correct value using the Zephr object (window.Zephr):
userState Value | Description | Logic |
Anonymous | A user who has not registered or subscribed. Identifiable only by dtId. | accessDetails.authenticated = false accessDetails.activeProducts is empty |
Registered | A user who has registered but does not have an active subscription. Identifiable by both dtId and user.userID (both mandatory). | accessDetails.authenticated = true accessDetails.activeProducts is empty |
Subscriber | A registered user with an active subscription. Identifiable by both dtId and user.userID (both mandatory). | accessDetails.authenticated = true accessDetails.activeProducts is populated (contains at least one value in the array) |