Subscribe with Google


Preferred Sources


Newsletter


Survey


Rewarded Ads


Custom CTA


Reader Registration


Using Extended Access


Syncing Publisher Entitlements to Google


Receiving Entitlements from Google


Cancelling Entitlements Plans or Making Refunds


Content examples

Preferred Sources: Implement with Button

The simplest method for integrating Google Preferred Sources is zero-configuration automatic initialization using a standard <button> element.

Try it out

Below is a live interactive Add Preferred Source button rendered automatically by publisher.js:


How to Implement

  1. Include the publisher.js client library in your HTML page using async or defer.
  2. Place a <button google-add-preferred-source-btn></button> tag anywhere you want the interaction button to render.
  3. Upon load, the active-by-default runtime scans the page for the attribute, inserts an interactive iframe button, and handles all click and confirmation toast events automatically.
<!DOCTYPE html>
<html>
  <head>
    <script async src="https://news.google.com/swg/js/v1/publisher.js"></script>
  </head>
  <body>
    <button google-add-preferred-source-btn></button>
  </body>
</html>
Fork me on GitHub