Home > widget-integration > FilterService > saveRequestId
FilterService.saveRequestId() method
Saves request ID to localStorage for analytics tracking.
Stores API request IDs associated with filter, search, and suggest operations. These IDs are used to correlate user actions (clicks, add-to-cart) with specific API requests for analytics and conversion tracking.
Signature:
saveRequestId(type: "filter" | "search" | "suggest", requestId?: string, bundles?: unknown[]): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
type |
"filter" | "search" | "suggest" |
Type of request ('filter', 'search', 'suggest') |
|
requestId |
string |
(Optional) The request ID from API response |
|
bundles |
unknown[] |
(Optional) Optional bundles array for widget-specific tracking |
Returns:
void
Remarks
Request IDs are stored with keys like 'filter', 'search', or '{widgetId}_{placement}' for widget-specific tracking. Used by analytics services to attribute conversions to filter usage.
Example
Override to add custom request tracking:
saveRequestId(type, requestId, bundles = []) {
super.saveRequestId(type, requestId, bundles);
// Send request ID to custom analytics
this.customAnalytics.trackRequest({
type,
requestId,
timestamp: Date.now(),
userSegment: this.getUserSegment()
});
}