Building expanded targeting for Pinterest ads

Zhiyuan (John) Zheng | Software Engineer, Ads Engineering

With more than 300 million people coming to Pinterest each month, Pinterest offers unique opportunities for advertisers to get their products in front of people with commercial intent. Similar to other platforms, Pinterest offers a variety of advertising targeting products¹. Advertisers can define a target audience based on Pinners’ interests, keywords, device, location, and more. When done well, targeting can deliver ads to the ideal audience and maximize partners’ value and return on investment (ROI), creating a good experience for everyone.

However, since many first-time advertisers on Pinterest do not have much knowledge about our platform or Pinners’ interests, many adopt the same targeting profiles (keywords, interests, or demographics) they’ve used on other platforms, which is likely to lead to suboptimal advertising performance, as Pinterest provides a unique experience to users helping them to find the inspiration they seek. One of the main reasons is certain keywords or interests are less popular on Pinterest. For example, a larger number of Pinners are interested in “room decor” than “home decor tips”.

To help advertisers be successful in targeting, we’ve developed Expanded targeting², a targeting product that automatically and intelligently connects a Promoted Pin to the ideal Pinners. With Expanded targeting, advertisers don’t need to determine the list of keywords or interests to target for their Promoted Pins and can instead rely on Pinterest to deliver the best advertising performance.

Since the first launch of Expanded targeting in Search Ads in 2017, Expanded targeting has become a popular targeting product on all product surfaces (Search, Related Pins, and home feed). As of August 2019, more than 85% advertisers and 60% of ad groups (i.e., a group of Promoted Pins which share the same targeting profiles) on Pinterest have opted into Expanded targeting.

In this article, we’ll share the techniques behind Expanded targeting for Pinterest ads.

Product Overview

Contextual targeting leverages keywords and interests to find the best audiences for ads. At Pinterest, we offer three types of contextual targeting products: Keyword targeting³, Interest targeting⁴, and Expanded targeting.

Keyword targeting requires advertisers to provide a list of relevant keywords, while Interest targeting allows advertisers to select relevant topics from a fixed interest taxonomy.

Expanded targeting, however, automatically determines the most relevant keywords or interests associated with Promoted Pins and derives knowledge from Promoted Pins, learns Pinners’ interests, and connects advertisers to the Pinners who are most interested in their business.

Image for post
Image for post
Fig. 1. Advertisers Can Easily Enable Expanded Targeting During Campaign Setup

Expanded targeting is designed to benefit both advertisers’ value and Pinners’ experience.

  • Advertiser benefits — Expanded targeting simplifies campaign creation as advertisers no longer need to specify keywords or interests, just need to enable the feature during campaign setup, as shown in Fig. 1. It also maximizes the ROI by showing the ads to the most interested Pinners.

Expanded targeting techniques

Expanded Targeting leverages two types of techniques to deliver ads to the most relevant Pinners through Textual-based Retrieval and Embedding-based Retrieval.

  • Textual-based retrieval — determines the best keywords or interests a Promoted Pin should be targeted, and is then used to match with search queries or interests.

In this post, we are using Generated keywords as an example to discuss textual-based retrieval in Expanded targeting. A discussion on embedding-based retrieval will be saved for a future post.

Textual-based retrieval

High-level architecture

Image for post
Image for post
Fig. 2. Architecture of Keyword Generation

Fig. 2 illustrates the high-level architecture of textual-based retrieval in Expanded Targeting, which contains the following stages. Interest generation follows a similar procedure.

  • Data Generation — uses heuristic and model-based approaches to generate keywords and interests for Promoted Pins

Data generation

We developed two approaches for keyword generation: a Pin2Pin Algorithm and a PinText Model based Algorithm.

  • Pin2Pin Algorithm — a heuristic algorithmic approach which aggregates the most engaged (clicks, repins, close-ups) search queries associated with each Promoted Pin and its most relevant Pins.
Image for post
Image for post
Fig. 3. An Example of Using Pin2Pin Algorithm to Generate Keywords

Fig. 3 shows an example of how we use the Pin2Pin algorithm to generate keywords for a Promoted Pin. First, we build a set of Pins which contain Related Pins (Related Pin 1, 2, and 3) that are similar to the input from the Promoted Pin. For each Promoted Pin and the set of similar Pins, we get its most engaged search queries. Specifically in this example, we get “unique tacos” and two other Navboost queries of the Promoted Pin. The “taco shell” query and five other Navboost queries appear on Related Pin 1. Next, for each of these queries, we compute a relevance score between the Promoted Pin and the query. In this example, we see “texas taco” from Related Pins 3, which has a relevance score of 0.90 with the Promoted Pin. Finally, we filter the Navboost queries by the relevance score at a threshold and determine the set of keywords for the Promoted Pin.

In addition, we use PinText Embeddings⁶, an in-house machine learning model to predict the most relevant terms for an input promoted Pin based on cosine similarity in embedding space. This model is trained based on Pinterest engagement data by making the embedding similarity between a positive engagement entity pair larger than the similarity between a randomly sampled background pair, where an entity embedding is derived by simply averaging its words’ embeddings. Fig. 4 shows an example of retrieved ads using PinText embedding.

Image for post
Image for post
Fig. 4 Use PinText-Model for Expanded Targeting Keyword Generation

The keyword generation pipeline generates a mapping from the keywords to a list of Pin IDs, and the data is stored in our in-house serving system. Currently our keyword generation pipeline is updated on a daily basis.


During indexing, our ads indexing server loads targeting profiles from a MySQL database and loads batched data to build both a forward index and an inverted index. The inverted index maps different features (such as keywords and interests) to Promoted Pins, whereas the forward index maps each Promoted Pin to a list of features. Similar to advertiser-provided keywords or interests, our generated keywords and interests are indexed in the same way. The generated indexes are used during online retrieval and ranking.


Ads retrieval is responsible for retrieving the best Promoted Pins according to the content signals associated with each Ads request. This is to ensure the delivered ads will not hurt the Pinner experience. Here, the request context varies across different placements. Specifically, it refers to Pinners’ interests on Homefeed, search queries in Search, and the close-up Pin signals on Related Pins.

We leverage a number of machine learning models to map context (search queries, close-up Pins, and user profile) to context signals (annotations and interests) and use them to retrieve ads.

Image for post
Image for post

Fig. 5. Retrieval Using generated keywords and interest

For example, as is shown in Fig. 5, for the Promoted Pin on the right, we generate a list of keywords and interests to build the index. For ads requests (Search Query, Pin or User), we also predict the most representative context signals (annotations and interests). During retrieval, when a search query (on Search), Pin annotations (on Related Pins), or Pinner annotations (on home feed) is “chicken recipes”, we are able to retrieve this Promoted Pin through keyword retrieval. Similarly, the “Meal Planning” interest can be used to retrieve this Ad through interest retrieval.

Targeting attribution

As part of our Ads product life cycles, Targeting attribution is responsible for attributing ads impressions and delivery back to the advertisier’s targeting spec. It is a very important stage in our Advertising product since advertisers rely on this information to evaluate the performance of targeting profiles and plan for future advertising strategies. If an Ad is retrieved through one of the Expanded Targeting techniques, we attribute the delivery to the generated keywords or interest. The attribution signals also provide good feedback signal for us to evaluate and improve the quality of our generation pipelines.

What’s next

  • Develop technology that retrieves ads without relying on keywords or interests.

Acknowledgments: Huge thanks to Albert Koy, Cynthia Johanson, Mao Ye, Jiajing Xu, Islam Al-Aarag, Roelof van Zwol, Jinfeng Zhuang, and entire Ads Quality team who helped in improving and scaling Expanded Targeting at Pinterest. We would also like to thank Content Team and Applied Science Team in our collaboration in developing many of these excellent techniques.


  1. Pinterest Ads Targeting Overview

We’re building the world’s first visual discovery engine. More than 250 million people around the world use Pinterest to dream about, plan and prepare for things they want to do in life. Come join us!

Pinterest Engineering Blog

Inventive engineers building the first visual discovery…

Pinterest Engineering

Written by | Inventive engineers building the first visual discovery engine |

Pinterest Engineering Blog

Inventive engineers building the first visual discovery engine, 200 billion ideas and counting.

Pinterest Engineering

Written by | Inventive engineers building the first visual discovery engine |

Pinterest Engineering Blog

Inventive engineers building the first visual discovery engine, 200 billion ideas and counting.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store