How to enable Search Reporting
Search reporting lets you track the performance of your on-site search (displays, clicks, add-to-carts, conversions) directly in your favorite analytics tool (e.g. GA4).
To do this, you just need to make sure that Search events are sent to your website's DataLayer through the AB Tasty tag.
Before you start:
This page documents the new GA4/DataLayer-based Search tracking for Commerce platform (distinct from the legacy abtasty_search / abtasty_search_result custom events described in "Search widget events", which relate to the historical AB Tasty/Ariane collection).
Enabling Search reporting
Configure analytics in your tag
Search events reuse the same DataLayer channel as Merchandising and Recommendation events. Your Technical Support Engineer (TSE) or internal tech team simply needs to add this key to the config.json file of your tag configuration (skip this step if it's already set for Merchandising/Recommendations):
"analytics": {
"ga4EventsToDataLayer": true
}Make sure GA4 / GTM is set up
If your Recommendation or Merchandising reporting is already configured, Search events will be captured the same way once the additional variable search_query is included.
Otherwise, your TSM or internal tech team can follow the existing Recos GTM setup (same trigger, same event structure) and add the Search-specific variables listed further down this page.
Test it
Open your site → open the browser console → type dataLayer.
You should see events like:
{
"event": "ab_recos_xxxx",
"recos": {
"reco_id": "search",
"action_id": "show",
"item_ids": "[\"12345\",\"67890\"]",
"search_query": "xxxx"
}
}If you see them, it means Search events are being correctly sent to GA4.
How to set up HTML on your website?
There are two different ways to implement Search, and the HTML setup differs depending on which one you're using:
Search widget - AB Tasty renders the search UI end-to-end. No HTML attributes are needed (see below).
100% API implementation - you build your own search UI on top of the Search API. HTML attributes are needed, following the same convention already used for Recommendations/Merchandising 100% API (see below).
Search widget
Unlike Merchandising banners, the Search widget is fully rendered and managed by AB Tasty end-to-end. There is no HTML attribute to add on your page. The widget reads the query typed by the visitor and the results it displays directly from its own internal state, and pushes the corresponding events to the DataLayer automatically without relying on markup added by your team.
100% API implementation
If you are building your own search UI on top of the Search API (see "Using search with API") instead of using the AB Tasty Search widget, the same approach as for Recommendations and Merchandising 100% API applies: your development team adds the required HTML attributes to your own search results markup, and the recos-tag (configured by your TSE) detects them and handles the DataLayer push automatically. You do not push to the DataLayer yourself.
Required attributes:
Data-search-uuid
Strategy identifier, always equals to "search"
<div data-search-uuid=”search”>
Data-search-value
The search query entered by the visitor
<div data-search-value="polo">
Data-search-click
On all clickable zones, possible values are add_to_cart and go_to_page
<button data-reco-click="add_to_cart">
Data-item-id
Product identifier, on each product tile
<div data-item-id="SKU123">
How to configure GTM / GA4?
The configuration follows the same principle as Recommendations and Merchandising tracking, with a dedicated set of DataLayer variables for Search.
If you already have Recommendation or Merchandising analytics events configured in GA4, you can reuse the same trigger and GA4 Event tag. Simply add the Search-specific variables below.
Otherwise, follow these steps:
Create DataLayer variables
Create these seven variables:
reco_id
recos.reco_id
reco_name
recos.reco_name
action_id
recos.action_id
item_id
recos.item_id
item_ids
recos.item_ids
search_query
recos.search_query
non_interaction
recos.non_interaction
You can access them in GTM via the data path recos.VARIABLE_NAME.
Example events in the DataLayer
Show event (search results displayed)
Click event (product clicked from the results)
Add-to-cart event (product added to cart from the results)
Available Event actions
show
When search results are displayed to the visitor
go_to_page
When a product in the search results is clicked
add_to_cart
When a visitor adds a product to cart directly from the search results
How to test my reporting tracking?
Open your website
Open the browser console
Type:
dataLayer
You should see events like ab_recos_xxxx containing reco_id: "search", action_id and search_query.
If these appear → the tracking setup is working. You can then check results in GA4 > DebugView.
Notes & limitations
Activating this does not interfere with your existing analytics setup.
Search queries may occasionally contain personal data if a visitor mistypes personal information into the search bar. Confirm this collection is covered by the client's privacy policy and consent settings before enabling it.
Last updated
Was this helpful?

