Help WIth HTML Code Placement for Klarna

New Member
3 0 1

Can anyone help me find where to post the codes given from Klarna on my liquid files? I would like it to be below the add to cart button. Klarna sent me two codes one for basic and one for variant products.

 

thanks!

 

TJ

1 Like
Tourist
12 0 2

Hi TJ,

The appropriate files to place Klarna On-Site Marketing placement tags & refresh code are dependent upon the Shopify theme you are using. For an example, using the Brooklyn theme, both the klarna-placement tag and refresh code are put into product.liquid (or if not, product.liquid usually points to product-template.liquid)

 

Example of placement code:

<klarna-placement data-id="11111111-2222-4b99-aa19-a4e4f619ee5e" data-purchase_amount="{{ current_variant.price }}"></klarna-placement>

 

Example of refresh code (if you have products with variants):

document.getElementsByTagName("klarna-placement")[0].setAttribute("data-purchase_amount", variant.price);
window.KlarnaOnsiteService = window.KlarnaOnsiteService || [] // Making sure that data layer exists in case the On-Site JavaScript library is loaded later for any reason
window.KlarnaOnsiteService.push({ eventName: 'refresh-placements' }) // Push the event to the data layer


Please note, also depending on your theme and section of code, you could use variant.price, current_variant.price, or another liquid variable

1 Like
Tourist
12 0 2

One additional note, Klarna's On-Site Messaging also requires a JavaScript library to be added to the store, for details see: https://developers.klarna.com/en/gb/kco-v3/on-site-messaging

For Shopify, scripts can be added via a PUSH call, see: https://help.shopify.com/en/api/reference/online_store/scripttag

0 Likes
Tourist
10 0 0
Hey!
Should I add Klarna on-site to my site and there are 3 codes to enter 1 instaltion code and 1 update code and the last one is the location code, is this someone who has done this before? I use Boost theme. I will have it on all product pages and under the buy button. Thanks for the reply.
0 Likes
Tourist
12 0 2

As documented at https://developers.klarna.com/en/gb/kco-v3/on-site-messaging, you can get the unique codes for your store from the Klarna Merchant Portal.  Under the On-Site Messaging, you can find your uci (which is used for the JavaScript library) and the placement id(s).   If you need additional support, you can also email shopifysupport@klarna.com

0 Likes
Tourist
10 0 0
Hej! Jo so far I have come but I do not really know where to put the codes, I've been in the program and watched but have tried to put them in the right place, but it does not want to. Vet du hur jag lägger in dem exakt
0 Likes
Tourist
12 0 2

Please email your Shopify store name to shopifysupport@klarna.com and we'll request access to your theme to help you get the codes added.

0 Likes
Tourist
12 0 2

We now have an app to let you add your Klarna On-Site Messaging placements to your Shopify store without have to write code, see: https://x.klarnacdn.net/plugins/Klarna+On-Site+Messaging+app+on+Shopify+-+Merchant+Guide.pdf

0 Likes
Tourist
12 0 2

Support email address is now skosm@klarna.com (instead of shopifysupport@klarna.com)
Support Guide now available at: Klarna On-Site Messaging app on Shopify - Support Guide

0 Likes
Highlighted
Tourist
10 0 0

Hey! Can you help me again? Whit klaran one my site? I want this.

 

and it should be in Swedish. NY hemsida.png

0 Likes