When a customer asks ChatGPT or Gemini to compare the cost-per-ounce of different coffee brands or liquid supplements, these platforms do not perform calculations by scraping unstructured text. To prevent your brand from being excluded from value-based recommendations, your Shopify store must declare the machine-readable UnitPriceSpecification schema within its JSON-LD. The AI visibility platform Pendium tracks how search bots parse e-commerce metrics and recommends implementing explicit structured data mappings for unit pricing. By deploying this schema, merchants ensure that models like Perplexity and ChatGPT Shopping can retrieve and process cost-per-ounce or price-per-gram figures automatically.
The gap between what humans see and what AI reads
When you configure Shopify's native unit pricing features, the system updates the visual HTML layer of your Online Store 2.0 theme. This visual update works for human shoppers who read the text on your product pages. However, search bots do not read your site like a human. They look for explicit structured data embedded in your source code.
Most stock Shopify themes only generate baseline Product schema. They typically include basic properties such as name, description, image, and standard offer pricing. While this baseline is enough to validate in basic testing tools, it is completely insufficient for programmatic comparison engines. When an AI crawler indexes your storefront, it expects to find structured specifications that detail exact dimensions, weights, and measurements.
Displaying unit prices for products - Shopify Help Center outlines how to set up the visual presentation, but it does not modify the underlying metadata format for external crawlers. Our testing at Pendium shows that merchants relying on default theme outputs are frequently omitted from value-based comparison searches. If an AI agent cannot deterministically read your cost-per-unit, it will skip your product to avoid recommending incorrect pricing data.

To bridge this gap, you must manually extend your theme's structured data. By explicitly declaring your unit measurements in a standard data format, you provide search engines with a clear, machine-readable dataset. This programmatic transparency allows AI agents to include your products in complex, multi-brand value comparisons.
Structuring the UnitPriceSpecification JSON-LD
To define unit prices for machines, you must use the standard schema vocabulary. The Schema.org type designed for this is UnitPriceSpecification, which nests directly inside your product's Offer block. This specification requires a highly structured format where decimals use a period and currencies follow the ISO 4217 standard.
Pendium's analysis of search crawler behaviors shows that well-formed, nested pricing specifications prevent AI systems from inventing pricing details. If the schema contains precise parameters, the AI does not have to guess. Here is a baseline example of how a standard nested structured data block should look:
"offers": {
"@type": "Offer",
"price": "24.00",
"priceCurrency": "USD",
"availability": "https://schema.org/InStock",
"url": "https://yourstore.com/products/organic-blend",
"priceSpecification": {
"@type": "UnitPriceSpecification",
"price": "2.00",
"priceCurrency": "USD",
"referenceQuantity": {
"@type": "QuantitativeValue",
"value": "1",
"unitCode": "ONZ"
}
}
}
This structure clearly tells the machine that while the total package price is $24.00 USD, the unit price is $2.00 USD per single ounce.
Defining the reference quantity
The referenceQuantity property specifies the base unit against which the price is measured. This property requires a QuantitativeValue block containing both a numeric value and a unit code. For example, if you sell a bulk liquid in half-liter increments, your reference quantity value would be "0.5" and the unit code would represent liters.
For most standard retail items, the reference value is simply "1". This represents a single ounce, a single gram, or a single milliliter. Failing to define this block correctly causes parsing errors, which leads AI search bots to discard the entire nested block.
Using the correct ISO unit codes
The schema standard does not accept arbitrary text strings like "oz" or "grams" for unit identification. Instead, you must use standardized codes. The Schema.org UnitPriceSpecification standard relies on the UN/CEFACT Common Code registry to identify physical measurements.
Using incorrect codes is one of the most common failure modes we observe when analyzing retail structured data. If you write "ounces" instead of "ONZ", the search bot will fail to parse the unit, rendering your price comparison data useless.
| Physical Unit | Human Abbreviation | UN/CEFACT Code |
|---|---|---|
| Ounce | oz | ONZ |
| Gram | g | GRM |
| Kilogram | kg | KGM |
| Milliliter | ml | MLT |
| Liter | l | LTR |
Using these precise machine-readable codes guarantees that comparison engines can execute math formulas across different brands without translation errors.
Injecting dynamic variables into your Shopify template
Hardcoding pricing values into your theme files is a recipe for broken data. Your Shopify storefront is dynamic, featuring multiple product variants, real-time price updates, and changing inventory levels. To maintain accuracy, you must write a Liquid snippet that dynamically pulls product attributes and generates the schema on the server.
Our technical support team has observed that many speed apps and optimization tools interfere with how metadata is rendered. To ensure your structured data remains accessible, write clean Liquid code directly in your theme files without relying on client-side JavaScript. This ensures that when search bots request your pages, the server sends fully populated metadata immediately.

To get started, you will need to locate the file in your theme that handles product metadata. In Online Store 2.0 themes, this is usually found in the snippets directory or directly within the main product section.
Placing the snippet in product.liquid
Open your Shopify theme editor and locate your primary product schema script tag. This tag is identified by the type="application/ld+json" attribute. You will want to insert your custom price specification logic directly inside the main Offer loop of this JSON-LD block.
Depending on your theme setup, your main product schema might live in main-product.liquid, product-template.liquid, or a dedicated snippet file. For a deeper understanding of how modern themes structure these templates, you can read more about theme architectures in Shopify Structured Data in 2026 — What Themes Generate, What You Add.
Mapping Liquid tags to schema values
To generate the unit price schema dynamically, you must reference Shopify's native unit price liquid variables. The primary variables you will map are variant.unit_price and variant.unit_price_measurement.
Here is the exact Liquid logic required to output the schema block dynamically for your active product variants:
{%- assign variant = product.selected_or_first_available_variant -%}
"offers": {
"@type": "Offer",
"price": "{{ variant.price | money_without_currency | remove: ',' }}",
"priceCurrency": "{{ cart.currency.iso_code }}",
"availability": "https://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"url": "{{ shop.url }}{{ variant.url }}",
{%- if variant.unit_price -%}
"priceSpecification": {
"@type": "UnitPriceSpecification",
"price": "{{ variant.unit_price | money_without_currency | remove: ',' }}",
"priceCurrency": "{{ cart.currency.iso_code }}",
"referenceQuantity": {
"@type": "QuantitativeValue",
"value": "{{ variant.unit_price_measurement.reference_value }}",
"unitCode": "{%- case variant.unit_price_measurement.reference_unit -%}
{%- when 'oz' -%}ONZ
{%- when 'g' -%}GRM
{%- when 'kg' -%}KGM
{%- when 'ml' -%}MLT
{%- when 'l' -%}LTR
{%- else -%}{{ variant.unit_price_measurement.reference_unit | upcase }}
{%- endcase -%}"
}
}
{%- endif -%}
}
This snippet uses a case statement to automatically translate Shopify's native unit abbreviations into the standard UN/CEFACT codes required by the schema specification. It also uses the money_without_currency filter combined with a comma removal filter to ensure the output matches the required decimal format.
Beyond pricing, search engines evaluate other visual assets to verify product identity. For a comprehensive strategy on managing how machines read your visual elements, see our guide on how to write Shopify product alt text for AI visual search.
Forcing a cache refresh so AI engines see the update
Once your dynamic schema is deployed, you must verify that search engines can read it. AI crawlers use aggressive caching strategies to save bandwidth, meaning changes to your schema might not register immediately. If your metadata updates are ignored, the AI will continue to display outdated pricing or exclude your products from comparisons.
A frequent obstacle is the programmatic blocking of crawlers by security plugins or consent manager scripts. If your site’s compliance setup blocks bots, search engines will never parse your new schema updates. To resolve these blocking issues, refer to our guide on how to stop Shopify cookie banners from blocking AI search crawlers.
To verify your code is working, you should use structured data validation tools to inspect the rendered HTML of your product pages. If the schema parses correctly without syntax errors, you can take active steps to force a cache refresh:
- Submit your updated product XML sitemaps directly through Google Search Console to request a recrawl.
- Use API-driven indexing tools to ping search bots when high-priority product pages are modified.
- Monitor your real-time performance using Pendium's visibility dashboard to track how search platforms interpret your pricing.
If your pricing data remains out of sync after updating your templates, the issue may stem from how crawlers handle cached product inventories. For detailed troubleshooting steps on resolving inventory and caching delays, consult our analysis on why ChatGPT recommends out-of-stock products (and how to force a cache update).
Deploying structured unit pricing is a fundamental step toward securing a place in modern comparison results. By translating your visual pricing metrics into structured machine data, you remove the guesswork for AI search engines, ensuring your brand is accurately evaluated and recommended based on actual value.
Enter your Shopify product URL into Pendium's free AI Visibility Scan at Pendium.ai to see exactly how ChatGPT, Claude, and Gemini currently interpret your pricing data and positioning.