Docs menu
Implementation · eCommerce Conversion Tracking
eCommerce Setup Guide
Complete guide to tracking eCommerce conversions, revenue, and funnel events with Sealmetrics. Includes examples for WooCommerce, Shopify, and custom platforms.
This guide covers how to implement complete eCommerce tracking with Sealmetrics, from product views to purchase completion.
Quick Start
1. Install the Tracker
Add to every page of your store:
<script src="https://t.sealmetrics.com/t.js?id=YOUR_ACCOUNT_ID" defer></script>2. Track Purchases
On your thank-you/confirmation page:
<script>
window.addEventListener('load', function() {
sealmetrics.conv('purchase', 149.99, {
currency: 'EUR',
items: [
{ product_name: 'Blue Running Shoes', price: 89.99, quantity: 1, category: 'footwear' },
{ product_name: 'Sports Socks Pack', price: 60.00, quantity: 2, category: 'accessories' }
]
});
});
</script>That's the minimum setup. The items array is optional but recommended for detailed product analytics. Read on for complete funnel tracking.
The eCommerce Funnel
Track the funnel from product view to purchase:
| Step | Event Type | Function |
|---|---|---|
| Product View | Microconversion | sealmetrics.micro('view_item', {...}) |
| Add to Cart | Microconversion | sealmetrics.micro('add_to_cart', {...}) |
| View Cart | Microconversion | sealmetrics.micro('view_cart', {...}) |
| Begin Checkout | Microconversion | sealmetrics.micro('begin_checkout', {...}) |
| Add Payment Info | Microconversion | sealmetrics.micro('add_payment_info', {...}) |
| Purchase | Conversion | sealmetrics.conv('purchase', amount, {...}) |
Step-by-Step Implementation
Product View
Track when users view product details. Use view_item: it is the name the Funnel report reads for its View Product step (the legacy view_product, still emitted by older integrations, is also accepted and summed).
// On product page load
sealmetrics.micro('view_item', {
product_id: 'SKU-123',
product_name: 'Blue Running Shoes',
category: 'footwear',
price: '89.99',
currency: 'EUR'
});Add to Cart
Track add-to-cart clicks:
document.querySelector('.add-to-cart').addEventListener('click', function() {
sealmetrics.micro('add_to_cart', {
product_id: 'SKU-123',
product_name: 'Blue Running Shoes',
price: '89.99',
quantity: '1'
});
});View Cart
Track when users view their cart:
// On cart page load
sealmetrics.micro('view_cart', {
items_count: '3',
cart_value: '267.97'
});Begin Checkout
Track checkout initiation:
// When user starts checkout
sealmetrics.micro('begin_checkout', {
items_count: '3',
cart_value: '267.97'
});Purchase (Conversion)
Track completed purchases with product details:
// On thank-you page
sealmetrics.conv('purchase', 267.97, {
currency: 'EUR',
payment_method: 'credit_card',
items: [
{ product_name: 'Blue Running Shoes', product_id: 'SKU-123', price: 89.99, quantity: 2, category: 'footwear' },
{ product_name: 'Sports Socks', product_id: 'SKU-456', price: 89.99, quantity: 1, category: 'accessories' }
]
});Platform-Specific Implementation
WooCommerce
Add to your functions.php or a custom plugin:
// Track purchases on thank-you page
add_action('woocommerce_thankyou', function($order_id) {
$order = wc_get_order($order_id);
if (!$order) return;
// Build items array
$items = array();
foreach ($order->get_items() as $item) {
$product = $item->get_product();
$items[] = array(
'product_name' => $item->get_name(),
'product_id' => $product ? $product->get_id() : '',
'sku' => $product ? $product->get_sku() : '',
'price' => $item->get_total() / max($item->get_quantity(), 1),
'quantity' => $item->get_quantity(),
'category' => wp_strip_all_tags(wc_get_product_category_list($product ? $product->get_id() : 0)),
);
}
?>
<script>
window.addEventListener('load', function() {
if (typeof sealmetrics !== 'undefined') {
sealmetrics.conv('purchase', <?php echo $order->get_total(); ?>, {
currency: '<?php echo $order->get_currency(); ?>',
payment_method: '<?php echo $order->get_payment_method(); ?>',
items: <?php echo json_encode($items); ?>
});
}
});
</script>
<?php
});For add-to-cart tracking, add this JavaScript:
// WooCommerce AJAX add-to-cart
jQuery(document.body).on('added_to_cart', function(e, fragments, cart_hash, button) {
if (typeof sealmetrics !== 'undefined') {
sealmetrics.micro('add_to_cart', {
product_id: jQuery(button).data('product_id'),
product_name: jQuery(button).data('product_name') || 'Product'
});
}
});Shopify
In your checkout.liquid or via Additional Scripts (Settings → Checkout):
{% if first_time_accessed %}
<script>
window.addEventListener('load', function() {
if (typeof sealmetrics !== 'undefined') {
sealmetrics.conv('purchase', {{ checkout.total_price | money_without_currency | remove: ',' }}, {
currency: '{{ checkout.currency }}',
items: [
{% for item in checkout.line_items %}
{
product_name: '{{ item.title | escape }}',
product_id: '{{ item.product_id }}',
sku: '{{ item.sku | escape }}',
price: {{ item.final_price | money_without_currency | remove: ',' }},
quantity: {{ item.quantity }},
category: '{{ item.product.type | escape }}'
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
});
}
});
</script>
{% endif %}For add-to-cart, use theme JavaScript:
// In theme.js or via Shopify ScriptTag API
document.addEventListener('click', function(e) {
if (e.target.matches('[data-add-to-cart]') || e.target.closest('[data-add-to-cart]')) {
var form = e.target.closest('form[action*="/cart/add"]');
if (form && typeof sealmetrics !== 'undefined') {
sealmetrics.micro('add_to_cart', {
product_id: form.querySelector('[name="id"]').value
});
}
}
});Magento 2
In your checkout success template or via layout XML:
<?php
$order = $block->getOrder();
$items = array();
foreach ($order->getAllVisibleItems() as $item) {
$items[] = array(
'product_name' => $item->getName(),
'product_id' => $item->getProductId(),
'sku' => $item->getSku(),
'price' => $item->getPrice(),
'quantity' => (int)$item->getQtyOrdered(),
);
}
?>
<script>
window.addEventListener('load', function() {
if (typeof sealmetrics !== 'undefined') {
sealmetrics.conv('purchase', <?php echo $order->getGrandTotal(); ?>, {
currency: '<?php echo $order->getOrderCurrencyCode(); ?>',
items: <?php echo json_encode($items); ?>
});
}
});
</script>PrestaShop
In your order confirmation template:
{if isset($order)}
<script>
window.addEventListener('load', function() {
if (typeof sealmetrics !== 'undefined') {
sealmetrics.conv('purchase', {$order.total_paid|floatval}, {
currency: '{$currency.iso_code|escape:'javascript'}',
items: [
{foreach from=$order.products item=product name=items}
{ldelim}
product_name: '{$product.product_name|escape:'javascript'}',
product_id: '{$product.product_id}',
sku: '{$product.product_reference|escape:'javascript'}',
price: {$product.unit_price_tax_incl|floatval},
quantity: {$product.product_quantity|intval},
category: '{$product.category|escape:'javascript'}'
{rdelim}{if !$smarty.foreach.items.last},{/if}
{/foreach}
]
});
}
});
</script>
{/if}Dynamic Values
Server-Side Rendering
Pass values from your backend:
<script>
window.addEventListener('load', function() {
sealmetrics.conv('purchase', <?= json_encode($order['total']) ?>, {
currency: <?= json_encode($order['currency']) ?>
});
});
</script>Data Layer
If using Google Tag Manager's data layer:
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'ORD-12345',
value: 149.99,
currency: 'EUR'
}
});
</script>
<script>
// Read from data layer
window.addEventListener('load', function() {
var purchaseData = window.dataLayer.find(function(item) {
return item.event === 'purchase';
});
if (purchaseData && typeof sealmetrics !== 'undefined') {
sealmetrics.conv('purchase', purchaseData.ecommerce.value, {
currency: purchaseData.ecommerce.currency
});
}
});
</script>Content Grouping for eCommerce
Use content grouping to segment your pages:
<!-- Product pages -->
<script src="https://t.sealmetrics.com/t.js?id=YOUR_ACCOUNT_ID&group=product" defer></script>
<!-- Category pages -->
<script src="https://t.sealmetrics.com/t.js?id=YOUR_ACCOUNT_ID&group=category" defer></script>
<!-- Cart page -->
<script src="https://t.sealmetrics.com/t.js?id=YOUR_ACCOUNT_ID&group=cart" defer></script>
<!-- Checkout pages -->
<script src="https://t.sealmetrics.com/t.js?id=YOUR_ACCOUNT_ID&group=checkout" defer></script>Properties Reference
Recommended properties for eCommerce events:
| Property | Description | Example |
|---|---|---|
currency | ISO 4217 currency code | 'EUR', 'USD' |
payment_method | Payment type | 'credit_card' |
coupon | Discount code | 'SAVE10' |
items | Array of product objects (see below) | [{ product_name: '...', price: 19.99 }] |
Product fields inside items
Each object in the items array can contain any combination of these fields (all are optional, free-form key-value):
| Field | Description | Example |
|---|---|---|
product_name | Product name | 'Blue Running Shoes' |
product_id | Product SKU/ID | 'SKU-123' |
price | Unit price | 89.99 |
quantity | Units purchased | 2 |
category | Product category | 'footwear' |
brand | Brand name | 'Nike' |
variant | Product variant | 'Blue / Size 42' |
sku | Stock keeping unit | 'SKU-123-BL' |
Viewing Product Data in the Dashboard
Once you're tracking purchases with items, your product data is available in the Properties report.
- Go to your site in the Sealmetrics dashboard
- Click Properties in the sidebar
- Select the Conv. Items tab
In this mode you can:
- Browse product fields: See all fields you've tracked across items (
product_name,category,brand,sku, etc.) and how frequently each appears - Analyze by source: Select a field (e.g.,
product_name) to see which products are sold by each traffic source, medium, and campaign - Export: Download CSV for any view
The report filters by date range only — there is no filter by conversion type, UTM, channel, country or device on it. See the Properties report for what each mode and toggle actually shows.
Items with a quantity field are automatically counted by units — a product with quantity: 2 counts as 2 in the report.
Deduplication
Prevent duplicate conversion tracking:
Server-Side Flag (Recommended)
Mark orders as tracked in your database:
// PHP example
if (!$order->isTracked()) {
echo '<script>sealmetrics.conv("purchase", ' . $order->getTotal() . ', {...});</script>';
$order->markAsTracked();
}Testing
Verify Installation
- Open your store in a browser
- Open Developer Tools → Network tab
- Filter by
t.sealmetrics.com - Navigate through pages and complete a test purchase
- Verify requests are sent with correct data
Check Data Is Arriving
- Log in to Sealmetrics dashboard
- Open your site's Overview report
- Within seconds, the Last hit timestamp at the top right updates and your test events are reflected in the numbers
Verify Conversion Data
- Go to Conversions report — check that purchase amount is correct
- Go to Properties report — verify properties appear in the Conversions tab
- Select Conv. Items tab — confirm your product items are listed with correct fields
- Verify attribution to traffic source
Related Documentation
- Conversions - Detailed conversion tracking
- Microconversions - Funnel step tracking
- Google Tag Manager - GTM integration
- WooCommerce Plugin - Official WooCommerce integration