Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Preferred Source Banner

No security coverage Under active development

This module adds a banner and inline button to your website that encourages visitors to add your site as a preferred source on Google. This feature can improve visibility in personalized search results and AI-powered search experiences. It includes local analytics, customizable display triggers, and flexible placement options.

Give your readers a one-click way to choose your site in Google.

Add as Preferred Source on Google places a banner and an inline button on your site that send visitors straight to Google's preferred sources page. One click, and your site is added to their personalized results, including Top Stories and Discover. It is built for publishers who want loyal readers, not just passing traffic.

Why Preferred Sources matter

Preferred Sources lets people tell Google which websites they want to see more often. According to Search Engine Journal, the feature is now available globally across supported languages, opening a real opportunity for publishers to build lasting visibility.

It has also reached Google's AI search experiences, including AI Overviews and AI Mode, as reported by Search Engine Journal.

Your best readers already like your content. This module gives them a simple, well-timed way to say so, and it shows you exactly how many take the step.

Features

Know what works, and keep the data

Every impression, click and dismissal is stored in a table on your own server. No tracking pixel, no cloud account, no data-sharing agreement. A built-in report at /admin/reports/preferred-source shows all-time totals, a 30-day breakdown with click-through rate, and the content that converts best.

Show the banner at the right moment

Do not interrupt readers the second they arrive. Set the banner to appear after a scroll depth or a time delay, so it reaches people who are already engaged. Scroll listeners are passive and remove themselves after firing, so your pages stay fast.

Make it look like your brand

Choose the position, background, text and accent colors, and the close button, with separate desktop and mobile toggles. Colors are passed as CSS custom properties, so your stylesheets stay aggregatable, and the markup lives in a Twig template you can override in your theme.

Everything else, done properly

  • No flicker. The banner is rendered hidden and revealed by JavaScript only after the dismissal check passes. Sites behind the Internal Page Cache or a CDN never show a banner that vanishes a moment later.
  • Dismissals that stick. Store them in Local Storage (with an automatic cookie fallback) or in cookies when the server or CDN needs to read them. Choose to always display, hide for a set number of days, or hide for the current session. Impressions are counted once per visitor per day, so click-through rate stays honest.
  • Automatic or manual placement. Inject the banner on every eligible page, place the provided block in any region or Layout Builder section, or do both. Blocks inherit the global settings and override only what you change, so updating the destination URL stays a one-step edit.
  • Precise display rules. Include or exclude pages by path (wildcards and <front> supported, matched against system paths and aliases), content type, node ID and user role. Admin routes are always excluded.
  • Three block styles. Card for a standalone unit, Compact inline for sidebars and articles, and Fixed bar for a top or bottom banner.
  • Accessible and responsive. Semantic anchor markup, a labelled close button, visible focus outlines, prefers-reduced-motion support, and a layout that reflows on small screens.
  • Built the Drupal way. Configuration API, render arrays and Twig, dependency injection, explicit cache tags and contexts, flood control on the tracking endpoint, translatable strings, and an alter hook for runtime adjustments.

Getting started

Install the module as usual, then:

  1. Configure the banner. Go to Configuration › Content authoring › Preferred Source Banner (/admin/config/content/preferred-source). The form has five tabs:
    • Content: banner text, optional subtitle, button label and target URL. Supports {site_name}, {site_url} and standard tokens such as [site:name].
    • Appearance: position (top or bottom), colors, close button, desktop and mobile visibility.
    • Behavior: trigger (immediate, scroll percentage or time delay), dismissal frequency, hide duration and persistence method.
    • Display rules: path mode and list, content types, excluded node IDs and excluded roles. These apply to automatic injection only.
    • Analytics: event recording, retention period and the per-IP rate limit on the tracking endpoint.
  2. Pick your placement. Leave Display automatically on to show the banner on every page that meets your rules, or turn it off and control placement with blocks.
  3. Place the block (optional). Go to Structure › Block layout, click Place block in a region, and choose Preferred Source Banner from the Marketing category. Leave fields empty to inherit global settings, or enable the override options for text, URL, colors or trigger on that instance. Standard block visibility conditions apply.
  4. Set permissions. At /admin/people/permissions, give Administer the Preferred Source Banner to administrators and View Preferred Source Banner analytics to anyone who should see the numbers without configuration access.
  5. Check the results. Load a front-end page, then open Reports › Preferred Source Banner to watch impressions and clicks arrive. Make sure cron runs regularly so the retention policy is applied.

Requirements

  • Drupal 10.3 or 11 (^10.3 || ^11) and PHP 8.1 or later. The block plugin uses PHP attributes, available since Drupal 10.2.
  • Core only. System, Block and Path alias. Node and User are used when present but are not required.
  • Nothing extra to install. No Composer packages, contributed modules, JavaScript libraries or CDN assets. The module ships one stylesheet and one vanilla JavaScript file built on Drupal.behaviors and core's once. No jQuery, no build step.
  • Fully self-contained. Analytics live in your own database. No API key, no account and no outbound requests.
Drupal 10–11 PHP ^8.1

Ask your assistant about Preferred Source Banner

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • block Drupal core
  • node Drupal core
  • path_alias Drupal core
  • system Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Sep 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.1 Stable 10–11 PHP ^8.1 Sep 24, 2026