πŸ”Using __GLU_NUDGE_CLICK for Widget Visibility

This guide explains how to programmatically check and respond to the visibility state of CustomerGlu widgets by accessing the __GLU_NUDGE_CLICK property stored in localStorage.

Overview

When a CustomerGlu widget reaches its completed state, it stores interaction data in localStorage under the key __GLU_NUDGE_CLICK. By default, the widget is automatically hidden when the click count is 1 or more.

Important Notes:

  • This data is also stored on the backend and synced across devices

  • The visibility threshold can be customized through Visibility Conditions under Widget Configuration view for a campaign

Data Structure

The __GLU_NUDGE_CLICK property uses the following structure:

{
  "userID": {
    "entrypointId": {
      "campaignId": {
        "clickedCount": 1
      }
    }
  }
}

Example Data

Field Explanation

  • userID: A unique identifier for the user

  • entrypointId: The ID representing the entry point where the widget is displayed

  • campaignId: The ID of the campaign associated with the widget

  • clickedCount: The number of times the widget was clicked (widget is hidden when this equals or exceeds the configured threshold, default is 1)

How to Access Widget Visibility?

Basic Code Example

Use Cases

1. Conditional UI Rendering

2. Listening for Visibility Changes

3. Integration with Segment API

This example shows how to combine widget visibility with the Segmentation API:

Best Practices

1. Defensive Coding

Always implement error handling when accessing localStorage:

2. Performance Considerations

  • Avoid checking localStorage in tight loops or high-frequency events

  • Consider caching the result if checking frequently:

3. Cross-Device Considerations

Since the widget state is synced across devices via the backend, users will generally see consistent widget visibility across their devices. However, there might be a short delay in synchronization.

Troubleshooting

Widget Visibility Inconsistencies

If the widget visibility state seems inconsistent:

  1. Verify you're using the correct IDs (userId, entrypointId, campaignId)

  2. Check the raw localStorage data:

  3. Check if the visibility conditions have been customized in the CustomerGlu dashboard

  4. Verify there are no network issues preventing backend sync

Missing Data

If no data appears in localStorage:

  1. Confirm the user has interacted with at least one widget

  2. Check browser localStorage permissions and quotas

  3. Verify the CustomerGlu SDK is properly initialized

Visibility Configuration

The default behavior is to hide widgets when clickCount is 1 or more, but this can be customized:

  1. Navigate to the Campaign in CustomerGlu dashboard

  2. Select the Widget Configuration view

  3. Find and update the Visibility Conditions according to your needs

Last updated

Was this helpful?