Storefront extensions

Add your app to a store's storefront with app blocks, hosted surfaces and app embeds.

An app adds to the storefront in three ways, all declared in tringify.app.json and frozen into each release. Changing a declaration reaches a store only when it installs or updates to a release that contains it.

Extension

What it is

Who places it

App block

A Vascula block the merchant adds to a theme section, on the pages it lists. A template block renders in the page itself; a hosted_surface block also opens one of your hosted surfaces; a partner_script block also shows a reviewed vendor's widget (Partner scripts, below). See App blocks.

The merchant, in the theme editor, in sections that accept app blocks.

Hosted surface

A page on your server that the storefront shows in an isolated frame, inline, as a drawer, a modal or a sticky bar. It can read and change the cart only through commands you declare. See Hosted surfaces.

Opened by an app block, or by a popup embed when one of your campaigns triggers.

App embed

Vascula markup on every page, a popup that opens one of your hosted surfaces when your campaigns say so, or a tracking pixel.

Vascula embeds and popups: the merchant, under App embeds in the theme editor, or the app for the whole store. Pixels: the merchant, in Online Store › Pixels, or the app for the whole store.

App blocks, hosted surfaces and Vascula embeds never appear in checkout or order confirmation. Pixels are different: they run there to observe checkout events, always in an isolated frame. A sandboxed pixel uses its frame, and a page-runtime pixel the frame_url it declared for these pages; without one it is left out. No app code runs in the checkout page itself. Nothing an app adds to the storefront can stop a shopper checking out: a pixel that cannot be built is left out of the page.

App blocks#

json
"storefront_blocks": [
  {
    "key": "size-guide",
    "name": "Size guide",
    "description": "Opens a size finder under the product's options.",
    "mode": "hosted_surface",
    "pages": ["product"],
    "surface_key": "size-guide",
    "source": "{% schema %}\n{\"name\": \"Size guide\", \"kind\": \"block\", \"settings\": [{\"id\": \"label\", \"type\": \"text\", \"default\": \"Find your size\"}]}\n{% endschema %}\n<p class=\"tf-ab-small tf-ab-muted\">{{ settings.label }}</p>"
  }
]

Field

Meaning

key

Lowercase letters and digits joined by - or _, up to 40 characters. It identifies the block in themes, so keep it stable across releases.

name

What merchants see in the theme editor. Up to 80 characters.

description

What the block shows, for merchants in the theme editor. Up to 300 characters.

mode

template (rendered into the page, no frame) or hosted_surface (its markup, then a hosted surface). A key keeps its mode across releases.

pages

The page types it may be placed on: product, collection, cart, page, account, blog, home. These seven are the only ones; see App blocks.

surface_key

hosted_surface blocks only: the hosted surface this block opens. It must be declared in the same release.

source

A complete Vascula block, up to 128 KB, with "kind": "block" in its schema. A template block may read shop, routes, product and collection through ctx_needs; a hosted_surface block may also read cart. Its markup follows the app markup policy and styles with the tf-ab-* classes. See App blocks.

An app can declare up to 10 blocks. Merchants can add them to sections whose schema sets accept_app_blocks, in templates of the pages the block lists. The storefront renders the block's markup and, for a hosted_surface block, then mounts its surface directly after it.

A hosted surface is a page on your server that the storefront shows in an isolated frame, opened by a hosted_surface app block. It is the only way for an app to show something shoppers interact with, and it reads and changes the cart only through the commands it declares. See Hosted surfaces for the declaration, commands, context, launch token and the surface bridge.

Partner scripts#

Some vendors' widgets must run first-party in the store's page and cannot run in a frame, such as Klarna's on-site messaging ("Pay in 3 interest-free payments of €33.33"). Apps never ship scripts, so Tringify reviews such a vendor once and lists it as a partner script: its exact script, the one element it renders and what fills that element's attributes. Your app opts in with a partner_script app block, and stores the merchant's settings for it (such as a client identifier). The storefront renders the vendor's element in place of the block, with the price of the selected variant on a product page or the cart total on the cart page, loads the vendor's script once for the page after the shopper's consent for its category, and updates the element when the shopper picks another variant or changes the cart.

json
"storefront_blocks": [
  {
    "key": "product-messaging",
    "name": "Klarna messaging",
    "mode": "partner_script",
    "pages": ["product"],
    "partner_script": "klarna-messaging",
    "placement": "credit-promotion-badge",
    "source_file": "blocks/product-messaging.vasc"
  }
]

// blocks/product-messaging.vasc
{% schema %}
{"name": "Klarna messaging", "kind": "block", "settings": []}
{% endschema %}

Store the merchant's settings with your app token. Only an app whose installed release declares a partner_script block for the key may; the settings are checked against the partner script's fields. Until settings are stored, the block renders only your markup. Uninstalling the app deletes them.

bash
curl -X PUT https://api-store.tringify.com/api/2025-01/partner-scripts/klarna-messaging \
  -H "Authorization: Bearer APP_TOKEN" -H "Content-Type: application/json" \
  -d '{"config": {"client_id": "klarna_test_client_…", "environment": "playground"}}'

# GET, and PUT, return {"script_key", "config", "updated_at", "origins"} (config null when none); DELETE removes them.
# origins: the store's storefront addresses, primary first, which the vendor must allow (Klarna: the client identifier's allowed origins).

Partner script

Vendor

Placements

Pages

Settings

Consent

klarna-messaging

Klarna on-site messaging

credit-promotion-badge

product, cart

client_id (Klarna Merchant Portal › Settings › Client identifier, with the store's domain allowed), environment (playground for a klarna_test_ identifier, production for klarna_live_)

analytics

To have another vendor reviewed as a partner script, contact Tringify with its integration guide.

App embeds#

json
"storefront_embeds": [
  {
    "key": "returns-badge",
    "name": "Returns badge",
    "kind": "vascula",
    "surface": "global_body_end",
    "consent_category": "essential",
    "snippet": "<div class=\"tf-ab-box tf-ab-row\"><span class=\"tf-ab-strong\">{{ store.name }}</span><span class=\"tf-ab-muted\">{{ settings.text }}</span></div>",
    "settings_schema": [
      { "id": "text", "type": "text", "default": "Free returns within 30 days", "editor": { "label": "Badge text" } }
    ]
  }
]

Field

Meaning

key, name

As for blocks. Up to 5 embeds per app.

kind

vascula: markup rendered on every page. surface: a popup that opens one of your hosted surfaces when one of your campaigns triggers; see Popups below. pixel: a tracking pixel that receives events; see Build a browser pixel.

surface

global_head, global_body_end or global_overlay. Pixels must use global_body_end and popups global_overlay. Vascula markup is always added at the end of the page.

consent_category

When the storefront adds the embed. essential embeds appear for every shopper with no consent needed; every other purpose (analytics, advertising, advertising_data, personalized_advertising, personalization) keeps the embed off the page until the shopper allows it, so a banner marked analytics stays hidden until the shopper accepts analytics. Vascula embeds start as essential in the Developer Portal: use it for an embed that shows something and collects nothing. Pixels use analytics, advertising or personalized_advertising.

browser_runtime

Pixels: sandbox (the default) runs your code in your own cross-origin frame. page runs script_url directly in the merchant's page: a privileged integration that needs a separate staff review and the merchant's confirmation, and never runs on checkout for third-party apps.

script_url

Pixels: your version-pinned HTTPS script, with a version or content hash in the path and no query or fragment. It must be on an origin the app registered (admin_ui_url, app_bridge_allowed_origins, redirect_uris or webhook_url), not on a Tringify platform or storefront domain.

frame_url

Sandboxed pixels: the version-pinned frame document that hosts your pixel, on the origin of script_url. Not allowed for page.

script_integrity

Page-runtime pixels: sha384-<base64> of the exact bytes at script_url, checked when you submit the release. Required for third-party apps; not allowed for sandboxed pixels.

snippet

For vascula embeds: the markup, up to 32 KB. It follows the app markup policy (below).

settings_schema

Optional settings the merchant fills in when turning the embed on: a list of settings like a theme's global settings, each with an id, a type (text, number, checkbox, select, range, color, url, color_scheme, font_picker, color_scheme_group or css), a default valid for that type, and options for select. The snippet reads them as settings.<id>; editor.label is the label the merchant sees. Saving refuses a schema with a missing or repeated id, an unknown type or an invalid default.

surface_key

Popups: the key of one of your hosted surfaces whose presentation is modal, drawer or sticky_bar.

Embeds declare no bridge actions. A Vascula embed is markup only and a pixel only observes events. A popup opens a hosted surface, and what it may do is what that surface declares. For anything else shoppers interact with, such as a button that adds to the cart, use an app block that opens a hosted surface.

App markup policy#

A Vascula embed's snippet follows the same app markup policy as app blocks. It may use reading markup and links only: no <script>, <style>, frames, forms, buttons, id or data-* attributes, event attributes or inline styles, and classes only from the platform's tf-ab-* set (listed on App blocks); the classes inherit the theme's font and colours. The snippet is checked when you save the configuration, and what it renders is checked again on every page.

A snippet that, rendered with a merchant's settings, breaks the policy is left out of that store's pages; the rest of the page renders as usual. You see it in the app's Health page under Storefront embeds: the stores, the embed, the reason and when it was last seen, for the last 7 days. The merchant sees the same reason on the embed under App embeds in the theme editor. Fix the snippet and release a new version.

Installing an app turns none of its embeds on. Merchants turn Vascula embeds and popups on per storefront under App embeds in the theme editor, and pixels per storefront in Online Store › Pixels; the theme editor shows a pixel's status and links there. An app can also activate one of its embeds on every storefront of the store with the app-token call PUT /api/2025-01/storefront-embeds/{embedKey}, for example when the merchant finishes its setup. A merchant's choice wins: a storefront where the merchant turned the embed off stays off. Storefronts created later inherit the app's activation. Uninstalling removes the app's switches, so a reinstall starts with everything off. An embed is left out of the page until the shopper has given the consent it declares.

Popups#

A popup embed (kind: surface) opens one of your hosted surfaces over the page: a centred card (a bottom sheet on phones) for modal, a side panel for drawer, a bar at the bottom for sticky_bar. Your campaigns decide when. Use it for email and text sign-ups, spin-to-win and discount reveals, announcements, age checks and notices. Nothing of your app loads until a campaign triggers, popups never open on checkout or order confirmation, and automated visits never see them.

json
"storefront_surfaces": [
  {
    "key": "signup",
    "name": "Sign-up popup",
    "url": "https://popups.example.com/surface@1.0.0/signup",
    "bridge_major": 1,
    "presentation": "modal",
    "launch_transport": "form_post",
    "actions": ["marketing.subscribe"],
    "context": ["campaign.id", "localization.locale", "customer.logged_in"]
  }
],
"storefront_embeds": [
  {
    "key": "signup-popup",
    "name": "Sign-up popup",
    "kind": "surface",
    "surface": "global_overlay",
    "consent_category": "essential",
    "surface_key": "signup"
  }
]

Set the campaigns of a popup with the app-token call PUT /api/2025-01/storefront-embeds/{embedKey}/campaigns (scope write_storefront). The list replaces every campaign of that embed on every storefront; storefronts created later inherit it. Campaigns never turn the embed on: the merchant turns it on under App embeds, or your app with PUT /api/2025-01/storefront-embeds/{embedKey}.

bash
curl -X PUT https://api-store.tringify.com/api/2025-01/storefront-embeds/signup-popup/campaigns \
  -H "Authorization: Bearer $APP_TOKEN" -H "Content-Type: application/json" \
  -d '{
  "campaigns": [{
    "id": "welcome-10",
    "priority": 50,
    "starts_at": "2026-11-12T00:00:00Z",
    "triggers": [{ "type": "page_load", "delay_seconds": 8 }, { "type": "exit_intent" }],
    "targeting": {
      "page_types": ["home", "product", "collection"],
      "exclude_paths": ["/pages/contact"],
      "devices": ["mobile", "desktop"],
      "visitors": "new",
      "customers": "guests"
    },
    "frequency": { "mode": "once_every_days", "days": 7, "stop_after_subscribe": true, "stop_after_close": true }
  }]
}'

Field

Meaning

id

Your campaign's id, 1–64 letters, numbers, - or _. The surface receives it as campaign_id when it declares the campaign.id context.

priority

0–100. When several campaigns are ready at the same moment, the highest opens. One popup opens per page.

starts_at, ends_at

Optional schedule (RFC 3339).

triggers

1–5 triggers; any one opens the campaign. page_load (delay_seconds 0–600), scroll (scroll_percent 1–100), exit_intent (the pointer leaves through the top of the window; on touch screens, a quick scroll back up after reading a third of the page), add_to_cart (after the shopper adds to the cart) and idle (delay_seconds 5–600 without interaction).

targeting.storefront_ids

Only these storefronts. Empty: all.

targeting.page_types

Only these page types, such as home, product, collection, cart, search, page, blog_post or account. Empty: all.

targeting.paths, targeting.exclude_paths

Up to 20 each. A path matches exactly, or as a prefix when it ends in * (/collections/sale*). Excluded paths win.

targeting.countries, targeting.exclude_countries

ISO 3166-1 alpha-2 codes of the shopper's country.

targeting.devices

mobile (up to 749 px wide), desktop. Empty: both.

targeting.visitors

all, new (first seen in this browser session) or returning.

targeting.customers

all, guests or signed_in.

frequency.mode

every_page, once_per_session, once_every_days (with days 1–365) or once.

frequency.stop_after_subscribe

Stop showing this campaign in a browser where the shopper signed up through any campaign of this popup.

frequency.stop_after_close

Stop showing it for the rest of the session once the shopper closes it.

Limits: 20 campaigns per popup and 32 KB in all, up to 250 countries and 50 storefronts per campaign. The storefront checks the schedule, storefront, page type, path, country and sign-in for each visitor, and the browser checks device, new or returning, frequency and triggers. When a campaign opens, the storefront checks it again, so a campaign you removed or that ended never opens from a page that was already loaded.

Size the popup with surface.observe(element), set a modal's width with surface.setWidth(px) (280–960), and close it with surface.close(); the shopper can also close it with Escape or by clicking outside. The popup appears only once your page reports its first layout, so a slow page never shows an empty box, and one that does not report within 8 seconds is left closed. Sign shoppers up with surface.subscribe() (the marketing.subscribe command): it uses the store's own sign-up, with its double opt-in and text-marketing consent rules, and must follow the shopper's own action in your frame. See Hosted surfaces.

Personalized products#

To collect text from the shopper, such as an engraving, declare line properties; for uploaded artwork and print files, use line artifacts. See Line properties and App-owned line artifacts. Check what the shopper supplies in your surface before you add it to the cart: once a line is in the cart, checkout never waits on your app.

Test#

  • Install the app on a development store and add your block to a product page in the theme editor.

  • Turn your pixel on for the development store's storefront in Online Store › Pixels, then follow Test event delivery.

  • Under the app's Installs in the Developer Portal, check which release each store runs.

  • Under Webhooks, Download lifecycle examples gives sample line artifact events to test your handlers without real orders.