Skip to main content

Documentation Portal

Klarna OSM Integration

Background

Global-e offers a checkout solution for e-commerce retailers looking to expand internationally, partnered with Klarna to enable pay later, slice it, or pay now across the e-stores (“merchants”) where their checkout is displayed.

Global-e owns all claims and liabilities on behalf of their merchants, so Klarna has signed them as a Merchant of Record and not as a partner. Each of the three Klarna regions (EU, US, and OC) has a single MID and credentials managed by Global-e. These credentials have been implemented in Global-e Checkout and are used across all Global-e merchants.

As Global-e only offers the checkout solution, merchants use their platform to manage other pages in the e-stores, this means that Global-e has no direct control over the implementation of Klarna On-Site Messaging (OSM) for the merchants.

The purpose of this section is to provide support for Global-e when working with merchants implementing Klarna OSM in their e-stores. The following guidelines describe the key considerations and best practices for implementation, especially when implementing OSM in multiple markets.

OSM Best Practices

To maximize the performance of the OSM integration merchants should perform the following:

  • Include the JavaScript Library in the code as early as possible. Add it before any content in the html, right after opening the body tag.

  • Load the JavaScript Library “asynchronously”. Make sure that the script has the async attribute set.

  • Avoid using a tag manager.

  • If the merchants' solution relies on templates, make changes in a central file to ensure placements added to other pages will render.

  • If it is a Shopify merchant, other apps may influence the performance of On-Site Messaging. Review installed apps to verify they are all still necessary and review all the resources loaded for the page, such as using the browser’s developer tools.

    Note: Klarna has a Shopify app for On-site messaging or merchants can integrate directly (if the app doesn’t fit the store’s needs), more info: here.

Check out our FAQ page for further information

Global-e considerations

There are several considerations for merchants integrating via Global-e, including but not limited to:

  • If the merchant is integrated locally through another partner, make sure to continue using this script for installation in the appropriate local market, and use the Global-e scripts above, for other locations.

  • The merchant has to handle the site language, by setting the country, currency and locale from the Global-e cookie - GlobalE_Data.

  • Global-e provides price conversions. it is possible to set the converted price in the DOM instead of the native price and set the attributes of its parent element: ge-data-converted-price and ge-data-converted-full-price. If the price has to be converted beforehand, then there is also an option to use Global-e JS external method to retrieve the converted price on client side. If support is required on this issue, merchants should discuss this with Global-e.

The Workflow

Homepage

Inform shoppers about Klarna as early as possible.

Use the top-strip promotion and banners to inform customers about available payment methods.

homepage.png

Product page

Show customers that they can shop now and pay later with Klarna.

Use the payment messaging and let the shoppers calculate their budget before purchasing.

product_page.png

Cart & Checkout

Give the customers the purchase power to finalize the purchase.

Inform customer of their purchase power with messaging tailored to the final order amount.

cart_and_checkout.png
Klarna JavaScript library

The On-Site Messaging (OSM) will only work by adding the JavaScript Library code snippet to all website pages along with the placements in specific places where you want messaging to appear.

Although the exact way merchants edit their e-store may differ depending on the e-commerce solution, the steps described below apply for all websites.

  • Merchants will need access and editing privileges to the source code of your e-store. This is a good point in time to involve a developer in the process.

  • Merchants will also need to know where on the e-store they would like the messaging to appear.

The JavaScript Library is the core part of On-Site Messaging integration. This library is used to communicate between the sub-merchants e-store and On-Site Messaging, and will render the content in the placements tags and not adding it to the merchants site will mean placements are not loaded. The On-Site JavaScript library delivers the core functionality of the On-Site Messaging:

  • Communicating with the On-Site Messaging to deliver messaging for placements.

  • Optimizing the user experience by leveraging a cache layer.

  • Setting cookies in order to assure consistency in delivered messaging.

  • Handling interstitial operations to allow user interaction without affecting the website.

More about how the On-Site JavaScript library works can be read here.

The JavaScript library contains three key attributes, these are:

Attribute

Description

src

Klarna OSM script URL

async

Makes loading the script non-blocking

data-client-id

OSM identifier for merchant configuration

Klarna provides three different Javascript libraries, one of each of the regions that are supported:

  • EU - Europe

  • NA - North America

  • OC - Oceania

Supported Countries

The countries currently supported in each region are listed in the below table:

Region 

Country 

Country Code 

Locales 

EU

United Kingdom

GB

en-GB

EU

Ireland

IE

en-IE

EU

Sweden

SE

sv-SE; en-SV

EU

Finland

FI

fi-FI; en-FI

EU

Norway

NO

no-NO; en-NO

EU

Denmark

DK

da-DK; en-DK

EU

Austria

AT

de-AT; fr-AT; it-AT; en-AT

EU

Germany

DE

de-DE; en-DE

EU

Netherlands

NL

nl-NL; de-NL; en-NL

EU

Belgium

BE

fr-BE; nl-BE; en-BE

EU

Italy

IT

it-IT; en-IT

EU

Spain

ES

es-ES; en-ES

EU

France

FR

fr-FR; en-FR

NA

United States

US

en-US

NA

Canada

CA

en-CA; fr-CA

OC

Australia

AU

en-AU

If merchants are offering Klarna in different markets then they need to handle this in the OSM implementation by using the correct JavaScript library for the consumer. Below are the snippets for the iintegration of Global-e with Klarna:

  • EU (single MID) 

    <script async src="https://osm.klarnaservices.com/lib.js"
    data-client-id="9c8a7017-ad57-55df-836d-614e67e412ee">
    </script>
  • US (single MID) 

    <script async src="https://osm.klarnaservices.com/lib.js"
    data-client-id="4e26337f-8723-5a1d-afad-1246c0aa4914">
    </script>
  • CA (single MID) 

    <script async src="https://osm.klarnaservices.com/lib.js"
    data-client-id="73f3022f-53d7-564a-b876-09be2a1f63af">
    </script>
    
  • OC (single MID) 

    <script async src="https://osm.klarnaservices.com/lib.js"
    data-client-id="701243cb-b680-5e01-ae1e-860e6f262912">
    </script>

Note

If the merchant is integrated locally through another partner, they will need to make sure to continue to use this script for installation in the appropriate local market, and use the Global-e scripts above for other locales.

To refresh placements we need to push an event into the data layer to inform the JavaScript Library the placements on the page have been altered. This should be triggered in the code after a change.

Example 

<script>
window.KlarnaOnsiteService = window.KlarnaOnsiteService || [];
window.KlarnaOnsiteService.push({ eventName: 'refresh-placements' });
</script>
Placements

Placement tags are the HTML tags that decide where to display messaging to visitors on your website. Placements require basic configurations to adjust them for your needs. Some attributes are required and others are optional.

Attribute

Mandatory or Optional

Description

data-key

Mandatory

Identifier for the placemen, uniquely identifies a placement type and size.

data-locale

Optional

Locale of the ad. If not defined, use default locale for country.

data-purchase-amount

Optional

The amount of money in micro units ($120.00 = 12000), used for amount-based credit promotions.

data-inline=”true”

Optional

The attribute will render placements inline in cases where content has been configured for this.

data-preloaded=”true”

Optional

Set when a placement is preloaded. Read more about in Pre-loading placements

data-theme=”default”

Optional

Set a theme to override the default or customized content.

Example of the attributes used in a placement

<!-- Placement v2 -->
<klarna-placement
data-key="credit-promotion-badge"
data-locale="en-GB"
data-purchase-amount="90000"
></klarna-placement>

<!-- end Placement →

It is important to correctly set the locale for the placement, based on the consumers' selection in the e-store.

Note

if the data locale of the placement is not configured for the data-client-id, the placement will not be displayed.

Amount-based Placements

Amount-based placements include the data-purchase-amount attribute. This will deliver messaging with an offering for the specific price provided in micro units, where available. The placements can be used in many places across the website, such as cart view, product details page, product list page, etc.

It is recommended that either of the following data-key should be used:

  • data-key="credit-promotion-badge"

  • data-key="credit-promotion-auto-size"

  • data-key="credit-promotion-small"

Note

  • Some data keys may not be available for all Klarna locales/markets.

  • We do not provide the currency in data-purchase-amount value, currency is based on the sub-merchant configuration for the country and data-client-id.

  • If the placement includes a data-purchase amount the placement will either advise the consumer of the cost when splitting into installments or the minimum amount to spend to use the credit-based product.

Adaptive Width Placements

This type of placement will adjust to 100% of the width of the container element. They are labeled with (auto) instead of a pixel width. For best results, add this type of placement inside elements that span the entire width of the page, and with high visibility for the user: page header, after navigation bar, etc.

Adaptive Height Placements

This type of placement will adjust depending on the length of the content. They are labeled with (auto) instead of a pixel height to minimize the placement size.

One-line content generally renders a default height of 40px. Two lines of content generally render 55px. Some credit promotions require additional legal disclosures and tend to have two or, in some cases, three lines of content.

All responsive placements have an adaptive height. This is to allow the content to display correctly when the placement is constrained by a parent element or through CSS.

For this type of placement, it is recommended to avoid adding a fixed height or overflow: hidden to their container element.

Refreshing placements

There are use cases where we need to refresh the content of the placement on demand. The most popular ones are:

  • Load new content without page refresh (i.e. Ajax) and this new content contains a placement tag.

  • Change the purchase amount for placements dynamically without page refresh.

  • Infinity scroll on the page with dynamically loaded content on scroll.

In those use cases, the JavaScript Library should be informed of changes to trigger messaging delivery for those placements or update the existing content to reflect changes. Our recommendation is to use such script.

Pre-loading placements

Some use-cases require the content to be pre-loaded in the placement before registering the impression. An example of this use case may be loading the ad in a pop-up triggered by a user action. If that is the case we want to have placement pre-loaded to deliver a fast experience, but we want to register the impression only if the content is displayed to the consumer.

To achieve this we need to make sure we do two things:

  • Configure the placement properly.

  • Make sure to fire the impression once a visitor sees the messaging.

To configure placement as pre-loaded we have to add an attribute to the HTML tag called data-preloaded="true".

Once we will have placement configured correctly we have to fire the impression in the code.

Example

window.KlarnaOnsiteService =
window.KlarnaOnsiteService || []
window.KlarnaOnsiteService.push({
eventName: 'placement-impression',
placementKey: 'credit-promotion-standard'

})

Available Placements

Global-e should provide a list of available placements for the sub-merchant based on the region they wish to implement OSM. The list of placements can be accessed from the Merchant Portal for each region.

Common Issues

Outlined below are some of the common issues seen when implementing OSM:

  • OSM requires cookies, if staging does not allow this the placements won't load.

  • Production OSM doesn't show until there has been a purchase on the credentials.

  • Password-protected Staging sites can block the OSM's ability to load.

  • Global modifiers on iframes/restricting the iframe can result in it failing (no OSM showing).

  • Playground and production will usually have different data-client-id, so this should be considered when testing and using OSM in Production.

  • Amounts must be presented in minor units (i.e. $56 should be 5600), and decimals should not be sent.

  • The placement will display the amount fed into it, so if you are displaying both sales and full price ensure you are feeding the correct value into the placement.

  • If payment methods shown do not match those available, ensure you are using the production and not playground placement.

  • Some placements are only available in certain markets or with certain payment methods - so ensure you are pulling from the correct Merchant Portal and trying to just change the data-client-id to get it to work.

    • Example -. credit-promotion-auto-size is not available in the US, and top-strip-banner is not available without pay later).

  • It is best to not use css to hide placements on the page (visibility: hidden) this can lead to the placement loading then disappearing, resulting in the placement appearing to ‘flash’ on the page. Credit-based placements which include amounts will dynamically adapt to the amount used when loading the placement.

    • Example - a credit placement implemented on a PDP with the data-purchase-amount =2500 for a en-GB consumer will display wording “Make 3 easy payments. Available for orders above £35. Klarna. Learn more”.