Tech Blog

Adwords/Hotwords JavaScript code


JavaScript file that presents links for popular library resources based on the primo search term.

Author: University of Iowa University of Iowa LIT staff

Institution:The University of Iowa

Year: 2008

License: BSD style

Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.



Programming language


Software requirements

JavaScript must be enabled



Working example

Installation instructions

Navigate to the base web directory of the front-end server (in our case, /exlibris/primo/p1_1/ng/primo/home/system/thirdparty/openserver/server/search/deploy/primo_library-app.ear/primo_library-libweb.war) . Copy the attached file to the javascript directory.
From the base web directory, navigate to the views/brief directory. In file, results_num_tile.jsp, insert the following code:

<script type="text/javascript" src="../javascript/embed.js" ></script>

between these lines:

<prm:userText styleId="result" type="openingText"/>
<html:form method="post" action="/action/ ...
<Code sample>

var thisQuery = queryString('vl(freeText0)')

adWordsLinks = createAdWords(thisQuery)

myOutput = header + adWordsLinks + footer


function createAdWords(str){

    var strLC = str.toLowerCase()

    var adWords = ''

    if (strLC.indexOf('hour') !=-1) {

        adWords = adWords + '<li><a class="title" href="" target="_blank">Library Hours</a> — Looking for Library Hours?</li>'



</Code sample>

*Modify the script to reflect URLs and search terms that make sense for your institution.

*Info sample

TO DO list

We would like to find a way move this code outside of the native jsp files that are updated with service packs.
We would like to find a way to test making this a “server side” routine rather than “client side” where the search term is known.

Page attachments

View links here:


Apr 20, 2012
Jim Adamson


Thanks for the contribution! I am trying to get this working in Primo v3. I have edited results_num_tile.jsp to include embed.js, but the three added lines do not show up when I ‘View source’ for the brief results page. Any ideas?


Leave a Reply