SourceCue Button for Google Preferred Sources

Plugin Banner

SourceCue Button for Google Preferred Sources

by souravpan

Download
Description

SourceCue Button for Google Preferred Sources helps publishers give readers a clear way to add an eligible domain or subdomain as a preferred source in Google Search.

This is an independent plugin. It is not affiliated with, endorsed by, or sponsored by Google.

The plugin supports the three implementation approaches documented by Google Search Central:

  • Standard JavaScript button: Google’s recommended automatically localized interactive button.
  • Advanced JavaScript button: a customizable site-owned button that starts Google’s Preferred Sources flow.
  • Deeplink: a normal link to Google’s source preferences tool, rendered as text or an official translated badge.

Key features include:

  • Gutenberg block and [psbgs_preferred_source] shortcode.
  • Automatic inline insertion before content, after content, or both.
  • Sticky top banner, sticky bottom banner, and floating alert.
  • Display rules for sitewide, posts, pages, front page, selected public post types, and custom exclusions.
  • Searchable category and individual-content exclusions.
  • Immediate, time-delay, and scroll-percentage display triggers.
  • Desktop, tablet, and mobile visibility controls using responsive CSS.
  • Dismissal controls using browser sessionStorage/localStorage rather than dismissal cookies.
  • Simple inline output or a customizable inline card with title and subtitle.
  • Six editable custom-button style presets, gradients, border controls, spacing, and typography.
  • {site_name} and {domain} variables in promotional text.
  • Official translated Preferred Sources badge assets in 17 languages, with light/dark and 1x/2x variants.
  • Official badge widths from 40 to 676 pixels.
  • Optional local click counter with configurable text and appearance.
  • Optional local analytics with 30-day reporting for impressions, clicks, dismissals, CTR, implementation, placement, and integration source.
  • Optional cache purge integration for detected popular WordPress caching plugins.
  • Data Management controls for analytics clearing, click-counter reset, settings reset, and uninstall cleanup preference.
  • Conditional/minified front-end assets and no jQuery dependency.
  • Developer action, filters, and PHP helpers.

Google controls Preferred Sources eligibility. Installing this plugin does not make a site eligible and does not guarantee rankings, traffic, or visibility.

Shortcode

Basic usage:

[psbgs_preferred_source]

Examples:

[psbgs_preferred_source mode="standard" theme="dark" align="center"]

[psbgs_preferred_source mode="custom" label="Add {site_name} as a Preferred Source"]

[psbgs_preferred_source mode="deeplink" deeplink_style="official_badge" badge_theme="dark" badge_lang="hi" badge_width="160"]

[psbgs_preferred_source mode="standard" presentation="alert" alert_position="bottom_right" trigger="scroll" scroll="35"]

[psbgs_preferred_source inline_style="card" inline_title="Stay connected with {site_name}" inline_subtitle="Add {domain} as a preferred source in Google Search."]<h3>External services</h3>

This plugin integrates with Google’s Preferred Sources service. The external service is required only for the Google functionality selected by the site administrator.

Google Preferred Sources JavaScript SDK

When the Standard or Advanced JavaScript implementation is rendered, the visitor’s browser loads Google’s Preferred Sources publisher library from:

https://news.google.com/swg/js/v1/publisher.js

This browser request is made to Google and may transmit information normally included in a web request, such as the visitor’s IP address, user agent, and referrer, according to Google’s policies. The plugin does not proxy or store that request.

The SDK is not loaded for the text-deeplink or locally served official-badge implementation unless another interactive Preferred Sources element on the same page requires it.

Google source preferences

Preferred Sources actions ultimately use Google’s source preferences service at:

https://www.google.com/preferences/source

For deeplink mode, the configured source domain is included in the q query parameter when the visitor follows the link. Standard and Advanced modes use Google’s documented interactive flow.

Service documentation: https://developers.google.com/search/docs/appearance/preferred-sources

Google Privacy Policy: https://policies.google.com/privacy

Google Terms of Service: https://policies.google.com/terms

Privacy

Local analytics is disabled by default. When enabled, the plugin stores aggregated daily counters in the site’s WordPress database. It does not store IP addresses, visitor IDs, WordPress user IDs, cookies, or individual page-view rows for analytics.

The optional public click counter stores one aggregate integer. A click is not presented as proof that the visitor completed the selection inside Google.

Dismissal preferences use browser sessionStorage or localStorage, depending on the configured behavior.

The Google external-service behavior is described in the External services section above.

By default, uninstalling/deleting the plugin removes its settings, public click counter, analytics database-version option, and custom analytics table. Administrators can disable this cleanup in Settings > Preferred Sources > Advanced & Usage > Data Management when they intentionally want to retain the database records for a later reinstall. Scheduled plugin events are always removed during uninstall.

Third-party assets

The plugin includes translated Preferred Sources badge image assets supplied by Google Search Central from the Preferred Sources documentation page:

https://developers.google.com/search/docs/appearance/preferred-sources

Google explicitly provides these translated badge assets for the Preferred Sources implementation described on that page. Google’s general Developers site license applies to page content, but Google’s site policies separately reserve Google trademarks and brand features and note that images may have separate terms. This plugin therefore does not claim that the Google logo or other Google brand features are licensed under CC BY 4.0. See THIRD-PARTY-LICENSES.txt for the source and trademark notice.

The badge files are included unchanged solely to implement Google’s documented Preferred Sources deeplink experience. Google, the Google logo, and related marks are trademarks of Google LLC. Inclusion of these assets does not imply affiliation, endorsement, or sponsorship of this plugin by Google.

Developer API

PHP echo helper:

psbgs_preferred_source_button( array( 'mode' => 'standard', 'align' => 'center' ) );

PHP return helper:

$html = psbgs_get_preferred_source_button( array( 'mode' => 'deeplink' ) );

Action:

do_action( 'psbgs_preferred_source_button', array( 'presentation' => 'sticky_bottom' ) );

Selected filters:

  • psbgs_default_settings
  • psbgs_settings
  • psbgs_button_args
  • psbgs_button_html
  • psbgs_deeplink_url
  • psbgs_badge_language
  • psbgs_badge_asset_urls
  • psbgs_supported_post_types
  • psbgs_should_auto_display
  • psbgs_analytics_retention_days
  1. Upload the plugin ZIP from Plugins > Add New > Upload Plugin, or install it from WordPress.org after publication.
  2. Activate “SourceCue Button for Google Preferred Sources”.
  3. Go to Settings > Preferred Sources.
  4. Confirm the source domain or subdomain and choose an implementation method.
  5. Configure display rules, presentation, and optional analytics.
  6. Save the settings and test the result on the front end.
Is this plugin affiliated with Google?

No. It is an independent WordPress plugin that implements Google’s publicly documented Preferred Sources methods.

Does the plugin make my site eligible for Preferred Sources?

No. Google controls eligibility. Preferred Sources eligibility is domain/subdomain based, and a subdirectory such as example.com/blog is not a separately eligible source.

Which implementation should I use?

Google recommends the Standard JavaScript implementation. Use Advanced when you need a custom button design, or Deeplink when you want a regular link or locally served official badge.

Does this improve search rankings?

The plugin does not guarantee rankings or traffic. It only provides controls that help readers access Google’s Preferred Sources feature.

Does the plugin track visitors?

Optional analytics is disabled by default and uses aggregate local counters only. It does not build visitor profiles. Standard and Advanced modes do load Google’s documented external SDK when rendered; see External services for details.

Does the public counter show confirmed preferred-source selections?

No. It counts clicks on the Preferred Sources action. Google does not provide this plugin with a confirmed-completion callback for a successful selection.

Does the plugin use cookies for banner dismissal?

No. Dismissal settings use browser sessionStorage/localStorage.

Does it work with caching plugins?

The front-end visibility rules are designed to be cache friendly. The plugin also offers an optional cache purge after its settings are saved when a supported cache plugin is detected.

Does it require jQuery?

No.

What happens to plugin data when I uninstall it?

Full cleanup is enabled by default. Deleting the plugin removes its settings, public click counter, analytics database-version option, custom analytics table, and scheduled plugin events. You can turn off database cleanup in Advanced & Usage > Data Management if you intentionally want to keep the stored settings and analytics for a later reinstall. Scheduled plugin events are always removed because the plugin code will no longer be present.

1.6.21

  • Resolved Plugin Check warnings for the Google SDK resource declaration and readme short-description length.

1.6.20

  • Renamed the plugin to SourceCue Button for Google Preferred Sources and updated the WordPress.org package identity and translation domain.

1.6.19

  • Updated plugin branding and translation domain for WordPress.org directory compliance.
  • Reworked frontend debug diagnostics to use the registered frontend JavaScript instead of directly printed script markup.
  • Updated Google SDK loading to use WordPress’s native async script strategy.

1.6.18

  • Fixed Gutenberg block selection by using the Block Editor useBlockProps() wrapper required for normal selection, toolbar, move, and remove behavior.
  • Reworked the editor-only placeholder to stay compact and centered instead of stretching across the full editor canvas.
  • Kept the server-rendered front-end block output and all existing block attributes unchanged.

1.6.16

  • Final WordPress.org submission audit and package cleanup.
  • Raised the minimum WordPress version to 6.3 to match Gutenberg Block API v3 requirements.
  • Improved multisite uninstall cleanup so each site honors its own data-retention setting while scheduled plugin events are always cleared.
  • Unschedules analytics cleanup automatically when local analytics is disabled.
  • Resets the promotion dismissal revision when plugin settings are reset, preventing stale browser dismissal state from hiding a fresh default configuration.
  • Clarified Google badge attribution and trademark wording without making unsupported licensing claims.

1.6.15

  • Enhanced frontend stylesheet theme isolation for banner, alert, and close dismissal controls.
  • Added high-specificity defensive resets to prevent aggressive third-party themes from overriding button styling.
  • Bumped asset cache version to ensure immediate cache invalidation across all browsers and CDN layers.

1.6.13

  • Resolved WordPress 6.7+ Just-In-Time translation loading notice by guarding early defaults and badge language queries prior to the init action.
  • Deferred analytics settings verification and background cron check to the init hook.
  • Modernized SQL database identifier escaping in the atomic counter update query using $wpdb->prepare %i placeholder.
  • Added full multisite network cleanup support to uninstall.php across all sub-sites.
  • Standardized internationalization sentence formatting and translators comment in the analytics dashboard chart tooltip.
  • Cleaned up redundant CSS rules and synchronized minified production stylesheets.
  • Prepared full compliance packaging for WordPress.org Plugin Directory submission under contributor profile souravpan.

1.6.12

  • WordPress.org Plugin Check compliance improvements for security, internationalization, block API compatibility, asset naming, database queries, resource versioning, and third-party cache integrations.

1.6.11

  • Fixed Standard Google button alignment on the live frontend so Banner / Alert and Inline left/center/right alignment applies to Google’s rendered declarative button container.

1.6.10

  • Updated fresh-install defaults to the requested Deeplink/official-badge, automatic display, inline, and floating-alert configuration.
  • Removed the custom interactive button shadow option and its renderer, preview, preset, and styling code.

1.6.9

  • Improved Sticky Top and Sticky Bottom banner layout so the promotional copy and action are centered as a compact group by default.
  • In sticky banners, the public click counter now appears directly below the promotional message instead of above or below the Preferred Sources action.
  • Counter placement for inline content and floating alerts is unchanged.
  • Updated the live preview to match the sticky-banner counter layout.

1.6.8

  • Added universal Inline button alignment (Left, Center, Right) for all implementation methods.
  • Added universal Banner / Alert button alignment (Left, Center, Right) for Sticky Top, Sticky Bottom, and Floating Alert.
  • Removed the implementation-specific Alignment control from Advanced Custom Interactive Button settings.
  • Fixed Hide counter when it is zero so zero remains hidden in frontend output and after JavaScript counter refreshes.
  • Reworked the Live Preview into separate Inline and Banner / Alert preview sections and widened the preview column for clearer rendering.

1.6.7

  • Restored the Inline placement selector as an always-visible control under Presentation.
  • Inline placement can be configured as Before content, After content, or Before and after content even before Inline is enabled.
  • No frontend placement or rendering features were removed.

1.6.6

  • Added independent Inline automatic placement plus one optional global promotion.
  • Inline can run together with Sticky Top, Sticky Bottom, or Floating Alert.
  • Only one banner/alert can be selected at a time, preventing banner/alert conflicts.
  • Existing 1.6.5 presentation choices are mapped safely to the new controls.

1.6.5

  • Removed all pre-directory settings/database migration code so this release behaves as a standalone fresh plugin.
  • Restored the simple v1.5-style boot lifecycle.
  • Moved automatic sticky-bottom/alert footer rendering to an earlier footer priority so markup exists before footer scripts execute.
  • Improved automatic inline compatibility by guarding against secondary content using the queried post ID instead of requiring in_the_loop() and is_main_query().
  • Added an opt-in Frontend Debug Mode under Advanced & Usage. It logs [PSBGS] rendering decisions and prints a browser-console DOM diagnostic snapshot.
  • Kept the canonical [psbgs_preferred_source] shortcode and current block namespace only; no legacy settings migration is performed.

1.6.4

  • Removed the custom interactive button icon feature completely.
  • Removed icon choice, icon position, icon style, trailing notification badge text, and badge color controls from the admin UI.
  • Removed icon/notification preview logic, SVG renderer markup, and related front-end/admin CSS.

1.6.1

  • Added an Advanced & Usage > Data Management section.
  • Added an enabled-by-default option to delete all plugin database data on uninstall, with an administrator-controlled retention choice.
  • Added a manual Clear analytics data action that removes aggregate rows while keeping the analytics table ready for future tracking.
  • Added a Data Management public click-counter reset control.
  • Added a Reset plugin settings action that restores defaults without deleting analytics or public click counts.
  • Added nonce/capability protection and confirmation prompts for destructive data-management actions.
  • Scheduled analytics cleanup events are always removed during uninstall, even when database retention is enabled.

1.6.0

  • Prepared the plugin for WordPress.org directory submission.
  • Prepared directory naming to use Google descriptively rather than as the initial brand term.
  • Changed globally accessible PHP identifiers, options, hooks, AJAX actions, asset handles, and block namespace to the five-letter psbgs/PSBGS prefix.
  • Added front-end AJAX nonces for optional local analytics and the public click counter.
  • Added activation/deactivation cleanup for scheduled analytics maintenance.
  • Added explicit external-service, privacy, third-party asset, trademark, and license documentation.
  • Updated the text domain, folder conventions, block namespace, canonical shortcode, and readme metadata for the proposed WordPress.org slug.
  • Updated compatibility metadata for WordPress 7.1.

1.5.1

  • Moved public click-counter settings to the Presentation tab.
  • Updated custom-button presets to use Preferred Sources-appropriate preview text and no preset-specific icons or notification count.

1.5.0

  • Added customizable public click counter.
  • Added editable custom interactive button templates with advanced border and gradient controls.
  • Reduced the official badge minimum width to 40px.

1.4.0

  • Added optional local aggregated analytics, cache integration, and conditional/minified production assets.

1.3.0

  • Added advanced display rules, triggers, sticky bottom banner, device controls, live preview, inline card mode, variables, and tabbed settings.

1.2.0

  • Added sticky top banner and floating alert presentation modes with dismissal controls.

1.1.0

  • Added official translated Google Preferred Sources badge assets with locale mapping, light/dark variants, and Retina support.

1.0.0

  • Initial plugin with Standard JavaScript, Advanced JavaScript, and Deeplink implementations plus shortcode, block, automatic placement, action hook, and PHP helpers.
Back to top