- Display sponsored products from brands bidding through a retail media platform (RMP) like Criteo, CitrusAd, and Zitcha.
- Show personalized recommendations from a machine learning recommendation engine.
- Promote items chosen by real-time bidding or A/B testing systems.
How external source groups work

- User searches or browses, which calls the middleware which, in turn, calls the retail media platform and Algolia.
- Middleware retrieves sponsored products from the retail media platform (API call 1).
- Middleware calls Algolia’s Composition API with request and sponsored products (API call 2).
- Algolia re-ranks sponsored results (optional) and merges or deduplicates these with regular search results.
- The Composition API returns a unified response which the middleware forwards.
Before you begin
You need:- Your Algolia app o be hosted in Algolia’s dynamic scaling infrastructure. Contact your Customer Success Manager if you’re on classic infrastructure.
- Access to Merchandising Studio.
- The Smart Groups feature and access to the Composition API. If you think you should have access to these features in your plan, but don’t see them, contact your Account Manager or Customer Success Manager.
- Algolia only injects items that are present in your index (referenced by
objectID
) and appear in regular search results for the current query and filters.
Configure an external source group
To configure an external source group, you first need to create a composition .Create a composition
If you haven’t already, create a composition for your dynamic results feed:- Go to Merchandising Studio and open Merch tools > Compositions.
- Click + Create Composition.
- Name your composition (for example, “Product results - United States”), select the main index, and save.
Add an external source group
- Go to Merch tools > Compositions > Composition Rules.
- Select your composition from the drop-down menu.
- Click + New Composition Rule.
- Define conditions for when this group should appear (for example, query contains “camera” or category is “Electronics”).
- Click + Add group.

- Set a unique group key, for example,
retail_media
(used when passing objectIDs) (1) - Under Data Source, select External Source. (2)
- (Optional) Add filters to constrain the external source results. For example, add
in_stock:true
to only show sponsored products that are available. (3) - (Optional) Configure Re-rank by relevance (defaults to enabled). When enabled, Algolia reorders the objectIDs you provide based on relevance to the user’s query. When turned off, items appear in the exact order you specify. (4)
- Save the group and publish the composition rule.
You must pass this exact group key (for example,
retail_media
) in the injectedItems
object when calling the Composition API.
The key links your API request to the group defined in Merchandising Studio.Pass objectIDs at query time
When calling the Composition API, include the objectIDs from your external source in the request. Your implementation should:- Call your external source API (for example, a retail media platform).
- Extract the objectIDs from the response.
- Pass the objectIDs to Algolia’s Composition API.
Example: full integration flow
JavaScript
You’re responsible for ensuring that the search query, filters, and facets sent to your external source (such as a Retail Media Platform) match those sent to Algolia.
This ensures that sponsored products are relevant to the user’s search context and filters.
Metadata
Each injected item can optionally include ametadata
field with extra information from your external source. This metadata isn’t used by Algolia for ranking but is returned with the search results, making it useful for:
- Campaign attribution: include campaign IDs, bid amounts, or advertiser information for analytics.
- Extra attributes: add attributes that aren’t present in your Algolia index but are needed for display or tracking.
metadata
field accepts strings, numbers, boolean values, and nested objects:
JavaScript
Performance considerations
For optimal performance, limit external source groups to fewer than 50 objectIDs per request. Requesting more than 50 items can significantly slow down search responses.Behavior details
External source groups interact with search results through re-ranking, deduplication, and filtering logic to ensure consistency and relevance.Re-ranking by relevance
When Re-rank by relevance is enabled (it is the default), Algolia applies your index’s ranking formula to the objectIDs provided by the external source. This ensures the most relevant sponsored items appear first within the group. For example, if your external source provides 5 objectIDs for “camera,” Algolia scores each item based on how well it matches the query and reorders them accordingly within the group. When turned off, items appear in the exact order you specify in the API request.Deduplication
Algolia automatically deduplicates results across groups and organic results:- External source items are injected at the group position.
- If any of those ObjectIDs also appear in regular search results, the duplicate is removed from them.
- The item only appears once (in the promoted group position).
objectID
appears in more than one group,
the first occurrence is kept and later duplicates are removed.
Combine with filters
You can add filters to external source groups to enforce extra constraints. For example:Handle missing or filtered object IDs
Algolia skips object IDs from external sources if theobjectID
:
- Isn’t in the index.
- Is filtered out of regular search results: it is in the index but doesn’t match the current query, filters, or other constraints. This filtering ensures your external source only injects relevant items.
Example use case: retail media platform integration
A typical retail media platform integration looks like this:JavaScript
Integrate with your frontend
After configuring the backend integration, update your frontend to use the Composition API client instead of the Search API client. For InstantSearch, replace your search client initialization:JavaScript
Regulatory requirements
In most regions (including the US, EU, and Canada), sponsored products must have a visual badge (such as “Sponsored”) on each injected product. For that reason, the code for each strategy adds asponsored: true
attribute to each “sponsored product” result.
Under regulations like the EU Platform to Business, you may also need to disclose how paid placements influence your search ranking.