Carbon Emissions Widget
The Zilch Carbon Emissions Widget lets you display product carbon footprint data directly on your website. It automatically detects product SKUs and shows emissions information in a clean format.
Features
- Automatic SKU Detection — works with Shopify, WooCommerce, Squarespace, and custom websites
- Domain Whitelisting — control which websites can use your widget
- Customisable Themes — choose from default, minimal, or detailed
- Responsive Design — works on all screen sizes
- Rate Limited — 1,000 requests per SKU per day
Getting Started
Step 1: Get your API key
- Log in to your Zilch account
- Navigate to Profile → API Key
- If you don't have a key yet, click Generate API Key
Step 2: Configure domain whitelist (optional)
- On your Profile page, scroll to Widget Domain Whitelist
- Add the domain where you want to allow the widget (e.g.
myshopifysite.com)
Step 3: Install the widget
Choose the installation method for your platform below.
Platform-specific installation
Shopify — product template (recommended)
- Go to Online Store → Themes → Actions → Edit code
- Open
product.liquid(or your product template) - Find where you want to display the widget, then add this code:
liquid
<div id="zilch-emissions">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
defer
data-zilch-widget
data-api-key="YOUR_API_KEY_HERE"
data-sku="{{ product.selected_or_first_available_variant.sku }}"
data-theme="default"
data-show-breakdown="true">
</script>
</div>Shopify — variant-specific
For product pages with a variant selector:
liquid
<div id="zilch-emissions" data-sku="{{ product.selected_variant.sku }}">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY_HERE">
</script>
</div>WooCommerce (WordPress)
- Go to Appearance → Theme Editor
- Open
single-product.php(or use a child theme) - Add the widget code where you want it displayed:
php
<div id="zilch-emissions" data-sku="<?php echo esc_attr($product->get_sku()); ?>">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY_HERE">
</script>
</div>Squarespace
- Go to Pages and select your product page
- Click Edit and add a Code Block
- Paste this code:
html
<div id="zilch-emissions">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY_HERE">
</script>
</div>Squarespace may require you to add the SKU manually if auto-detection doesn't work — add
data-sku="YOUR-PRODUCT-SKU" to the container div.BigCommerce
- Go to Storefront → Script Manager
- Create a new script for Footer
- Add this code:
html
<script>
window.productData = window.productData || {};
window.productData.sku = '{{product.sku}}';
</script>
<div id="zilch-emissions">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY_HERE">
</script>
</div>Custom website / HTML
html
<div id="zilch-emissions">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY_HERE"
data-sku="PRODUCT-SKU-HERE">
</script>
</div>Manual initialisation (advanced)
If you need more control, you can initialise the widget manually:
html
<script src="https://www.api.tryzilch.com/zilch-widget.js"></script>
<div id="product-emissions"></div>
<script>
new ZilchEmissionsWidget({
apiKey: 'YOUR_API_KEY_HERE',
sku: 'PRODUCT-SKU-HERE',
container: document.getElementById('product-emissions'),
theme: 'default',
showBreakdown: true
});
</script>SKU auto-detection
The widget automatically tries to detect the product SKU from your page using these methods, in order:
- Data attribute —
data-skuon the script tag or container - Platform objects — Shopify, WooCommerce, or BigCommerce global variables
- Meta tags —
<meta property="product:sku">or<meta name="sku"> - Structured data — Schema.org JSON-LD with a product SKU
- DOM elements — elements with classes or IDs containing "sku"
- URL parameters —
?sku=...in the URL
If auto-detection fails, specify the SKU manually:
html
<script
data-zilch-widget
data-api-key="YOUR_API_KEY"
data-sku="MANUAL-SKU-HERE">
</script>Customisation options
Themes
Choose a theme that matches your site's design:
- default — standard widget with emissions breakdown
- minimal — compact version without breakdown
- detailed — larger version with more emphasis
html
<script
data-zilch-widget
data-api-key="YOUR_API_KEY"
data-theme="minimal">
</script>Show / hide breakdown
html
<script
data-zilch-widget
data-api-key="YOUR_API_KEY"
data-show-breakdown="false">
</script>Custom API base URL
html
<script>
window.ZILCH_API_BASE_URL = 'https://your-custom-api.com';
</script>
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY">
</script>Widget attributes reference
| Attribute | Required | Description | Example |
|---|---|---|---|
data-zilch-widget | Yes | Enables auto-initialisation | data-zilch-widget |
data-api-key | Yes | Your Zilch API key | data-api-key="zlch_live_..." |
data-sku | No* | Product SKU (auto-detected if omitted) | data-sku="ABC-123" |
data-theme | No | Widget theme: default, minimal, detailed | data-theme="minimal" |
data-show-breakdown | No | Show emissions breakdown: true or false | data-show-breakdown="false" |
data-api-base-url | No | Custom API base URL | data-api-base-url="https://..." |
* Required if SKU cannot be auto-detected.
Troubleshooting
Widget not showing
- Check that your API key is correct and active
- Verify your domain is whitelisted
- Ensure the product has a SKU that the widget can detect
- Open your browser's developer tools (F12) and check the console for errors
"SKU not found" error
- Add
data-sku="YOUR-SKU"to the script tag - Ensure your product has a SKU assigned in your platform
- Check that the SKU exists in your Zilch account
"Domain not allowed" error
- Go to Profile → Widget Domain Whitelist
- Add your domain (e.g.
example.com)
Widget shows "Unable to load data"
- Check that the product has emissions data calculated in Zilch
- Verify your API key is valid
- Check whether the rate limit has been exceeded
Rate limit exceeded
- Each SKU is limited to 1,000 requests per 24 hours
- This limit is per SKU, not per API key
- Wait 24 hours, or contact support for higher limits
Rate limits
| Scope | Limit |
|---|---|
| Per SKU | 1,000 requests per 24 hours |
Security best practices
- Domain whitelisting — always whitelist your domains in production
- API key security — never commit API keys to version control
- HTTPS — always use HTTPS when loading the widget
Support
For issues or questions, contact support with:
- Your API key (first 10 characters only)
- The domain where the widget is installed
- The product SKU
- Any browser console errors
Examples
Complete Shopify example
liquid
<div class="product-emissions-section">
<h3>Environmental Impact</h3>
<div id="zilch-emissions">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="{{ settings.zilch_api_key }}"
data-sku="{{ product.selected_or_first_available_variant.sku }}"
data-theme="default"
data-show-breakdown="true">
</script>
</div>
</div>Minimal widget (no breakdown)
html
<div id="zilch-emissions">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY"
data-theme="minimal"
data-show-breakdown="false">
</script>
</div>Multiple products on the same page
html
<!-- Product 1 -->
<div id="zilch-emissions-1" data-sku="SKU-001">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY">
</script>
</div>
<!-- Product 2 -->
<div id="zilch-emissions-2" data-sku="SKU-002">
<script
src="https://www.api.tryzilch.com/zilch-widget.js"
data-zilch-widget
data-api-key="YOUR_API_KEY">
</script>
</div>