Home > widget-integration > RecommendationAnalytic > getStorageKeyPrefix
RecommendationAnalytic.getStorageKeyPrefix() method
Gets the storage key prefix for recommendation widget tracking data.
This method returns the base prefix used when generating localStorage keys for recommendation widgets. Override this method to customize the prefix for specific shop requirements, such as multi-shop setups or namespacing strategies.
Signature:
protected getStorageKeyPrefix(): string;
Returns:
string
The storage key prefix string. Default is 'boostSdRecommend'.
Remarks
The prefix is used as part of the full storage key format: {prefix}-{widgetId}. Choose prefixes carefully to avoid conflicts with other localStorage keys. Consider including shop identifiers for multi-shop implementations.
Example 1
Override to include shop domain in prefix:
protected getStorageKeyPrefix(): string {
  const shopDomain = window.Shopify?.shop || 'default';
  return `${shopDomain}-boostSdRecommend`;
}
Example 2
Override to use environment-specific prefix:
protected getStorageKeyPrefix(): string {
  const env = process.env.NODE_ENV === 'production' ? '' : 'dev-';
  return `${env}boostSdRecommend`;
}