Preview Wizard

The Preview Wizard is designed to let you quickly, easily, and reliably integrate previews with your site. You can embed a book viewer, link to Book Search, or even add a preview "popup" window to your site—all you need to do is generate the code and paste it onto your page. You can also customize this code using some simple JavaScript functions.


The Preview Wizard is a simple convenience library we built on top of our Dynamic Links and Embedded Viewer APIs. If you're an advanced developer looking for customized integration, consider using the underlying APIs directly.

Generate your preview code

Examples of generated previews

The following examples were generated using the Preview Wizard.

Customize your code

In addition to using the wizard above, you can call some simple JavaScript "helper" functions directly. To do this, you should first load the Preview Wizard library. One way to do this is by adding the following tag to the <head> section of your page:

<script type="text/javascript" src="https://books.google.com/books/previewlib.js"></script>

Having loaded the preview library, you can then call any of the following functions from within <script> tags inside your document's <body>. For example, if you'd like to insert the "Google Preview" button, you'd put the code to do so in a <script> element at the button's desired position within the page.

GBS_setLanguage

GBS_setLanguage(languageCode)
    Changes the language of any buttons or text added after this function is called. This includes the language of the "Google Preview" button, the interface language of the embedded preview, and so on.
    Parameters:
      string languageCode - The desired RFC 3066 language code (default is 'en' for English). Currently supported language codes include hy, bg, ca, zh-CN, zh-TW, hr, cs, da, nl, en, fil, fi, fr, de, el, hi, hu, is, id, in, it, ja, ko, lv, lt, no, pl, pt-BR, pt-PT, ro, ru, sr, sk, sl, es, sv, th, tr, uk, and vi.

GBS_setViewerOptions

GBS_setViewerOptions(optionObj)
    Parameters:
      Object optionsObj - A set of key-value pairs passed to the Embedded Viewer API's DefaultViewer constructor. Typically, this is used for advanced customizations.

GBS_setCobrandName

GBS_setCobrandName(cobrandName)
    Intended for use by publishers in the Partner Program, this function sets the Co-Branded Search site to be used when inserting any preview links to Book Search. Calling this function before inserting a button ensures that users see the partner's logo above the Book Search previews.
    Parameters:
      string cobrandName - The cobrand name to be added to any Book Search URLs. This is typically what comes after /p/ in existing Co-Branded Search preview URLs.

      For example, setting the value to sup will send the user to links like
      https://books.google.com/books/p/sup?id=Q8ysL64pM54C&printsec=frontcover
      rather than the default
      https://books.google.com/books?id=Q8ysL64pM54C&printsec=frontcover

GBS_insertEmbeddedViewer

GBS_insertEmbeddedViewer(identifier, opt_width, opt_height)
    Inserts an embedded book preview wherever this function is called. If the preview is unavailable, no viewer is shown.
    Parameters:
      Number opt_width - The desired width of the viewer, in pixels.
      Number opt_height - The desired height of the viewer, in pixels.

GBS_insertPreviewButtonPopup

GBS_insertPreviewButtonPopup(identifiers)
    If the book preview is available, this function writes out a "Google Preview" button. Clicking this button opens a "floating preview window" right on top of your page. If no preview is available, the button is not drawn.

    More sophisticated developers may be interested in the Embedded Viewer API, which this function uses internally.

    Parameters:
      string, Array identifier - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See Dynamic Links request format. If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.
GBS_insertPreviewButtonLink(identifiers, opt_options)
    If the book preview is available, this function writes out a "Google Preview" button that simply links off to a preview page for the book. By default, this links to the preview on Google Books, but you can also:
    • link to a URL on your site (which should, in turn contain an embedded viewer). You can do this by passing an optional alternativeUrl option.
    • link to a Co-Branded version of the book preview page, if GBS_setCobrandName is called before this function.
    If no preview is available to the user, no button is drawn onto the page.
    Parameters:
      string, Array identifier - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See Dynamic Links request format. If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.
      Object opt_options - optional - A name-value map used to configure the behavior of the button. Currently one option is supported: alternativeUrl. For example, to have the Google Preview button link to a custom preview page on your site, simply pass the following as a second argument to GBS_insertPreviewButtonLink:
           { 'alternativeUrl' : 'http://yoursite.com/your-preview-page' }