frenzAfterApiCallBack, a global callback that gives your theme or custom JavaScript access to the complete Frenzy response after the built-in interface has rendered it. Use it when you need to extend Frenzy with your own analytics, UI, experiments, or integrations without replacing the standard search and recommendation experience.
Quick start
Define the callback onwindow before frenzy-search.js loads. The name is case-sensitive and intentionally spelled frenzAfterApiCallBack.
When the callback runs
The callback runs after Frenzy has processed and rendered a supported API response. Depending on the components enabled on the storefront, this includes search results, collection results, autocomplete suggestions, recommendation widgets, and bundles. It can run more than once in one shopper session. For example, expect another invocation when the shopper changes a filter or sort order, moves between result pages, loads additional products through infinite scroll, performs another search, or opens suggestions. Build the callback as an event handler, not as a one-time page-load hook.Working with the response
The callback receives the response payload used by the active Frenzy feature. Its exact shape depends on that feature and its configuration, so use optional chaining and defaults rather than assuming every field is present.response.results.results— the returned product records. Each record contains the product data configured for the Frenzy experience, such as identifiers, SKU, product name, price, images, options, custom data, and other storefront attributes where available.response.results.request_id— identifies the Frenzy result request. Preserve it when you need to associate a shopper interaction or downstream event with the result set that produced it.response.results.products_foundandresponse.results.page_count— total matched products and available pages, useful for a custom result-count indicator or pagination integration.response.results.filtersandresponse.results.facet_fields— current filter values and available facets. These are useful when mirroring filter state in a custom component.response.results.corrected_query— the query correction when Frenzy has applied one.response.global_setting, page settings, CSS settings, filter order, and labels — configuration used by the current Frenzy component. These fields are feature-dependent.
response in your browser’s developer tools for the specific component you are extending, then feature-detect the properties you use. Do not rely on a field being available in every callback invocation.
A/B test assignment date
response.ab_test_assignment_date tells you when the shopper was assigned to the current Frenzy A/B-test experience. It represents the assignment time, not the time that the current API response was generated.
This field is useful for keeping external analytics and experiment tooling aligned with Frenzy. For example, you can send it with a product-impression or conversion event so analysts can distinguish a shopper’s original experiment assignment from later search activity.
Avoid duplicate events
Because the callback can be invoked repeatedly, use the request ID to prevent duplicate analytics events for the same response. The example below deduplicates only requests that provide an ID.Recommended practices
- Define the callback before Frenzy initializes. If it is added after the relevant response has already been processed, it will not run for that earlier response.
- Use optional chaining and fallback values because response fields differ across search, collections, suggestions, recommendations, and bundles.
- Keep the callback fast. Avoid slow synchronous work or blocking network calls that could affect the shopper’s experience.
- Use
request_idandab_test_assignment_dateas supplied by Frenzy when reporting analytics or experiment events. - Do not modify the response object or rely on callback return values to alter Frenzy rendering. Use the callback to read the response and enhance your own UI or integrations.
- Only forward data to third-party analytics tools in accordance with your storefront’s consent and privacy requirements.