Documentation / Integration guide / Part 3 of 18

3. The embed

The embed is 1 script and 4 custom elements.

<script type="module" src="https://konto.example.no/embed/v1/embed.js" data-locale="en"></script>

data-locale is optional. It takes en, sv-SE, nb-NO or da-DK. With no value, or with a value that the publication does not offer, the embed uses the language of the market.

The 4 elements

Your server renders the elements. The embed adds no element by itself. Each element holds fallback content, which shows when the script does not run.

Custom elements, attributes and rendered output
ElementAttributesWhat it draws
<norspire-account>knownA Log in link, or an Account link when known is set.
<norspire-meter>free-left, knownThe notice of the free articles that are left.
<norspire-wall>type, article, known, access-key, tier-wallThe registration wall, the offer box, the tier wall, or the card for no answer.
<norspire-legal-links>noneThe link to cancel and the link to withdraw.
  • known has no value. Set it on each element when the answer of the server check has known: true.
  • free-left is the whole number of the answer field freeLeft. Render <norspire-meter> only when freeLeft is not null.
  • type is registration_wall, paywall or unavailable. Copy the value of the answer field access. Use unavailable when the server check gives no answer.
  • article is the article reference of part 7.
  • access-key is the access key that your server sent in the server check of the article. Set it on the wall of each article that you sent with an accessKey. No attribute means paid. Part 5 explains both attributes.
  • tier-wall is the answer field tierWall of the server check. Set it only when tierWall is not null. The value is month or year.

The fallback content

Put fallback content inside each element. It shows with JavaScript off, while the script loads, and when the script cannot reach Norspire.

  • <norspire-wall>: 1 sentence of your site and a link to https://konto.example.no/subscribe?return=<address of the page>. Encode the address of the page. Use the same link for each type.
  • <norspire-account>: a Log in link to https://konto.example.no/login?return=<address of the page>. For known, an Account link to https://konto.example.no/account.
  • <norspire-meter>: the sentence that you want. A meter with a count of 0 shows its fallback content.
  • <norspire-legal-links>: the link to /cancel and the link to /withdraw on the subscription host. Use the 2 labels from the Integration page.
<norspire-wall type="paywall" article="budget-plan">
  <p>This article is for subscribers.</p>
  <a href="https://konto.example.no/subscribe?return=https%3A%2F%2Fwww.example.no%2Farticles%2Fbudget-plan">Subscribe</a>
</norspire-wall>

The 2 failure cases

  • The server check gave no answer. Your server gets no answer in 1 second, an error, or a status other than 200. Send the teaser and <norspire-wall type="unavailable">, and no paid part. When the script loads, the element draws a card that states Norspire cannot check access, with a reload button.
  • The view of the publication failed. The script does not load, Norspire refuses the origin, or the request for the view fails. The element shows its fallback content. The embed draws no card and no retry button.

The look

The elements use the font of your page. They use 1 accent color. Set it on any ancestor of the elements:

:root { --norspire-accent: #c8102e; }

The embed reads the accent and the background of your page. It picks a text color and a fill color that meet a contrast of 4.5 to 1. Do not set another value for the embed.

Your server renders the fade of the teaser above a wall. Use 3 lines of CSS on the teaser:

.fade {
  mask-image: linear-gradient(#000 calc(100% - 150px), transparent);
}

The trust that the tag gives

Read these 4 facts for your own security review.

  1. The trust. The tag runs the script of the subscription host with the rights of your page. The script can read the page, the paid part that your server sent, and each cookie of the page that has no HttpOnly. 1 script serves each publication. A change of the script, or a compromise of the subscription host, reaches each publisher site at the same time.
  2. The integrity rule. Do not add integrity to the tag of /embed/v1/embed.js. Each release changes the file. The browser then refuses the script, and each wall shows its fallback content with no message for the reader.
  3. The page CSP. When your page has a Content Security Policy, add the subscription host to script-src and to connect-src. The embed needs no style-src source and no Trusted Types policy.
  4. Personal data in the address. The elements send the address of your page, with its query, as return to the pages of the subscription host. The checkout stores it. Keep personal data out of the address of a page with an element. For example, do not put an email address in the query of a newsletter link.
Content-Security-Policy: script-src 'self' https://konto.example.no; connect-src 'self' https://konto.example.no

See also the API reference for GET /api/v1/embed/site.