skip to main content

Division of Marketing
& Communications

Search

Google's Google Custom Search Engine (CSE) searches only selected sites. It uses the public Google search engine instead of a local Google Search Appliance, while still allowing us to customize the results.

You can set up a custom search engine that indexes only your college or department websites, or you can use the code below to add a Google Custom search box to your website that will search all Texas A&M websites.

Separate page

The following code displays an all-university search box on any page of your website, with the results displayed on your own website's search page. Paste the first code block in your site's <body> section, anywhere you want the search box to appear.

  <form action="http://YOUR-SITE.tamu.edu/search.html" id="searchForm" method="get">
     <label for="search_text_box">Search:</label>    
     <input id="search_text_box" maxlength="256" name="q" placeholder="Search Texas A&amp;M"/> 
     <input id="search_button" type="submit" value="Search"/>
   </form> 

Paste this second code block where you want the search results to appear on the <body> section of your search page (http://YOUR-SITE.tamu.edu/search.html, in the example above). To use your own Custom Search engine instead of ours, replace the cx variable with your own search engine ID.

<script> (function() { var cx = '007072000051401796093:7dedkcxj2gk'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:searchresults-only linktarget="_parent"></gcse:searchresults-only>

Single Page

The following code displays the search box and search results in the same <div>. Paste the code into a <div> element in your site's <body> section, where you want both the search box and the search results to render.

<script> (function() { var cx = '007072000051401796093:7dedkcxj2gk'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:search></gcse:search>

Learn more