How to Collect Price Data in Italy: Product Code Matching

Published:

12 minute read

Acar Diveroli
Written by: Acar Diveroli
Two stores' 13- and 14-digit code strips join one barcode plate; the first digit is dashed, the last digit is blue

Product code matching is the work of linking the same product in different stores to a single record. When you collect price data in Italy, the accuracy of every comparison rests on this step. The most reliable key is the GTIN, but the same code arrives with 13 digits in one store, 14 in another, or with the zero at the front dropped. A plain text comparison turns that difference into two separate products and raises no error. This article covers GTIN normalization, the check digit, brand and MPN matching, and size parsing from Italian product names.

Matching keys

Matching uses three keys, and their order of trust is fixed: GTIN, brand with MPN, name with size. The GTIN belongs to the product itself and is the same in every store. The MPN (manufacturer part number) is the maker's own model code, while the product name is written differently in each store.

On Italian product pages these values can appear in rows such as Codice EAN, EAN or Codice produttore. The store's own stock code (sku, Cod. articolo) does not belong on this list. That code only means something in that store and will not find the same product elsewhere.

The rule is simple: check the GTIN first, then the MPN, then the name. Record which key produced each match.

Padding the GTIN to 14 digits

A GTIN has 8, 12, 13 or 14 digits, and all of them share one number space. A 12-digit UPC code (036000291452) and its 13-digit form with a zero in front (0036000291452) point to the same product. Compared as text, the two values are not equal. The fix is to left-pad every value with zeros to 14 digits.

schema.org does not require publishers to pad with zeros in front. So sites publish the same product at different lengths, and the padding happens on your side. Always store the value as text. A spreadsheet column opened as numbers drops the zeros at the front and a 12-digit code shrinks to 11.

The last digit is the check digit. The GS1 method counts the digits, excluding the check digit, from the right. The first, third and fifth digits from the right are multiplied by 3, the others by 1, and the results are summed. The digit that rounds the sum up to the next multiple of 10 is the check digit. Counting from the right makes the function work at any length, because zeros at the front do not change the sum. We covered the structure of EAN-13 and its place in German stores in our article on price monitoring in Germany.

python
import re

def gtin14(raw):
    """Converts a raw value to a 14-digit GTIN, returns None if invalid."""
    s = str(raw).strip()
    m = re.search(r"/01/(\d{14})", s)  # GS1 Digital Link URL
    if m:
        s = m.group(1)
    s = re.sub(r"[\s-]", "", s)
    if not re.fullmatch(r"\d{8,14}", s):
        return None
    s = s.zfill(14)
    data, check = s[:-1], int(s[-1])
    total = sum(
        int(c) * (3 if i % 2 == 0 else 1)
        for i, c in enumerate(reversed(data))
    )
    return s if (10 - total % 10) % 10 == check else None

In our test, 8001234567897, 08001234567897, 800 1234 56789 7 and https://id.gs1.org/01/08001234567897 all returned the same value: 08001234567897. A code with a changed last digit returned None, while a UPC code read as a number and cut to 11 digits came back as the correct 14-digit value. The GS1 UK sample code 5012345670003 passed the test.

In-store codes and case GTINs

Not every code with a valid check digit is globally unique. GS1 reserves numbers starting with 02, 04 and 20-29 for restricted circulation. 20-29 and 02 are used within a region, 04 within a single company. Barcodes on cheese or deli products sold by weight often fall in this range. The same number can mean two different products in two chains.

The second trap is the packaging level. If the first digit of a 14-digit GTIN is 1-8, the code identifies a case or a multipack. It is derived from the GTIN of the single item inside, but it is a separate product. GS1 requires a separate GTIN for each packaging level. If the first digit is 9, the product is variable measure.

python
def gtin_type(g):
    if g[0] == "9":
        return "variable measure"
    if g[0] != "0":
        return "case"
    if g[1] == "2" or g[1:3] in ("02", "04"):
        return "in-store"
    return "product"

The function looks at the 14-digit value. A 13-digit code such as 2012345000018 starts with 02 once padded to 14 digits and counts as "in-store". Do not auto-match a code that returns "case" or "in-store" against a single-item price.

Brand and MPN matching

An MPN only distinguishes a product among one manufacturer's products, and two manufacturers can use the same code. So the key is not the MPN alone but brand and MPN together. For products without a GTIN, such as small makers' home appliances or spare parts, matching relies on this pair.

Neither field can be compared before normalization. Brand names carry company suffixes (S.p.A., S.r.l.), accents and apostrophes written in different ways. D'Amico, D’Amico (typographic apostrophe) and DAmico are the same brand. In the MPN, hyphens, dots, slashes and spaces change from store to store.

python
import unicodedata

def brand_key(brand):
    s = unicodedata.normalize("NFKD", brand.casefold())
    s = "".join(c for c in s if not unicodedata.combining(c))
    s = re.sub(r"\b(s\.?p\.?a|s\.?r\.?l|s\.?n\.?c|s\.?a\.?s)\b\.?", "", s)
    return re.sub(r"[^a-z0-9]", "", s)

def mpn_key(mpn):
    return re.sub(r"[^0-9A-Z]", "", mpn.upper())

In our test, D'Amico Casa S.r.l., D’Amico Casa and D'Amico Càsa srl gave the same key: damicocasa. MC-450.B, mc 450 b and MC450/B all became MC450B. MC-450.W stayed separate. Do not strip color or variant suffixes, because the suffix often marks a different product.

Size in Italian product names

The same product is described in different packaging language in two stores. One store writes 6 x 1,5 L, the other 1,5lt confezione da 6. The decimal separator is a comma, liters are abbreviated l or lt, grams g or gr. The count comes with conf. da 3, 10 pz or pezzi. On wine labels the unit can also come before the number: cl 75.

The parser writes count, amount and unit to separate fields. Converting the amount to grams or milliliters makes 0,35 kg equal to 350 g.

python
UNITS = {"kg": ("g", 1000), "gr": ("g", 1), "g": ("g", 1),
         "lt": ("ml", 1000), "l": ("ml", 1000),
         "cl": ("ml", 10), "ml": ("ml", 1)}
NUM = r"(\d+(?:[.,]\d+)?)"
U = r"(kg|gr|g|lt|l|cl|ml)"
SIZE = re.compile(rf"(?:(\d+)\s*x\s*)?{NUM}\s*{U}\b")
REVERSED = re.compile(rf"\b{U}\.?\s*{NUM}\b")  # "cl 75"
PACK = re.compile(
    r"(?:conf(?:ezione)?\.?|pacco|set)\s*da\s*(\d+)"
    r"|(\d+)\s*(?:pz|pezzi|bottiglie|lattine|capsule)\b"
)

def parse_size(name):
    s = name.lower().replace("×", "x")
    count, amount, unit = 1, None, None
    m = SIZE.search(s)
    if m:
        count = int(m.group(1) or 1)
        num, u = m.group(2), m.group(3)
    elif (m := REVERSED.search(s)):
        u, num = m.group(1), m.group(2)
    if m:
        unit, factor = UNITS[u]
        amount = round(float(num.replace(",", ".")) * factor, 3)
    p = PACK.search(s)
    if p:
        count = int(p.group(1) or p.group(2))
    return {"count": count, "amount": amount, "unit": unit}

In our test, Acqua Minerale Naturale 6 x 1,5 L and Acqua Naturale 1,5lt confezione da 6 gave the same result: 6 items, 1,500 ml. The n.5 in Spaghetti n.5 500 g was not taken for a size, and 40 lavaggi 2 lt was read as 2,000 ml only. Twelve of thirteen names came out right. In Birra 66 cl x 3 the count comes after the size, so the count stayed at 1. Put formats the parser cannot read on the manual review list.

Accents are a trap in name matching too. Older systems write caffè as caffe', with an apostrophe in place of the accent. The brand_key function above also works on product names. With accents and punctuation removed, both spellings become caffe.

Reading schema.org fields

The JSON-LD on a product page gives identity data in its cleanest form. In the schema.org Product type, the GTIN sits in the gtin field or, by length, in gtin8, gtin12, gtin13 or gtin14. gtin is the general field and covers the other four. The manufacturer code is in mpn, the brand in brand. We explained how JSON-LD is added to a page in What Is Schema Markup?

The format of these fields varies from site to site. brand can be an object ({"@type": "Brand", "name": …}) or plain text. The product can sit inside a @graph list, and @type can arrive as a list. The GTIN may also be written as a number and have lost its first zero.

python
import json

GTIN_FIELDS = ("gtin", "gtin13", "gtin12", "gtin14", "gtin8")

def product_ids(html):
    blocks = re.findall(
        r'<script[^>]*application/ld\+json[^>]*>(.*?)</script>', html, re.S
    )
    for block in blocks:
        data = json.loads(block)
        if isinstance(data, dict):
            data = data.get("@graph", [data])
        for d in data:
            kind = d.get("@type")
            if "Product" not in (kind if isinstance(kind, list) else [kind]):
                continue
            brand = d.get("brand")
            if isinstance(brand, dict):
                brand = brand.get("name")
            raw = next((d[k] for k in GTIN_FIELDS if d.get(k)), None)
            yield {
                "gtin": gtin14(raw) if raw else None,
                "mpn": d.get("mpn"),
                "brand": brand,
                "name": d.get("name"),
            }

Italian stores can show catalog, price and delivery information based on the visitor's country. A page opened from Türkiye may redirect you to another country's store. Take the measurement from an IP that exits in Italy. We list the exit points in the country on our Italy proxy page.

python
import requests

PROXY = "http://user:pass@pr.proxynet.io:8000"
URL = "https://negozio.example/p/macchina-caffe-mc-450"

s = requests.Session()
s.proxies = {"http": PROXY, "https": PROXY}
s.headers["Accept-Language"] = "it-IT,it;q=0.9"

r = s.get(URL, timeout=30)
r.raise_for_status()
for product in product_ids(r.text):
    print(product)

The output looks like {'gtin': '08001234567897', 'mpn': 'MC-450.B', 'brand': "D'Amico Casa", 'name': 'Macchina da caffè MC-450 nera'}. A Residential Proxy, which carries home connection IPs, opens the page from a home connection in Italy. Keep the request rate low and follow the site's terms and its robots.txt rules.

Match confidence table

Every match carries a confidence level, and the level decides whether the match is approved automatically or by hand.

CaseConfidenceAction
GTIN equal, both codes single itemsExactMatch automatically
GTIN equal, code in the in-store rangeLowManual review
One side is a case GTIN (first digit 1-8)LowManual review, record the count
GTIN differentNoneSeparate products
Brand and MPN equal, same sizeHighMatch automatically, audit by sampling
Brand and MPN equal, different sizeLowManual review
Only brand, name and size equalLowManual review

In code, the table is a short function. If both sides have a GTIN, the GTIN decides. Otherwise brand, MPN and size are checked.

python
def match(a, b):
    ga, gb = a.get("gtin"), b.get("gtin")
    if ga and gb:
        if gtin_type(ga) != "product" or gtin_type(gb) != "product":
            return "manual review"
        return "exact" if ga == gb else "different"
    same_brand = brand_key(a["brand"]) == brand_key(b["brand"])
    same_size = parse_size(a["name"]) == parse_size(b["name"])
    if not same_brand:
        return "different"
    if a.get("mpn") and b.get("mpn"):
        if mpn_key(a["mpn"]) != mpn_key(b["mpn"]):
            return "different"
        return "high" if same_size else "manual review"
    return "manual review" if same_size else "different"

Troubleshooting

Matching errors usually show themselves through a few symptoms:

  • The same product has two records. One source read the GTIN as a number. Look for values with 9-11 digits.
  • The check digit does not match. The field may be the store's stock code, not a GTIN.
  • Two different products were matched. The code is in the in-store range, or the MPN's color suffix was stripped.
  • The unit price is off by a factor of 1,000. The kg and g or cl and ml factors got mixed up.
  • The JSON-LD is empty. The data may be added to the page with JavaScript. Search the raw HTML for ld+json.
  • 407 Proxy Authentication Required. The username or password is wrong.

You can quickly see with curl whether the page comes from the Italian store and what its identity fields hold:

bash
curl -x http://user:pass@pr.proxynet.io:8000 \
  -H "Accept-Language: it-IT,it;q=0.9" \
  -s https://negozio.example/p/macchina-caffe-mc-450 \
  | grep -o '"gtin[0-9]*":"[0-9]*"\|"mpn":"[^"]*"'

If the command prints nothing, the page has no JSON-LD or the request was redirected. Follow the redirect with -i.

How we tested

We ran the tests on December 3, 2026 on Windows 11 with Python 3.13.17, requests 2.34.2, Node 24.22.2 and curl 8.23.0. We did not use a real store. Locally, we set up a small HTTP server that serves an Italian product page with a Product inside @graph. In front of it we put a Node forward proxy that requires a password and logs incoming requests. In the examples we replaced the proxy address and the target with these local addresses.

We tried the gtin14 function with thirteen inputs. Valid codes came back as 14 digits, and a code with a broken last digit and a value with letters were rejected. The size parser read twelve of thirteen Italian names correctly. The match function classified six pairs at the levels in the table. The requests example passed the Accept-Language header to the server, and a wrong password returned 407. The target was plain HTTP, so we did not test the HTTPS tunnel in this setup.

The bottom line

Store every GTIN as 14-digit text, validate the check digit, and separate in-store and case codes. Without a GTIN, use brand and MPN together and add size as a second check. We describe how collected data feeds into regular tracking on our price monitoring page. Above all, never auto-approve a match found by product name alone.

Sources

Frequently asked questions

Are GTIN and EAN the same thing?

Largely, yes. GTIN is the general name for GS1 product numbers, which have 8, 12, 13 or 14 digits. In Europe, "EAN" usually means the 13-digit GTIN-13. The 12-digit UPC is a GTIN too. For matching, ignore the name the code arrives under. Pad the value to 14 digits, validate the check digit, then compare.

Why should I store the GTIN as 14 digits?

Because the same product is published at different lengths. One store writes a UPC with 12 digits, another writes the same code with 13 digits and a zero in front. In a text comparison the two differ. Padding with zeros to 14 digits reduces every format to one value and does not change the check digit. Store the value as text, not as a number, or the zeros at the front disappear.

If the check digit is valid, is the code a real product?

No. The check digit only catches typing errors. One in ten random numbers also passes the test. On top of that, codes starting with 02, 04 and 20-29 are for restricted circulation. They are common on products sold by weight and can mean different products in two chains. Review these codes, and case codes with a first digit of 1-8, by hand.

How do I match products without a GTIN?

With brand and MPN. The MPN is the manufacturer's model code and is unique only among that manufacturer's products. That is why it is used together with the brand. Strip both fields of case, accent, company suffix and punctuation differences. If there is no MPN either, find candidates by brand, name and size, but do not approve the result automatically.

Is it safe to remove hyphens and dots from an MPN?

In most cases, yes. Stores write the same code as MC-450.B, MC450/B or mc 450 b, and the punctuation carries no meaning. But do not remove color and variant suffixes. .B and .W are different products. Rarely, two different codes become identical once punctuation is removed. A size check usually catches this case.

Do I need an Italian IP to see Italian prices?

At most stores, yes. Sites can show catalog, price and delivery information based on the visitor's country. They can also redirect visitors from abroad to another country's store. Take the measurement from an IP that exits in Italy and with an Italian language header. Use the same country in every measurement series and record the country.

Ask ChatGPTAsk Claude