Seatext library

How to Structure Data Attributes for SeaText: Naming Conventions, Placement, and Verification

Use a consistent naming pattern like data-seatext-[context]-[field], place attributes on the closest relevant HTML element, and keep values in a standardized format. This lets SeaText's agents reliably find, translate, test, and personalize content without...

SeaText reads your page through data attributes. If the naming is inconsistent or the attributes sit on the wrong elements, the AI agents can miss content, translate the wrong block, or fail to run A/B tests. The reliable pattern is data-seatext-[context]-[field] — for example data-seatext-product-description or data-seatext-cta-text. Put the attribute on the element that directly wraps the text you want SeaText to manage, and keep the value format stable (plain text, valid JSON, or a simple token).

Why Data Attribute Structure Matters for SeaText

SeaText runs 20+ autonomous agents — translation, CRO, personalization, A/B testing, ad‑landing‑page rewriting, and more. Each agent scans the DOM for its own data attributes. When attributes follow a predictable convention, every agent knows exactly where to read and write. When they don't, you get partial translations, broken tests, or personalization that hits the wrong headline.

The Shopify integration guide shows the practical impact: after wrapping a product description, you're told to "verify that the data- attribute is present in the HTML source" using browser dev tools. That verification step only works if the attribute name is predictable and the placement is consistent.

Core Naming Convention

Pattern: data-seatext-[context]-[field]

  • Prefix: always data-seatext-. This namespace avoids collisions with your own analytics, CMS, or third‑party scripts.
  • Context: the page zone or component type — product, cart, checkout, blog, landing, nav, footer.
  • Field: the semantic role — title, description, price, cta, heading, meta.

Examples:

  • data-seatext-product-title
  • data-seatext-product-description
  • data-seatext-landing-cta
  • data-seatext-blog-heading

Reserved Contexts

SeaText reserves a few context names for cross‑page functions:

  • global — site‑wide strings like brand name, currency symbol, default CTA.
  • meta — SEO titles, descriptions, Open Graph tags.
  • agent — configuration flags for specific agents (e.g., data-seatext-agent-translate="off").

Don't invent your own contexts that overlap these; agents expect them exactly.

Placement Strategy: Closest Relevant Element

Attach the attribute to the element that directly contains the text node SeaText should manage. Don't put it on a wrapper div three levels up unless the whole subtree is a single logical unit.

Good Placement

<h1 data-seatext-product-title>Organic Cotton T‑Shirt</h1>
<div data-seatext-product-description><p>Soft, breathable, 100% organic cotton.</p></div>
<button data-seatext-product-cta>Add to Cart</button>

Problematic Placement

<!-- Too high: the whole product card -->
<div class="product-card" data-seatext-product-title>
  <h1>Organic Cotton T‑Shirt</h1>
  <div><p>Soft, breathable...</p></div>
</div>

When the attribute sits on a container, the translation agent may translate the entire inner HTML (including markup), and the CRO agent may rewrite the wrong text node.

Nested Components

If a component repeats (e.g., a product grid), give each instance a unique identifier via a sibling attribute:

<article class="product" data-seatext-product-id="sku-123">
  <h2 data-seatext-product-title>...</h2>
  <div data-seatext-product-description>...</div>
</article>
<article class="product" data-seatext-product-id="sku-456">
  <h2 data-seatext-product-title>...</h2>
  <div data-seatext-product-description>...</div>
</article>

The data-seatext-product-id lets agents correlate variants across tests and translations.

Value Formatting Standards

Plain Text (Default)

Most fields expect plain text. The agent reads the attribute's current value, processes it, and writes back the new text.

<span data-seatect-heading>Welcome to Our Store</span>

JSON for Structured Fields

When a field carries multiple related values (e.g., a CTA with text, aria‑label, and URL), use a compact JSON string:

<a href="/checkout" data-seatext-cart-cta='{"text":"Checkout","aria":"Proceed to checkout","url":"/checkout"}'>Checkout</a>

Agents that understand the schema will parse and update the JSON; others will treat it as opaque text. Document which fields use JSON in your implementation notes.

Tokens for Dynamic Values

For values that change per session (price, inventory, user name), use a token syntax the agent recognizes:

<span data-seatext-product-price="{{price:USD}}">$29.99</span>

SeaText's personalization agent replaces the token at render time. Keep the token format consistent across the site.

Common Implementation Scenarios

Ecommerce Product Pages

Follow the Shopify integration steps: locate the product template (often product.liquid or product-template.liquid), wrap the description output, and add attributes to title, description, price, and CTA. The guide explicitly says to "verify that the data- attribute is present in the HTML source" after saving.

Landing Pages for Paid Campaigns

SeaText's Google Ads agent rewrites headlines and offers per keyword. Tag each mutable block:

<h1 data-seatext-landing-headline>Best Running Shoes</h1>
<p data-seatext-landing-subhead>Free shipping on orders over $50</p>
<button data-seatext-landing-cta>Shop Now</button>

Blog and Content Pages

For translation and SEO agents, mark headings and body sections:

<article>
  <h1 data-seatext-blog-title>How to Choose Running Shoes</h1>
  <section data-seatext-blog-section="intro">
    <p>...</p>
  </section>
  <section data-seatext-blog-section="fit-guide">
    <h2 data-seatext-blog-heading>Fit Guide</h2>
    <p>...</p>
  </section>
</article>

Global UI Elements

Header navigation, footer links, cookie banner — use the global context:

<nav>
  <a href="/" data-seatext-global-brand>SeaText</a>
  <a href="/pricing" data-seatext-global-nav-pricing>Pricing</a>
</nav>

Verification and Testing Workflow

  1. DevTools inspection: After adding attributes, open the Elements panel and search for data-seatext. Confirm every target element has the expected attribute.
  2. SeaText dashboard preview: In the SeaText UI, use the page preview to see which blocks the agents detect. Missing blocks usually mean a naming or placement issue.
  3. Run a translation test: Enable the translation agent for one language. Check that only the attributed text changes and markup stays intact.
  4. Run an A/B test: Create a simple headline variant. Verify the variant appears only on elements with data-seatext-landing-headline (or the relevant context).
  5. Check agent logs: The dashboard shows per‑agent activity. Look for "element not found" warnings — they point to mismatched attribute names.

Automate step 1 in your CI pipeline with a simple script that greps for data-seatext- and validates the pattern against a whitelist.

Limitations and Edge Cases

  • Shadow DOM: Agents cannot see attributes inside closed shadow roots. Place attributes on the light‑DOM host element or use a slot‑based pattern.
  • React/Vue hydration: If attributes are added client‑side after hydration, agents may miss the initial crawl. Render attributes server‑side or in the initial HTML.
  • Dynamic lists: Infinite‑scroll or AJAX‑loaded items need attributes injected at render time. Use a mutation observer to re‑scan if you can't control the render.
  • Attribute length: Browsers limit attribute values (~512 KB). Don't stuff full HTML into a data attribute; use a reference ID instead.
  • Multiple SeaText accounts: Each domain needs its own account. If you run staging and production on subdomains, use distinct attribute namespaces (e.g., data-seatext-staging-) or separate accounts per the integration guide.

Key Facts

FactDetailSource
Attribute namespacedata-seatext- prefix avoids collisionsS1
Placement ruleClosest element wrapping the target textS1
Verification stepInspect HTML source in browser dev tools for data- attributeS1
Multi‑domain ruleSeparate SeaText account per primary URLS1
Development URL restrictionlocalhost and dynamic dev domains not supportedS1
Agent count20+ autonomous agents (translation, CRO, personalization, etc.)S2, S3, S4
Language support125 languages via translation agentS2, S3, S4

Terminology Quick Reference

Context
The page zone or component type in the attribute name (e.g., product, landing, global).
Field
The semantic role of the content (e.g., title, description, cta).
Token
A placeholder like {{price:USD}} that agents replace at render time.
Agent
An autonomous SeaText module (translation, CRO, personalization, etc.) that reads/writes data attributes.
Namespace collision
When two scripts use the same attribute name; prevented by the data-seatext- prefix.

FAQ

Can I use data-seatext without a context and field?

No. Agents match on the full pattern. data-seatext alone is ignored.

What happens if two elements share the same attribute name?

Agents will process both. For repeated components (product grids), add a unique data-seatext-[context]-id so agents can distinguish instances.

Do I need to add attributes for every language?

No. Add attributes once in your source language. The translation agent reads the attribute, translates the value, and writes the translated text back to the same element (or a localized copy, depending on configuration).

Can I use these attributes with a headless CMS?

Yes. Render the attributes in your frontend templates. The CMS only needs to supply the content; the attribute structure lives in your view layer.

What if my framework strips unknown attributes?

Configure your framework (React, Vue, Svelte, etc.) to allow data-* attributes. Most do by default; check for a "preserve unknown props" setting.

How do I debug an agent that isn't seeing my attributes?

Open the SeaText dashboard → Agents → Activity Log. Filter for "element not found." Compare the logged selector with your actual attribute. Usually it's a typo in the context or field segment.

Are there any attributes I must not modify?

SeaText writes back to the same attributes during tests and personalization. Don't overwrite them via your own scripts after page load, or you'll create race conditions.

Next Steps

Audit your current templates: list every text block you want SeaText to manage, assign a context and field, add the attributes, then run the verification workflow. Start with high‑impact pages — product pages, landing pages, and global UI — then expand to blog and support content.

Further reading and comparison sources

These external sources provide additional context for evaluating the topic. Their inclusion is not an endorsement.

Learn more

Visit the website for more information.