Home > widget-integration > RecommendationAnalytic > generateStorageKey

RecommendationAnalytic.generateStorageKey() method

Generates a unique storage key for a recommendation widget.

Combines the storage key prefix with the widget ID to create a unique localStorage key for storing widget tracking data. This ensures each widget's tracking data is stored separately and can be retrieved independently.

Signature:

generateStorageKey(widgetId: string): string;

Parameters

Parameter

Type

Description

widgetId

string

The unique identifier of the recommendation widget. Must be a non-empty string that uniquely identifies the widget instance.

Returns:

string

The generated storage key in the format {prefix}-{widgetId}. For example: 'boostSdRecommend-homepage-recs'.

Example

Generate storage key for a specific widget:

const key = analytic.generateStorageKey('product-page-similar');
// Returns: 'boostSdRecommend-product-page-similar'