Using Coveo UI's SearchView.cshtml, Is there a way in Coveo to pin external items into results list in certain order?

Basically I am trying to insert ads between search results list. I have n no. of ads that need to go between every 4 non-ad result item.

Any pointers on the best approach to this?

Update: I am trying to use CoveoProcessParsedRestResponseArgs to insert ads into the ResultsRespnse object. The challenge I see is, it does not give me the search result page or firstResultIndex in the response to accurately insert ads on subsequent pages. Is there any other pipeline processor that I need to use?

  • Are the ads also search results or something else? Dec 3, 2016 at 12:53
  • They are not search results.
    – xoail
    Dec 3, 2016 at 15:26

2 Answers 2


I see two valid approaches for this.


  • Inject "fake results" that correspond to ads and add an underscore template to match those results, either using a server-side preprocessing or client-side PreprocessResults
  • Client-side, using a simple underscore trick that does not mess with the results at all.

Here is a quick example I came up with for the second scenario:

<script class="result-template" type="text/underscore">
    <div class="coveo-result-frame">
        {{ if(index % 4 == 0) { }}
            <div class="coveo-result-row my-ad-row">
                 Here is my AD
        {{ } }}
        ... // Your normal result template

I then added this style here to make it look like a real result:

.my-ad-row {
    padding: 0px 0px 20px 0px;
    border-bottom: 1px solid #BCC3CA;

Here is what it looks like:

Ad within Coveo results

  • we just posted the same answer at the same time. I am going to mark this one as the answer since you explained it much better. Thanks!
    – xoail
    Dec 5, 2016 at 19:45

I managed to do this by combining CoveoProcessParsedRestResponseArgs and underscore template on UI.

Basically I added a new property Ads to SearchResult item using the CoveoProcessParsedRestResponseArgs pipeline, which contains all ads collection (lucky for me there are only about 10) and then on the UI wrote logic on how to specify placeholders for what position to display them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.