Add code snippet to your site

To launch Reader Revenue Manager for your publication, you have to set up each page on your site with a code snippet from Publisher Center. This snippet loads Reader Revenue Manager prompts on your site.

To install the snippet, you must have permission to access and edit your site’s theme or template code in your content management system (CMS).

Add a code snippet to your site

  1. Go to Google Publisher Center.
  2. Sign in with a Google Account you use with your publication.
  3. Click Reader Revenue Manager.
  4. Click Add code snippet to your site
  5. If you’ve already completed your setup but haven’t added the code snippet, you can access it under CMS Sync. There are 2 snippet types:
    • Open access snippet:
      • Use this on:
        • Articles that should be open to all readers if you set up a paywall.
        • All articles if you set up contributions or surveys
    • Product ID snippets
      • On the pages you want to paywall, copy the code snippet containing the product ID you want to use.
      • To set different prices for different content types, use product IDs. For example, if you’d like to sell a subscription for your news content and sports content, create 2 separate product IDs to have separate code snippets. The code snippet associated with your sports subscription is added to your sports pages. The code snippet associated with your news subscription is added to your news pages.
  6. Add the snippet to the <head> tag of each page.
  7. To make sure Reader Revenue Manager loads properly, go to your website.

Tips:

  • If you make an update to your price with a new product ID, you must update your CMS Sync on your website.
  • If you have multiple plans active on a single site, you must configure multiple snippets and add each snippet to the relevant content pages. One snippet per page:
    • Configure one snippet for each product ID.
    • Include these product IDs on the:
      • Relevant pages
      • Templates within your CMS

Glossary

Fields

clientOptions

The clientOptions attribute accepts an Object where you can specify theme and language. If you don’t specify a language value, it defaults to your Publisher Center settings. Language codes for this attribute follow ISO 639-1 format.

  • For theme: Specify “light” or “dark.”
  • For lang: Specify the language code, such as “en.”
Example: {theme: 'dark', lang: 'en'}
isPartOfProductID

To specify the pricing plan you want to configure for your page, use the isPartofProductID attribute. This attribute follows the syntax of <PUBLICATION_ID>:<PRODUCT_ID>. You can find your product ID in Google Publisher Center.

To make sure the snippet loads correctly on the page, set the pricing plan to “live.”

isPartOfType

The isPartOfType attribute accepts an array of strings. When you copy the code snippet, the default value for this attribute is set to ["Product"].

type

The type property should fall in line with structured data markup schema. For news publications, use NewsArticle — more information is available on Schema.org.

Example code snippet


JavaScript

<script async type="application/javascript"

        src="https://news.google.com/swg/js/v1/swg-basic.js"></script>

<script>

  (self.SWG_BASIC = self.SWG_BASIC || []).push( basicContributions => {

    basicContributions.init({

      type: "NewsArticle",

      isPartOfType: ["Product"],

      isPartOfProductId: "<PUBLICATION_ID>:<PRODUCT_ID>",

alwaysShow: true,

      clientOptions: { theme: "light", lang: "en" },

    });

  });

</script>
Search
Clear search
Close search
Google apps
Main menu
13241246760660417696
true
Search Help Center
true
true
true
true
true
100499
false
false