This project is not covered by Drupal’s security advisory policy.
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-motionsupport, 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:
- 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.
- Content: banner text, optional subtitle, button label and target URL. Supports
- 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.
- 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.
- 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. - 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.behaviorsand core'sonce. No jQuery, no build step. - Fully self-contained. Analytics live in your own database. No API key, no account and no outbound requests.
Project information
- Project categories: Search engine optimization (SEO)
- Created by otaviozoocha on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.


