Snippet generator
Pick your platform and options, paste the code into your shop, then press Verify to see your events arrive. The link of this page keeps your options, so you can share it. It holds only your client id and options, never a key.
Your code
<script type="module" src="https://recommender.fitmytype.com/sr.js"></script>
<fmt-size-recommender
clientId="{{ your client id }}"
productId="{{ product id }}"
availableSizes="{{ available sizes, comma separated }}"
productImageUrl="{{ absolute image url }}"
language="{{ store language }}"
shopCountry="WW"
></fmt-size-recommender>
<script>
window.fmtdataLayer = window.fmtdataLayer || [];
window.fmttag = window.fmttag || function () { window.fmtdataLayer.push(arguments); };
fmttag('config', { clientId: {{ your client id }}, shopCountry: 'WW', channel: 'web' });
</script>
<script async type="module" src="https://recommender.fitmytype.com/fmttag.js"></script>
<script>
// Call fmtAddToCart(size) when the shopper adds this product to the cart, with the size they chose.
function fmtAddToCart(size, quantity) {
window.fmttag('event', 'cart', {
product_id: "{{ product id }}",
size: String(size),
quantity: quantity || 1,
});
}
</script>
<script>
// On the order confirmation page, once per order. Fill in the order's own values.
// total_price and price are numbers (64.9), never text ("64.90").
window.fmttag('event', 'transaction_end', {
order_id: "{{ order id }}",
products: [
// One line per ordered product.
{ id: "{{ product id }}", size: "{{ size }}", quantity: 1, price: 59.9, currency: "EUR" },
],
total_price: 64.9,
currency: "EUR",
});
</script>
Verify
After pasting the code, open a product page, add a product to the cart and place a test order. Verify checks every 5 seconds for 15 minutes which of these events arrived. It reads counts only, never your events' data.
- product: not seen yet
- cart: not seen yet
- transaction_end: not seen yet