Developers

The badge on your site

The PeopleWritten Verified badge can go beside a verified piece on any site that runs scripts. You decide where it sits. Because it reads the piece before it shows itself, you also have to tell it where the text is.

How the badge decides

Every time the page loads, the badge script:

  1. Reads the text of the element you pointed it at.
  2. Keeps only the printable characters, in order. Spaces, line breaks and invisible characters are ignored, so a CMS that rewraps the text or changes the markup doesn’t matter. Every character a reader can see does.
  3. Sends a fingerprint of that text (a SHA-256 hash) to PeopleWritten. The text itself never leaves the page.
  4. Only if the fingerprint matches the verified version does PeopleWritten send the badge. Otherwise nothing appears, and the browser console says why.

It keeps watching. If the text changes the badge hides, and it comes back if the text changes back. So the badge needs two things from you: somewhere to appear, and the element that holds the piece.

1. Get the code

Each verified piece has its own certificate and its own code. The writer finds it on their account page, under “Your verified pieces”, ready to copy. If you’re placing a badge for someone who writes for you, ask them for it. The certificate ID is also the last part of the piece’s record link: https://peoplewritten.com/v/CERTIFICATE_ID.

2. Place the badge

Put this where the badge should appear: under the byline, at the end of the piece, in a sidebar.

Where the badge goes
<div data-peoplewritten-certificate="CERTIFICATE_ID"></div>
<script async src="https://peoplewritten.com/embed/certificate/v1.js"></script>
  • The badge takes the width of its element, up to the size the writer chose, and lines itself up within it, on the left, centre or right as the writer chooses. In a narrower element it’s drawn smaller, and with less than 40px it isn’t shown at all: see Sizes.
  • Use a <div> or a <span>. The badge draws itself inside the element, which elements like <a>, <img> and <li> can’t hold.
  • It can sit inside the article. Its own element is left out when the text is read.
  • The script tag goes anywhere on the page, once, however many badges there are. With async it never holds up the page.

3. Point it at the text

The text the badge reads has to be the piece exactly as it was verified: the body, without the title, the byline, the date or anything else your template puts around it. There are two ways to point it there.

Mark the element that holds the piece

If you can add an attribute to the element that holds the body of the piece, do that:

On the element that holds the text
<div class="post-body" data-peoplewritten-article="CERTIFICATE_ID">
  …the piece…
</div>

Or give the badge a selector

If your CMS doesn’t let you touch the article’s markup, point the badge at it with any CSS selector. The badge uses the match nearest to it: an element around the badge that matches, or else the first inside the closest element around the badge that has one, so on a page with several posts, each badge inside a post reads that post.

On the badge
<div data-peoplewritten-certificate="CERTIFICATE_ID" data-article=".entry-content"></div>

Most WordPress themes put the body of a post in .entry-content, and Ghost’s own themes in .gh-content. Themes differ, so check with your browser’s inspector: right-click the first paragraph of the piece, choose Inspect, and look for the element that holds every paragraph and nothing else.

Leave out what isn’t the piece

Anything inside the article that isn’t part of the piece counts as text and stops the match: an ad slot, a newsletter sign-up box, share buttons, “related posts”, a pull quote your template repeats. Mark each one and it’s skipped:

<aside class="newsletter" data-peoplewritten-ignore>…</aside>

For what other scripts put in the article, which you can’t mark in advance, such as ads placed automatically, give the badge a selector instead. Anything matching it is skipped:

On the badge
<div data-peoplewritten-certificate="CERTIFICATE_ID" data-ignore=".adsbygoogle, .google-auto-placed"></div>

When your site changes covers ads, plugins and the rest in more detail.

A piece exported from the PeopleWritten app ends with its verification line, “PeopleWritten Verified” and a link. The badge reads past it, marked data-peoplewritten-ignore (as the HTML export does) or not, as long as it still reads “PeopleWritten Verified:” followed by the piece’s address.

Scripts, styles and <template> elements are skipped without being marked. Charts drawn in the PeopleWritten editor aren’t part of the verified text either, so if you publish one with the piece, mark it too.

4. Check it works

Open the published page. The badge should appear within a second. If it doesn’t, open the browser’s console (in most browsers, right-click the page, choose Inspect, then Console). Every message from the badge starts with “PeopleWritten:”.

The console saysWhat to do
the text on this page doesn’t match certificate …, with more characters here than in the verified textSomething that isn’t the piece is inside the element: usually the title, the byline, a caption or a sign-up box. Point the badge at a narrower element, or mark the extra with data-peoplewritten-ignore.
…with fewer characters herePart of the piece is missing: a “read more” cut, a section loaded later, or a template that splits the body across several elements. Point the badge at an element that holds all of it. Or characters were merged: WordPress turns -- into a dash and three full stops into an ellipsis.
…with the same number of charactersSomething changed characters as the piece was published. WordPress, for one, turns straight quotes into curly ones. Publish the text exactly as it was verified.
no text found for certificate …There’s no element marked data-peoplewritten-article with that ID, or the data-article selector matches nothing. Check for typos. If the article is added to the page later, the badge finds it when it arrives.
“…” is not a certificate idThe ID in data-peoplewritten-certificate was mistyped or cut short. Copy the code again.
the badge for certificate … has …px of room, less than the …px it needsThe badge’s element is too narrow, often a column on a phone or an item squeezed in a flex row. Give it the width the message names, or more. See Sizes.
data-ignore on the badge for certificate … isn’t a selectorFix the selector in data-ignore. Until then, nothing extra is skipped.
the badge for certificate … needs an element that can hold itPut the badge on a <div> or <span>.
Nothing at allThe script didn’t load. Check the script tag, and your Content-Security-Policy (below). A site that puts custom HTML in a frame of its own can’t show the badge, because the badge can’t see the article from inside the frame: publish the piece with its verification line. Other messages, such as a withdrawn certificate or PeopleWritten out of reach, are in Troubleshooting.

How it looks

The writer chooses how their badges look, on their account page, with a live preview drawn by the same script your page loads:

  • Layout: the round stamp on its own, or a smaller stamp with its name beside it, for bylines.
  • Size: small, medium or large: the largest the badge is drawn. See Sizes.
  • Colour: any colour. White is for dark backgrounds.
  • Alignment: left, centre or right within the element you placed.
  • Hover card: light, dark, or following the reader’s device.

A change applies to every one of the writer’s badges, on every site, the next time each page loads. You don’t need to change your code. The badge draws itself in a closed shadow root, so your page’s CSS can’t restyle it, and the wording on it and on its hover card is the same everywhere. You control only where it goes and how much room it has.

Sizes

The writer’s size is the largest the badge is drawn. In less room it’s scaled down, and as it gets smaller the drawing changes, so it stays legible rather than shrinking into a blur:

  • The seal, with “Human authorship verified by PeopleWritten” lettered round its edge, needs 96px across. Below that the lettering is too small to read, so it becomes the ring.
  • The ring has no lettering, and is used from 95px down to 40px.
  • Stamp and name needs 170px for the name to be read. Below that it becomes the stamp alone.
  • Under 40px, nothing is shown, and nothing is loaded. The PeopleWritten mark can’t be drawn clearly any smaller, and a badge readers can’t recognise, or easily tap, does more harm than none. The console says how much room it had.
The writer’s settingFull size (px)In the width its element gives it
Stamp, small64 × 6440px and up: the ring
under 40px: not shown
Stamp, medium96 × 9696px and up: the seal
40–95px: the ring

under 40px: not shown
Stamp, large128 × 12896px and up: the seal
40–95px: the ring

under 40px: not shown
Stamp and name, small187 × 44170px and up: stamp and name
40–169px: the stamp alone

under 40px: not shown
Stamp and name, medium238 × 56170px and up: stamp and name
40–169px: the stamp alone

under 40px: not shown
Stamp and name, large289 × 68170px and up: stamp and name
40–169px: the stamp alone

under 40px: not shown

The badge measures its element all the time, so a column that narrows on a phone, or a layout that changes as the page is used, gets the right drawing without a reload. You can’t make the badge bigger than the writer’s size, but you can make it smaller by giving it less room.

Recommended sizes

Where it goesSettingGive its element
Under the headline, or at the end of the pieceStamp, medium or largeAt least 96px wide, so it’s the seal, with its lettering
In the byline, beside the writer’s nameStamp and name, small or medium187px or 238px for its full size; at least 170px to keep the name
A narrow sidebar, or a compact byline on phonesStamp, small64px
Lists of articles, cards, teasers, feedsNoneThe badge only appears beside the whole piece, because it has to read it. Put it on the piece’s own page.

The writer chooses the setting. If you publish several writers in one template, tell them which suits it.

  • In a flex row or a grid, the badge can be squeezed like an image. To keep it at its full size, give its element flex: none or a width.
  • If its element is hidden, with display: none or inside a closed menu, the badge waits and is drawn when the element is shown.
  • The badge takes up no height until it appears. If you’d rather the text didn’t move when it does, give its element a min-height of the badge’s height.

When your site changes

The badge reads the article again whenever it changes, and hides as soon as the text there isn’t the verified text. That’s the point of it, but it means anything that later adds visible characters inside the article hides the badge too, on every piece at once. Almost every badge that stops appearing was working until something was added to the page. Set the page up so the article holds the piece and nothing else, and the badge keeps working through redesigns, new plugins and new ads.

A layout that keeps working

A post template
<article>
  <h1>…</h1>
  <p class="byline">…</p>

  <div data-peoplewritten-certificate="CERTIFICATE_ID"
       data-ignore=".adsbygoogle, .google-auto-placed"></div>

  <div class="post-body" data-peoplewritten-article="CERTIFICATE_ID">
    …the piece, exactly as verified…
    <div class="ad-slot" data-peoplewritten-ignore>…</div>
    …
  </div>

  <!-- After the piece, not inside it -->
  <aside class="share">…</aside>
  <aside class="related-posts">…</aside>
</article>
  • Mark the article in the template with data-peoplewritten-article, rather than relying on a class name. A new theme can rename .entry-content; it won’t remove an attribute you put in your own template.
  • Keep everything that isn’t the piece outside the article element: share buttons, sign-up boxes, the author’s bio, related posts, comments.
  • Inside the article, mark what you place there yourself with data-peoplewritten-ignore, and name what other scripts add with data-ignore on the badge.

Ads in the body of the piece

Images, iframes and videos have no text, so an ad that’s only those changes nothing. But most ads come with a label, “Advertisement” or “Sponsored”, and that’s text: the badge hides when the ad loads.

  • Ads in slots you place, between paragraphs in your template or by your CMS: mark each slot data-peoplewritten-ignore. Whatever loads inside it later is skipped.
  • Ads placed automatically, where the ad network chooses the spot (Google AdSense Auto ads, for one, adds .google-auto-placed and ins.adsbygoogle): add their classes to data-ignore on the badge. For another network, load a page with ads, inspect one, and use the class on its outermost element.
  • Ads that change while the page is open, refreshing or rotating, are skipped the same way. Nothing in a skipped element is ever read.

Plugins

Plugins that add to the end of every post, such as related posts, share buttons, a “reading time”, a sign-up box or an author bio, usually put it inside the post’s content element. Most let you turn off adding it there and place it in the template instead. Otherwise add its class to data-ignore (on WordPress, Jetpack’s are .sharedaddy and .jp-relatedposts).

Text your site rewrites

Some tools change the text of every page as it’s served or shown. The badge sees the changed text:

  • Quotes and dashes. WordPress turns straight quotes into curly ones and -- into a dash. Publish the piece exactly as it was verified.
  • Email addresses. Cloudflare’s Email Address Obfuscation serves each address in a page as “[email protected]” and puts it back with a script. The badge appears once that script has run, and not if it doesn’t. For a piece that contains an address, it’s simpler to turn the feature off.
  • Translation. A translation widget or the reader’s browser translating the page changes every word, so the badge hides for those readers. That’s right: what they’re reading isn’t the verified text.
  • Soft hyphens added for hyphenation, extra spaces, line breaks and markup don’t matter.

Pieces that load in parts

The badge reads what’s in the page, whether or not it’s visible, so a piece collapsed behind “Continue reading” is fine if all of it is in the page. If the rest is fetched when the reader asks for it, the badge appears once it has arrived.

Until the text first matches, the badge asks PeopleWritten about each new version of it, up to ten times on one page load, and then stops asking until the page is reloaded. Once it has matched, it asks nothing more: it compares the article with the verified text itself, hiding and showing as the article changes. So a page that changes the article over and over as it loads, with a live counter or a timestamp inside it, can use up those checks before the piece is complete. Keep such things outside the article, or mark them.

Scripts that delay other scripts

Some speed-up tools hold back scripts until the reader scrolls or taps, so the badge appears late. Leave the badge’s script out of them: in WP Rocket, add it to the exclusions for delaying JavaScript; for Cloudflare Rocket Loader, add data-cfasync="false" to its script tag.

After a change

After a redesign, a new plugin or a new ad network, open a piece with a badge and look at the console. If the badge is missing, the console says why, and says how many printable characters it found against how many were verified: more here usually means something was added inside the article.

Content-Security-Policy

If your site sends a Content-Security-Policy, it has to let the badge load its script, check the text and show its image. Add PeopleWritten to these directives, alongside what’s there already:

script-src https://peoplewritten.com;
connect-src https://peoplewritten.com;
img-src https://peoplewritten.com;

The badge’s styles are constructed stylesheets, which style-src doesn’t block. Browsers without them (Safari before 16.4) fall back to a <style> element, which a strict style-src does block: on those the badge appears unstyled.

If your policy requires Trusted Types, add peoplewritten-badge to its trusted-types directive. The badge loads its hover card’s script through a policy of that name; without it, the badge appears without its card.

Single-page apps

The badge notices when badges or articles are added to the page, removed or swapped, and checks again. In React, Vue, Svelte and the like, render the badge’s element as part of the piece and load the script once:

React
function VerifiedBadge({ certificate }) {
  return <div data-peoplewritten-certificate={certificate} data-article="#piece" />;
}

// Once, e.g. in your root layout:
// <script async src="https://peoplewritten.com/embed/certificate/v1.js"></script>

To look for new badges straight away rather than on the next change to the page, call window.PeopleWrittenCertificates.refresh().

Corrections, paywalls, several badges

Corrections

The badge matches every version of a piece the writer has had verified. If you publish a correction, the badge hides until the writer has the corrected version verified, then comes back without any change to your code. If the writer corrects the piece and you don’t, your badge stays: it matches the version you published, and its hover card says the piece has been updated since. The record counts the update.

Paywalls

The badge has to read the whole piece, so it appears for readers who can see the whole piece and stays hidden for those who see a preview. The record it links to never shows the text.

Several badges on one page

Give each badge its own piece, with its own ID on the badge and on the element holding its text, or its own data-article selector. One script tag serves them all.

What PeopleWritten keeps

Each check is counted: which piece, which site and the day. Nothing about the reader is kept, and the text is never sent, only its fingerprint. See Privacy.