Skip to content
ShopAssist Docs
Widget

Embed attributes

Every data attribute and ShopAssistConfig key the loader reads, and the order in which configuration sources are merged.

The loader reads configuration from the script tag's data-* attributes, window.ShopAssistConfig, and JSON blocks on the page. Plugins set these for you; Generic stores set them by hand.

Attributes

AttributeConfig keyValues
data-shopassist-keypublishableKeypk_live_… or pk_test_… (required)
data-platformplatformgeneric (default), shopify, magento2, woocommerce, prestashop
data-localelocaleBCP 47 or platform form (da_DK → da-DK)
data-currency, data-countrycurrency, countryHints only
data-launcherlauncherdefault or none (your own button calls ShopAssist.open())
data-consentconsentModemanaged: wait for ShopAssist.setConsent()
data-debugdebug1: console diagnostics
data-position, data-accent-colortheme.position, theme.accentColorOverride the dashboard look
data-logged-incustomerLoggedIn1/0, a hint only
data-page-type, data-product-id, data-variant-id, data-category-idpage.*Page context
data-cart-page-url, data-checkout-url, data-cart-add-url-templateendpoints.*Same-origin URLs
data-identity-url, data-cart-api-url, data-store-api-url, data-session-url, data-proxy-pathendpoints.*Set by plugins
data-api-base, data-asset-baseapiBase, assetBaseOnly ShopAssist hosts are accepted
data-design-mode, data-consent-api, data-cookie-restriction—Set by plugins

Every endpoint URL must be on the same origin as the page; others are dropped.

Precedence

Later sources win (nested objects are merged):

  1. Built-in defaults
  2. data-* attributes of the script tag
  3. window.ShopAssistConfig
  4. <script type="application/json" id="shopassist-config">
  5. <script type="application/json" id="shopassist-page"> (page context only)
  6. ShopAssist.setPageContext() at run time
<script>
  window.ShopAssistConfig = { publishableKey: "pk_live_YOUR_PUBLISHABLE_KEY", platform: "generic", locale: "da-DK" }
</script>
<script type="application/json" id="shopassist-page">
  { "type": "product", "productId": "SHIRT-42" }
</script>

Late configuration

Optimisation tools that delay scripts (WP Rocket "Delay JS", Cloudflare Rocket Loader) can run the loader before your configuration. The loader retries at DOMContentLoaded, at load and 2 seconds later, then gives up silently (data-debug="1" logs why).

Last updated on

On this page