# Shopify GTIN, MPN & Brand Coverage Audit (`practical_ai_lab_jp/pal-shopify-merchant-identifier-coverage-audit`) Actor

- **URL**: https://apify.com/practical_ai_lab_jp/pal-shopify-merchant-identifier-coverage-audit.md
- **Developed by:** [Practical AI Lab](https://apify.com/practical_ai_lab_jp) (community)
- **Categories:** E-commerce, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 audit reports

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Shopify GTIN, MPN & Brand Coverage Audit

Audit a dated Shopify product export for **GTIN, MPN and brand completeness**, see **how coverage changed by category** since an earlier export, and get a **supplier fix queue** with explicit confidence warnings.

This Actor reports identifier completeness in the data you give it. It **does not assert, predict or certify Google Merchant Center compliance** or product approval.

### Who it is for

Store operators and catalog analysts who receive product feeds from suppliers and need to know which suppliers and categories to chase for missing barcodes, MPNs or brand names, and whether things got better or worse between two dated exports.

### What it checks

Per variant (one row per variant):

- **GTIN**: missing, malformed (wrong length or characters), placeholder (for example all zeros), bad check digit, or shared by different products.
- **MPN**: missing or placeholder, when the export has an MPN column.
- **Brand**: the Shopify `Vendor` field is used as the brand; empty or placeholder values (such as "unknown") are flagged.
- A variant counts as **identifier-complete** when its brand is present and it has either a valid, unique GTIN or a usable MPN.

Across two snapshots, variants are matched by variant id, else by handle plus SKU, else by handle and position. The Actor reports regressions (complete before, incomplete now), fixes, GTIN changes, brand changes, and added or removed variants.

### Input

| Field | Purpose |
| --- | --- |
| `authorizationConfirmed` | Must be `true`. Confirms you may analyze the data. |
| `currentSnapshot` | One source: `csvText` (Shopify product CSV), `jsonText` (`products.json` content or a list of rows) or `shopUrl` (public store origin). Pasted text needs `capturedAt` (YYYY-MM-DD). |
| `previousSnapshot` | Optional earlier export (`csvText`/`jsonText` with `capturedAt`) or `snapshotKey` saved by an earlier run. Must be older than the current snapshot. |
| `categorySource`, `categoryDepth` | Which column defines categories and how many path levels to group by. |
| `minCategorySample` | Below this size a category is "low confidence" and change signals are suppressed (default 30). |
| `exemptCategories` | Categories that legitimately lack GTIN/MPN (for example handmade); excluded from rates and queues. |
| `maxRows`, `maxQueueVendors`, `maxChangeItems`, `maxPages`, `requestDelaySeconds` | Limits that keep runs small and polite. |
| `saveSnapshot` | Stores a compact snapshot (handle, SKU, GTIN, vendor, category) in a named key-value store for later comparison. |

#### Copyable sample input

The input form is pre-filled with this synthetic example. Replace the CSV text with your own export and keep `authorizationConfirmed` true only if you are allowed to analyze it.

```json
{
    "authorizationConfirmed": true,
    "currentSnapshot": {
        "label": "demo-store",
        "capturedAt": "2026-11-01",
        "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,,12.00\ntrail-flask,Trail Flask,Northpeak,Drinkware,NP-102,4006381333948,22.00\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789013,25.00\ncamp-lamp-2,Camp Lamp Mini,Brightly,Lighting,BR-201,4006381333931,15.00\nwool-sock,Wool Sock,,Apparel,WS-1,5012345678900,9.00\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\n"
    },
    "previousSnapshot": {
        "capturedAt": "2026-10-01",
        "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,4006381333948,12.00\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789012,25.00\nwool-sock,Wool Sock,Fieldwear,Apparel,WS-1,5012345678900,9.00\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\n"
    },
    "minCategorySample": 5
}
```

To monitor a store over time, run once with `saveSnapshot` on, then use the saved key (shown in the summary as `snapshotKeySaved`) as `previousSnapshot.snapshotKey` in a later run with a newer `capturedAt`.

### Output

The dataset has one row per record, tagged by `recordType`:

- `summary`: overall rates with a 95% interval, confidence level, change counts, warning count and the disclaimer.
- `category`: per-category completeness, GTIN/MPN/brand rates, issue counts, sample confidence, change in percentage points versus the previous snapshot, and a `changeSignal` (`likely_real_change`, `within_noise` or `insufficient_sample`).
- `supplier_fix`: ranked suppliers (Shopify vendors) with incomplete variants, issue counts, example items, a plain-language requested fix and a confidence level.
- `change`: variant-level regressions, fixes, GTIN changes and brand changes (capped by `maxChangeItems`).
- `warning`: confidence and data-quality warnings.

### Pricing event (not configured)

The code records one `audit-report` charge event after a report has been produced and saved. No payable plan is configured in this repository. Runs that fail validation, are refused by robots.txt or hit a feed error stop before any charge.

### Limitations and caveats

- **Sample size matters.** Rates for small categories swing widely. Categories below `minCategorySample` are labeled low confidence and change signals are suppressed. The category change test compares interval overlap between two snapshots; it is a screening aid, not a formal significance test, and the two snapshots are not paired samples.
- **Brand equals Vendor.** Shopify exports have no dedicated brand field, so a vendor name that is a distributor rather than the brand will look complete.
- **MPN is usually absent** from plain Shopify exports. Without an MPN column, completeness is judged on brand plus a valid GTIN, and MPN rates are not reported.
- **GTIN checks are structural** (length and check digit). The Actor cannot confirm that a code is registered to the product or its brand. Spreadsheet damage such as scientific notation (`4.00638E+12`) is reported as malformed.
- **Change detection depends on stable keys.** If variant ids and SKUs changed between exports, matches will be few and a low-overlap warning is raised.
- **Exempt categories are your decision.** The Actor does not decide which products legitimately lack identifiers.
- **Live mode** reads only the public `/products.json` feed of one store, at most `maxPages` x 250 products, and only if the store is a public HTTPS domain and robots.txt allows it. Stores that disable the feed cannot be audited that way; use an export instead. DNS is checked for public addresses before connecting, but a determined DNS-rebinding attack between the check and the request is not fully excluded.
- Snapshots saved with `saveSnapshot` are kept in a named key-value store until you delete them.
- The Actor does not log in, use proxies, collect contact details, or modify any store.

### Local development

Tests are offline and use only the Python standard library plus the project code:

```
python -m unittest discover -s tests -t .
```

# Actor input Schema

## `authorizationConfirmed` (type: `boolean`):

Tick only if you own the store or have permission to analyze this export or public feed. The bundled sample data is synthetic.

## `currentSnapshot` (type: `object`):

Provide exactly one source: csvText (Shopify product CSV), jsonText (products.json content) or shopUrl (public store origin, fetched with robots.txt checks). capturedAt (YYYY-MM-DD) is required for pasted text. Optional label names the report.

## `previousSnapshot` (type: `object`):

An earlier export to compare against: csvText or jsonText with capturedAt, or snapshotKey of a snapshot saved by an earlier run. Must be dated before the current snapshot.

## `categorySource` (type: `string`):

Which column defines categories. Auto uses Type, then Product Category.

## `categoryDepth` (type: `integer`):

How many levels of a 'A > B > C' category path to group by.

## `minCategorySample` (type: `integer`):

Categories and snapshots below this size are labeled low confidence and change signals are suppressed.

## `exemptCategories` (type: `array`):

Category names (after depth grouping) that legitimately have no GTIN/MPN, such as handmade goods. They are excluded from rates and fix queues.

## `maxRows` (type: `integer`):

Rows beyond this limit are ignored and a warning is added.

## `maxQueueVendors` (type: `integer`):

Limits the count of supplier action records in the report; summary totals remain unchanged.

## `maxChangeItems` (type: `integer`):

Cap on listed variant-level changes (regressions first). Counts in the summary are always complete.

## `maxPages` (type: `integer`):

Each page holds up to 250 products.

## `requestDelaySeconds` (type: `integer`):

Minimum delay between permitted public Shopify feed requests in live mode.

## `saveSnapshot` (type: `boolean`):

Stores identifiers (handle, SKU, GTIN, vendor, category) in a named key-value store so a later run can pass its key as previousSnapshot.snapshotKey.

## Actor input object example

```json
{
  "authorizationConfirmed": true,
  "currentSnapshot": {
    "label": "demo-store",
    "capturedAt": "2026-11-01",
    "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,,12.00\ntrail-flask,Trail Flask,Northpeak,Drinkware,NP-102,4006381333948,22.00\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789013,25.00\ncamp-lamp-2,Camp Lamp Mini,Brightly,Lighting,BR-201,4006381333931,15.00\nwool-sock,Wool Sock,,Apparel,WS-1,5012345678900,9.00\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\n"
  },
  "previousSnapshot": {
    "capturedAt": "2026-10-01",
    "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,4006381333948,12.00\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789012,25.00\nwool-sock,Wool Sock,Fieldwear,Apparel,WS-1,5012345678900,9.00\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\n"
  },
  "categorySource": "auto",
  "categoryDepth": 2,
  "minCategorySample": 30,
  "exemptCategories": [],
  "maxRows": 50000,
  "maxQueueVendors": 100,
  "maxChangeItems": 200,
  "maxPages": 5,
  "requestDelaySeconds": 2,
  "saveSnapshot": true
}
```

# Actor output Schema

## `results` (type: `string`):

Download rows from the latest run in JSON/CSV.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "authorizationConfirmed": true,
    "currentSnapshot": {
        "label": "demo-store",
        "capturedAt": "2026-11-01",
        "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,,12.00\ntrail-flask,Trail Flask,Northpeak,Drinkware,NP-102,4006381333948,22.00\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789013,25.00\ncamp-lamp-2,Camp Lamp Mini,Brightly,Lighting,BR-201,4006381333931,15.00\nwool-sock,Wool Sock,,Apparel,WS-1,5012345678900,9.00\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\n"
    },
    "previousSnapshot": {
        "capturedAt": "2026-10-01",
        "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,4006381333948,12.00\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789012,25.00\nwool-sock,Wool Sock,Fieldwear,Apparel,WS-1,5012345678900,9.00\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\n"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-shopify-merchant-identifier-coverage-audit").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "authorizationConfirmed": True,
    "currentSnapshot": {
        "label": "demo-store",
        "capturedAt": "2026-11-01",
        "csvText": """Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price
trail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00
trail-cup,Trail Cup,Northpeak,Drinkware,NP-101,,12.00
trail-flask,Trail Flask,Northpeak,Drinkware,NP-102,4006381333948,22.00
camp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789013,25.00
camp-lamp-2,Camp Lamp Mini,Brightly,Lighting,BR-201,4006381333931,15.00
wool-sock,Wool Sock,,Apparel,WS-1,5012345678900,9.00
canvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00
""",
    },
    "previousSnapshot": {
        "capturedAt": "2026-10-01",
        "csvText": """Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price
trail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00
trail-cup,Trail Cup,Northpeak,Drinkware,NP-101,4006381333948,12.00
camp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789012,25.00
wool-sock,Wool Sock,Fieldwear,Apparel,WS-1,5012345678900,9.00
canvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00
""",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-shopify-merchant-identifier-coverage-audit").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "authorizationConfirmed": true,
  "currentSnapshot": {
    "label": "demo-store",
    "capturedAt": "2026-11-01",
    "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,,12.00\\ntrail-flask,Trail Flask,Northpeak,Drinkware,NP-102,4006381333948,22.00\\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789013,25.00\\ncamp-lamp-2,Camp Lamp Mini,Brightly,Lighting,BR-201,4006381333931,15.00\\nwool-sock,Wool Sock,,Apparel,WS-1,5012345678900,9.00\\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\\n"
  },
  "previousSnapshot": {
    "capturedAt": "2026-10-01",
    "csvText": "Handle,Title,Vendor,Type,Variant SKU,Variant Barcode,Variant Price\\ntrail-bottle,Trail Bottle,Northpeak,Drinkware,NP-100,4006381333931,18.00\\ntrail-cup,Trail Cup,Northpeak,Drinkware,NP-101,4006381333948,12.00\\ncamp-lamp,Camp Lamp,Brightly,Lighting,BR-200,0123456789012,25.00\\nwool-sock,Wool Sock,Fieldwear,Apparel,WS-1,5012345678900,9.00\\ncanvas-bag,Canvas Bag,Tote Works,Bags,TW-5,,20.00\\n"
  }
}' |
apify call practical_ai_lab_jp/pal-shopify-merchant-identifier-coverage-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,practical_ai_lab_jp/pal-shopify-merchant-identifier-coverage-audit"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/FlVNQfp0OIRSPNJXB/builds/XWHUXAMrMecpddhtu/openapi.json
