Help your readers find your site through favorites in Google Search
If you're a website owner, you can help your audience find your publication as a favorite in Google Search. When a user adds your site to their favorites, your content is more likely to appear in "Top Stories", highlighted with a "Favorite" badge. In AI Mode and AI Overviews, your content is more likely to appear as a supporting link, highlighted with a "Favorite" badge for users who have selected your site as a favorite.
Feature availability
The favorites feature is available globally for the "Top Stories" feature in all languages where Google Search is available.
Favorites can also appear in AI Mode and AI Overviews in all languages and locales where those features are available. To make your site eligible for display as a favorite in these features, you must make sure your site is included in Search generative AI features in Search Console.
Only domain-level and subdomain-level sites are eligible to appear in the
favorites tool.
For example, https://www.example.com/ and
https://code.example.com/ are eligible for favorites,
but the subdirectory https://www.example.com/blog isn't
eligible.
How to help users find your site as a favorite
If your site appears in the favorites tool (to check, enter your site in the tool's search box), you can use the following methods to guide your readers to select your site as a favorite:
- Standard JavaScript implementation (recommended): Embed an interactive button to your web pages, which lets readers seamlessly add your site to their favorites and returns them to your page. By adding only two lines to your HTML, this option renders an automatically localized, Google-styled button that supports device and language customization.
- Advanced JavaScript implementation with custom design assets: If you want to use your own design assets and customize the standard JavaScript button, follow the advanced JavaScript implementation instructions. The end-user UI flow remains the same as the standard JavaScript implementation.
- Deeplink implementation: If you can't implement the interactive button (for example, your CMS doesn't support it), you can use a deeplink to direct people to adding your site to their favorites. You can do this by adding a text link or a clickable image on your web pages. You can also use the deeplink in your social posts, email newsletters, or promotions.
Standard JavaScript implementation (recommended)
By adding only two lines to your HTML, you can add an automatically translated, interactive button, which lets readers seamlessly add your site to their favorites and return to where they left off on your page. You can also set the theme of the button (dark or light), plus override the button language. We recommend this implementation because it provides the best user experience for readers.
Here's how it looks:
To embed the JavaScript button on your web page, do the following:
-
Add the following
<script>tag to your web page (preferably in the<head>element), which loads the favorites library.<script async src="https://news.google.com/swg/js/v1/publisher.js"></script> -
Add the following
<div>tag anywhere you'd like the button to appear in the body of your web page.<div google-add-preferred-source-btn></div>
Set the button theme
By default, the "Add to favorites" button appears in a light theme.
To adjust the theme, add the data-theme data attribute to your
<div> element and set it to either light or
dark:
<div google-add-preferred-source-btn data-theme="dark"></div>Override the button language
By default, the "Add to favorites" button appears in the user's
language based on their browser settings. To override this behavior, add the
data-lang data attribute to your <div>
element and set it to the language code you'd prefer (download the
list of supported language codes):
<div google-add-preferred-source-btn data-lang="en"></div>Download supported language codes
Advanced JavaScript implementation with custom design assets
By default, the standard JavaScript button automatically scans the DOM for
elements with the google-add-preferred-source-btn attribute and
renders the standard badge. However, for custom integrations where you want
to trigger the flow from your own UI elements or application milestones, you
can initialize the client programmatically and bind the flow to custom
triggers.
When integrating the favorites library into custom user interfaces, application milestones, or modern framework applications, you can take full programmatic control over runtime settings and flow initiation using our JavaScript SDK. We provide two distinct integration approaches depending on your tooling and architecture: ES Module imports (ESM) and standard script callback queues (IIFE). Both distribution models expose identical capabilities and methods.
ES Module imports
For modern build setups and module-based environments, import the library directly into your code.
import { preferredSource } from
"https://news.google.com/swg/js/v1/publisher.mjs";
// 1. Initialize directly using the imported module instance
preferredSource.init({
theme: 'light', // Theme choice: "light" or "dark" (default "light")
lang: 'en' // Optional: override language (defaults to page language)
});
// 2. Programmatically bind flow invocation using a click handler
const button = document.querySelector('#myButton');
button.onclick = () => {
preferredSource.addPreferredSource();
};Standard script callback queues
For standard script tag integrations, load the following script in the
<head> of your document with the
preferred-sources-control="manual" attribute to prevent
automatic button rendering:
<script async preferred-sources-control="manual" src="https://news.google.com/swg/js/v1/publisher.js"></script>
Then use the global PREFERRED_SOURCE callback queue to
initialize options and bind custom triggers:
<script>
(self.PREFERRED_SOURCE = self.PREFERRED_SOURCE || []).push(
function(preferredSource) {
// 1. Initialize with options
preferredSource.init({
theme: 'light',
lang: 'en'
});
// 2. Programmatically bind trigger button
const button = document.querySelector('#myButton');
button.addEventListener('click', () => {
preferredSource.addPreferredSource();
});
});
</script>For interactive frontend and backend implementations showcasing live usage across buttons, declarative containers, IIFE scripts, and ES Module bundles, explore the favorites demo.
Deeplink implementation
If you can't use JavaScript on your website, you can alternatively use a deeplink to direct your users to the favorites tool, where they can add your site to their favorites and confirm their selection.
Use the following URL format and replace example.com with your
publication's domain name, which takes users directly to your site in the
favorites tool:
https://www.google.com/preferences/favorites?q=Your_Website's_URLExample text link
<a
href="https://www.google.com/preferences/favorites?q=example.com">
Add to favorites
</a>Example clickable image link
<a
href="https://www.google.com/preferences/favorites?q=example.com">
<img src="path/to/your/button.png" alt="Add to favorites">
</a>Button image assets
You can design your own custom promotion badge or download official translated graphic assets provided by Google: