Functions, Users, and Comparative Analysis
We decided that Docs should have prime location.
Build AI products you can trust.
We’re super excited to share that Aporia is now the first ML observability offering integration to the Databricks Lakehouse Platform. This partnership means that you can now effortlessly automate your data pipelines, monitor, visualize, and explain your ML models in production. Aporia and Databricks: A Match Made in Data Heaven One key benefit of this […]
Fundamentals of ML observability
Metrics, feature importance and more
We’re excited 😁 to share that Forbes has named Aporia a Next Billion-Dollar Company. This recognition comes on the heels of our recent $25 million Series A funding and is a huge testament that Aporia’s mission and the need for trust in AI are more relevant than ever. We are very proud to be listed […]
When building search and recommendation systems, one critical aspect to consider is the integration of sponsored content or advertisements into the results. For example, companies like Google and Amazon display sponsored results alongside organic ones. This article will guide you through the process of integrating ads into your search and recommendation results while maintaining a positive user experience.
Integrating ads into search and recommendation results presents several challenges, such as:
There are different approaches to integrating ads into your search and recommendation results. Two common methods are to display ads in fixed positions or to interleave them within the organic results. Here, we will discuss both approaches and provide some code examples.
In this method, ads are displayed at predefined positions within the results (e.g., positions 2 and 5 out of 6). You can achieve this by adding an orchestration layer that aggregates organic results and ad results, pushing the search or recommendations results down accordingly.
Here’s a sample implementation using Python:
def integrate_ads(organic_results, ad_results, ad_positions):
Insert ad_results into organic_results at specified ad_positions and return the modified list.
organic_results (list): A list of organic search results, e.g. ["result", "result", "result"].
ad_results (list): A list of ads to be inserted, e.g. ["ad", "ad"].
ad_positions (list): A list of positions for ads, e.g. [1, 4].
list: The modified list with ad_results inserted into organic_results at ad_positions.
for index, ad in enumerate(ad_results):
integrated = integrate_ads(["organic 1", "organic 2", "organic 3", "organic 4", "organic 5"], ["ad 1", "ad 2"], [1,3])
This will output the following:
['organic 1', 'ad 1', 'organic 2', 'ad 2', 'organic 3', 'organic 4', 'organic 5']
A classic example of this strategy is Google’s search engine. When you perform a search on Google, the first few results (typically 1-3) are often sponsored ads. These ads are relevant to your search query but are placed in predefined positions at the top of the search results. This strategy is not limited to Google but is also used by other search engines like Bing and Yahoo.
In-feed ads are interleaved within the organic results and require a more sophisticated approach, such as a third-pass ranker that accounts for ad margins and business objectives. This method can improve user experience by displaying ads more naturally within the result set.
Examples of different ranking logic could include:
To implement In-feed ads, you can modify the integrate_ads function from the previous example, adding a custom ranking function to control the placement of ads.
def should_pair(organic_result, ad_result):
threshold = 2
organic_keywords = set(organic_result.lower().split())
ad_keywords = set(ad_result.lower().split())
return len(organic_keywords.intersection(ad_keywords)) > threshold
def integrate_ads(organic_results, ad_results):
integrated = 
for organic_index, organic_result in enumerate(organic_results):
for ad in ad_results:
if should_pair(organic_result, ad):
organic_results = ["a spring jacket for men", "a winter coat for women", "a snow jacket for children"]
ads = ["ad: spring jacket selection for men", "ad: snow clothing for children"]
integrated = integrate_ads(organic_results, ads)
This considers each ad for each result, and if it has overlapping keywords it will display the ad after the results. In our example, the code will output the following:
['a spring jacket for men', 'ad: spring jacket selection for men', 'a winter coat for women', 'a snow jacket for children', 'ad: snow clothing for children']
Note that this means that sometimes not all ads will be shown, and it is possible that no ads will be shown.
A well-known example of this approach is Facebook’s News Feed or Instagram’s Feed. As you scroll through your feed, you will see sponsored posts or ads appearing amidst posts from your friends or people you follow. These sponsored posts are interleaved within organic content. The placement of these ads is determined by Facebook’s or Instagram’s ad placement algorithm which considers factors like your interests, interactions, and other behavioral data to serve you ads that you’re more likely to engage with. Another example is YouTube, which interleaves ads within the list of recommended videos, based on your viewing history and preferences.
Aporia’s ML observability platform helps ensure your ad integrations are performing at their best. With the platform, you’re able to easily optimize ad integration performance, and discover untapped revenue streams. Aporia’s integration into your ad search and ranking setup takes under 7 minutes, enabling you to scale and improve your ML models with confidence and speed. See how Aporia enhances your ad ranking models:
Integrating ads into search and recommendation results is a critical aspect of monetizing your systems without negatively impacting the user experience. By using the techniques outlined in this article and leveraging Aporia’s ML Observability platform, you can efficiently manage your ad placements while maintaining high-quality search and recommendation services.
Want to learn more about optimizing ad search and recommendations with Aporia? Book a demo with one of our ML observability experts.