wiki:TracGoogleSearchPlugin

Trac Google Adsense and Search

Description

This plugin enables your Trac environment to use Google's Adsense for Search on the mini search box displayed on top. Google AdSense is a program run by Google that allows publishers in the Google Network of content sites to serve automatic text, image, video, or interactive media advertisements, that are targeted to site content and audience. AdSense for search allows publisher to display ads relating to search terms on their site and receive part of of the revenue generated from those ads.

Note: Regular Trac search won't be disabled, the users must click the Search button to access it, and will only show up and work if user has SEARCH_VIEW permissions, unlike this plugin, which does not require any special permissions since it's querying Google not Trac.

Bugs/Feature Requests

Existing bugs and feature requests for TracGoogleSearchPlugin are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

This plugin is also available on PyPi.

Source

Check out TracGoogleSearchPlugin from here using Subversion, or browse the source with Trac.

Installation

General instructions on installing Trac plugins can be found on the TracPlugins page.

Configuration

In order to use this plugin you must first create a custom search engine on your Adsense account, configure it like you want it and choose to display the results on a page on your own website.

If you wish Google to show results relative to the domain of your Trac environment, on your Adsense account, edit your search engine settings, choose "view more advanced features", select "Search the entire web but emphasise included sites" and then under "Sites" add your Trac environment domain.

From the resulting code that Google provides we'll need the values from the hidden fields named, cx and cof, ie your client id and search id strings.

Consider the following example code:

  <form action="http://domain.tld/gsearch" id="cse-search-box">
    <div>
      <input type="hidden" name="cx" value="partner-pub-0000000000000000:0aaaa0aaa00a" />
      <input type="hidden" name="cof" value="FORID:1" />
      <input type="hidden" name="ie" value="UTF-8" />
      <input type="text" name="q" size="31" />
      <input type="submit" name="sa" value="Search" />
    </div>
  </form>
  <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>

The values you'll need to remember would be partner-pub-0000000000000000:0aaaa0aaa00a and FORID:1, the rest of the code will be provided by the plugin.

The plugin can then be configured on Trac's administration panel, under the section Google and then Search.

Recent Changes

17123 by rjollos on 2018-04-13 22:51:49
Correct the plugin path
17122 by rjollos on 2018-04-13 22:49:10
Correct the directory name
17119 by rjollos on 2018-04-13 00:34:26
Fix directory name
(more)

Author/Contributors

Author: Pedro Algarvio
Maintainer:
Contributors:

Last modified 7 years ago Last modified on Apr 14, 2018, 8:29:48 AM