π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 userentrypointId: The ID representing the entry point where the widget is displayedcampaignId: The ID of the campaign associated with the widgetclickedCount: 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:
Verify you're using the correct IDs (userId, entrypointId, campaignId)
Check the raw localStorage data:
Check if the visibility conditions have been customized in the CustomerGlu dashboard
Verify there are no network issues preventing backend sync
Missing Data
If no data appears in localStorage:
Confirm the user has interacted with at least one widget
Check browser localStorage permissions and quotas
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:
Navigate to the Campaign in CustomerGlu dashboard
Select the Widget Configuration view
Find and update the Visibility Conditions according to your needs
Last updated
Was this helpful?