Home > widget-integration > RecommendationService > identifyWidgetPage
RecommendationService.identifyWidgetPage() method
Identifies which page type a widget belongs to based on its ID.
Widget IDs follow a naming convention where the prefix indicates the page type: - 'homepage' prefix → home-page - 'cartpage' prefix → cart-page - 'collectionpage' prefix → collection-page - 'productpage' prefix → product-page
Signature:
identifyWidgetPage(payload: {
		widgetId: string;
	}): SupportedPage | undefined;
Parameters
| 
 Parameter  | 
 Type  | 
 Description  | 
|---|---|---|
| 
 payload  | 
 { widgetId: string; }  | 
 Object containing the widget identifier. The widgetId should be a non-empty string following the page prefix naming convention.  | 
Returns:
SupportedPage | undefined
The page type identifier (SupportedPage) if recognized, undefined if the widget ID doesn't match any known page prefix pattern.
Example
Identify widget page:
const pageType = this.identifyWidgetPage({ widgetId: 'homepage-recommendations-1' });
// Returns: 'home-page'