How to Integrate Algolia Recommend with Instagram Ads

How to Integrate Algolia Recommend with Instagram Ads

The effectiveness of Instagram ads can be optimized by leveraging AI tools for product recommendations. Trends is a set of new models within…

· 4 minute read

Instagram ads

Instagram ads are a very common promotional tool for many industries, especially ecommerce. Promoted ads are injected between the regular feed, presenting a user with a carousel of items to click on and potentially purchase. Instagram offers advertisers an ad targeting algorithm based on internal data, such as user behaviors and shopping preferences, on Meta’s social media platform, as well as an option to include external tracking information from other sources.

Trends models with Algolia Recommend

The effectiveness of Instagram ads can be optimized by leveraging AI tools for product recommendations. Trends is a set of new models within Algolia Recommend that enable teams to create experiences that can dynamically adapt to emerging trends, removing the need for manual editorial curation.

Recommend provides builders with two new APIs focused on trends:

  • Trends on items: builders will be able to display the trending items over their whole catalog or simply for a given category or brand (or any facet values, really).
  • Trends on facet values: builders will be able to display the trending facet values right now for a given category or brand (or any facet values, really).

Those 2 models can be combined to recommend “trending items per facet name”

The benefits of the Trends model are in discovering early trends, such as product demand growing over time, as opposed to the constant high-demand products like typical best sellers. For highly competitive industries, such as retail, fashion, and beauty, detecting new trends early is a game changer, directly impacting the revenue and brand credibility.

From the customer experience perspective, the immediate benefit is the consistency seen across marketing and promotional assets, on all channels. Customers see the same products recommended to them on the website, while browsing social media, and when they receive promotional emails featuring recommended products. Consistency is key.

How to implement Algolia Recommend with Instagram ads

Instagram offers several options for ad content promotion. With the classic Instagram Ads, the content is selected manually by the advertiser and served by Instagram to the chosen target audiences. The Dynamic Ads option lets advertisers leverage external tracking data in addition to the internal Instagram user behavior data. We will start with integrating Algolia Recommend models with classic Instagram ads and then discuss the enhancement possibilities with dynamic ads.

To start integrating Algolia Recommend with Instagram ads, you will need to follow a two step process.

  1. Step 1: Algolia set up
  • Upload your catalog data to Algolia
  • Implement Insights click & conversion events
  • Implement Recommend (Docs: Trending Recommendations)
  • Ensure having met minimum traffic volume requirements: Collect at least 10K events within the last 30 days
  1. Step 2: Instagram set up
  • Set up a Business Manager account – Your account must be verified in order to use the catalog APIs

  • Upload your Catalog to Business Manager

  • Dynamically Create a Set of Items in a Catalog by using the Algolia recommend API to fetch the trending items to be added to the set

  • Fetch the global trending products from Algolia, using the Python client:

    from algoliasearch.recommend_client import RecommendClient

    algolia_app_id = '' algolia_api_key = '' algolia_index_name = ''

    recommend_client = RecommendClient.create(app_id, api_key)

    recommendations = recommend_client.get_recommendations(

queries=[ { 'indexName': algolia_index_name, 'model': 'trending-items', } ] )

trending_product_skus = [product['sku'] for product in recommendations['results'][0]['hits']]
view rawfetch_trending_product_skus.py hosted with ❤ by GitHub

Using the list of trending product ids, create a new Facebook Catalog product set:

import requests

facebook_api_version = 'v14.0'
facebook_catalog_id = '<facebook-catalog-id>'
facebook_api_token = '<facebook-api-token>'

res = requests.post(

f'https://graph.facebook.com/{api_version}/{product_catalog_id}/product_sets', json={ 'access_token': facebook_api_token, 'name': 'Trending products', 'filter': { 'retailer_id': { 'is_any': trending_product_skus } } } )

trending_product_set_id = res.json()['id']
view rawcreate_product_set.py hosted with ❤ by GitHub

Create your ad campaign, using the product set created above as the product source, and define your target audience Review and Publish The trending products are refreshed every 24h, in order to always keep the products displayed in your ad fresh, you will need to update your product set:

import requests

facebook_api_version = 'v14.0'
facebook_api_token = '<facebook-api-token>'
# The `product_set_id` is obtained during the creation of the product set, refer to the `create_product_set.py` file.
facebook_product_set_id = ''

# Refer to the `fetch_trending_product_skus.py` file for fetching the trending products.
trending_products = []

requests.post(

f'https://graph.facebook.com/{version}/{product_set_id}/', json={ 'access_token': facebook_api_token, 'filter': { "retailer_id": { "is_any": [product['sku'] for product in trending_products] } } } ) view rawupdate_product_set.py hosted with ❤ by GitHub

Instagram ads in feed showing product recommendations - purses and bags

Instagram ads stories showing recommended products - purse, bag, and scarves

Demo • Repository

Next steps: enhance and automate the audience targeting

A common marketing tool used for targeted marketing campaigns is a customer data platform. CDPs like Segment, mParticle, and Google Tag Manager collect and unify first-party customer data from multiple sources and then leverage it for targeted and personalized marketing campaigns. When powering Instagram ads with Algolia Recommend Trending Products model, you can use your CDP to define dynamic audiences matching the facets of trending categories, automating the ad audience targeting process.

Conclusion

To integrate Algolia Recommend‘s Trending Products model with your Instagram ads, head to Algolia Code Exchange for implementation instructions, a code sample GitHub repository, and a demo. Or refer back to this blog post!

To implement this solution, you will need to activate Algolia Recommend and set up your Instagram product audiences. Once all of the configurations are completed, your social media ad targeting should become much more accurate and effective.

product
recommend