Eseguire la migrazione del report Più venduti

Questo documento ti aiuta a eseguire la migrazione dalla versione precedente dei report Più venduti alla versione più recente. La versione precedente del report che esporta le tabelle BestSellers_TopBrands_, BestSellers_TopProducts_ e BestSellers_TopProducts_Inventory_ verrà ritirata il 1° settembre 2025.

Il nuovo report Più venduti offre quanto segue:

Tabelle esportate dai report vecchi e nuovi

La seguente tabella mette a confronto le tabelle esportate dai report precedenti e nuovi:

Report precedente Nuovo report
BestSellers_TopBrands BestSellersBrandWeekly e BestSellersBrandMonthly
BestSellers_TopProducts BestSellersProductClusterWeekly e BestSellersProductClusterMonthly
BestSellers_TopProducts_Inventory BestSellersEntityProductMapping

Il vecchio report contiene un'unica aggregazione dei dati dei più venduti in un intervallo di tempo non specificato. Il nuovo report fornisce sia le aggregazioni settimanali sia quelle mensili più recenti di questi dati al momento della richiesta.

Confronta BestSellers_TopBrands con BestSellersBrandWeekly e BestSellersBrandMonthly

La seguente tabella ti aiuta a identificare i campi nella tabella BestSellers_TopBrands che hanno sostituzioni equivalenti nelle tabelle BestSellersBrandWeekly e BestSellersBrandMonthly. Le sostituzioni per alcuni campi della vecchia tabella non sono disponibili.

BestSellers_TopBrands (vecchio) BestSellersBrandWeekly e BestSellersBrandMonthly (novità)
rank_timestamp _PARTITIONDATE e _PARTITIONTIME
brand brand
google_brand_id
ranking_category category_id
ranking_category_path.locale
ranking_category_path.name
ranking_country country_code
rank_id
rank rank
previous_rank previous_rank
relative_demand.bucket relative_demand
relative_demand.min
relative_demand.max
previous_relative_demand.bucket previous_relative_demand
previous_relative_demand.min
previous_relative_demand.max
relative_demand_change

Confronta BestSellers_TopProducts con BestSellersProductClusterWeekly e BestSellersProductClusterMonthly

La seguente tabella ti aiuta a identificare i campi nella tabella BestSellers_TopProducts che hanno sostituzioni equivalenti nelle tabelle BestSellersProductClusterWeekly e BestSellersProductClusterMonthly. Le sostituzioni per alcuni campi della vecchia tabella non sono disponibili.

BestSellers_TopProducts (vecchio) BestSellersProductClusterWeekly e BestSellersProductClusterMonthly (novità)
rank_timestamp _PARTITIONDATE e _PARTITIONTIME
rank_id entity_id
rank rank
previous_rank previous_rank
ranking_country country_code
ranking_category report_category_id
ranking_category_path.locale
ranking_category_path.name
relative_demand.bucket relative_demand
relative_demand.min
relative_demand.max
previous_relative_demand.bucket previous_relative_demand
previous_relative_demand.min
previous_relative_demand.max
relative_demand_change
product_title.locale
product_title.name title (un singolo titolo anziché un array per ogni lingua)
gtins variant_gtins
google_brand_id
brand brand
google_product_category
category_l1, category_l2, category_l3, category_l4, category_l5
google_product_category_path.locale
google_product_category_path.name
price_range.min price_range.min_amount_micros
price_range.max price_range.max_amount_micros
price_range.currency price_range.currency_code
product_inventory_status
brand_inventory_status

Mappatura dell'inventario dei dati dei prodotti più venduti

Nel vecchio report Più venduti, i dati dei prodotti più venduti vengono mappati ai dati di inventario del commerciante in una nuova tabella generata utilizzando la colonna rank_id della tabella TopProducts.

Nel nuovo report Più venduti, la colonna entity_id viene esportata nelle tabelle BestSellersProductCluster, che è associata a tutti gli ID prodotto dell'inventario del commerciante nella tabella BestSellersEntityProductMapping.

BestSellers_TopProductsInventory (vecchio) BestSellersEntityProductMapping (nuovo)
rank_id (rintracciato in BestSellers_TopProducts) entity_id (presente nelle tabelle BestSellersProductClustersWeekly e BestSellersProductClustersMonthly)
product_id product_id
merchant_id
aggregator_id

Esempi di query

Questa sezione evidenzia le modifiche alle query di esempio utilizzate per recuperare i dati dei best seller.

Esempio 1: recuperare i prodotti principali per una determinata categoria e un determinato paese

Le seguenti query restituiscono i prodotti principali per una determinata categoria e un determinato paese.

Utilizzare la tabella BestSellers_TopProducts (versione precedente)

SELECT
  rank,
  previous_rank,
  relative_demand.bucket,
  (SELECT name FROM top_products.product_title WHERE locale = 'en-US') AS product_title,
  brand,
  price_range,
  google_product_category
FROM
  `DATASET.BestSellers_TopProducts_MERCHANT_ID` AS top_products
WHERE
  _PARTITIONDATE = 'DATE' AND
  ranking_category = 267 /*Smartphones*/ AND
  ranking_country = 'US'
ORDER BY
  rank;

Utilizzare la tabella BestSellersProductClusterWeekly o BestSellersProductClusterMonthly (novità)

SELECT
  rank,
  previous_rank,
  relative_demand,
  title AS product_title,
  brand,
  price_range,
  category_l1,
  category_l2
FROM
  `DATASET.BestSellersProductClusterWeekly_MERCHANT_ID` AS top_products
WHERE
  _PARTITIONDATE = 'DATE' AND
  report_category_id = 267 /*Smartphones*/ AND
  country_code = 'US'
ORDER BY
  rank;

Esempio 2: recuperare i prodotti di punta nel tuo inventario

Le seguenti query restituiscono un elenco dei prodotti di punta nel tuo inventario.

Utilizzare la tabella BestSellers_TopProducts (versione precedente)

WITH latest_top_products AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellers_TopProducts_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
),
latest_top_products_inventory AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellers_TopProducts_Inventory_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
)
SELECT
  top_products.rank,
  inventory.product_id,
  (SELECT ANY_VALUE(name) FROM top_products.product_title) AS product_title,
  top_products.brand,
  top_products.gtins
FROM
  latest_top_products AS top_products
INNER JOIN
  latest_top_products_inventory AS inventory
USING (rank_id);

Utilizzare la tabella BestSellersProductClusterWeekly o BestSellersProductClusterMonthly (novità)

WITH latest_top_products AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellersProductClusterWeekly_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
),
latest_top_products_inventory AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellersEntityProductMapping_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
)
SELECT
  top_products.rank,
  inventory.product_id,
  top_products.title AS product_title,
  top_products.brand,
  top_products.variant_gtins
FROM
  latest_top_products AS top_products
INNER JOIN
  latest_top_products_inventory AS inventory
USING (entity_id);

Inoltre, se vuoi trovare il numero di prodotti o brand più venduti nel tuo inventario, esegui una query sulle tabelle BestSellerProductClusterWeekly o BestSellerProductClusterMonthly utilizzando le colonne product_inventory_status o brand_inventory_status. Vedi la seguente query di esempio:

SELECT
  *
FROM
  `DATASET.BestSellersProductClusterMonthly_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  product_inventory_status != 'NOT_IN_INVENTORY'
ORDER BY
  rank;

Esempio 3: recuperare i brand più importanti per una determinata categoria e un determinato paese

Le seguenti query restituiscono un elenco dei principali brand per una determinata categoria e un determinato paese.

Utilizzare la tabella BestSellers_TopBrands (versione precedente)

SELECT
  rank,
  previous_rank,
  brand
FROM
  `DATASET.BestSellers_TopBrands_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  ranking_category = 267 /*Smartphones*/ AND
  ranking_country = 'US'
ORDER BY
  rank;

Utilizzare la tabella BestSellersTopBrandsWeekly o BestSellersTopBrandsMonthly (novità)

SELECT
  rank,
  previous_rank,
  brand
FROM
  `DATASET.BestSellersTopBrandsWeekly_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  report_category_id = 267 /*Smartphones*/ AND
  country_code = 'US'
ORDER BY
  rank;

Esempio 4: recuperare i prodotti dei principali brand nel tuo inventario

Le seguenti query restituiscono un elenco dei prodotti dei principali brand nel tuo inventario.

Utilizzare la tabella BestSellers_TopBrands (versione precedente)

WITH latest_top_brands AS
  (
    SELECT
      *
    FROM
      `DATASET.BestSellers_TopBrands_MERCHANT_ID`
    WHERE
      _PARTITIONDATE = 'DATE'
  ),
  latest_products AS
  (
    SELECT
      product.*,
      product_category_id
    FROM
      `DATASET.Products_MERCHANT_ID` AS product,
      UNNEST(product.google_product_category_ids) AS product_category_id,
      UNNEST(destinations) AS destination,
      UNNEST(destination.approved_countries) AS approved_country
    WHERE
      _PARTITIONDATE = 'DATE'
  )
SELECT
  top_brands.brand,
  (SELECT name FROM top_brands.ranking_category_path
  WHERE locale = 'en-US') AS ranking_category,
  top_brands.ranking_country,
  top_brands.rank,
  products.product_id,
  products.title
FROM
  latest_top_brands AS top_brands
INNER JOIN
  latest_products AS products
ON top_brands.google_brand_id = products.google_brand_id AND
   top_brands.ranking_category = product_category_id AND
   top_brands.ranking_country = products.approved_country;

Utilizzare la tabella BestSellersTopBrandsWeekly o BestSellersTopBrandsMonthly (novità)

WITH latest_top_brands AS
  (
    SELECT
      *
    FROM
      `DATASET.BestSellersBrandMonthly_MERCHANT_ID`
    WHERE
      _PARTITIONDATE = 'DATE'
  ),
  latest_products AS
  (
    SELECT
      product.*,
      product_category_id
    FROM
      `DATASET.Products_MERCHANT_ID` AS product,
      UNNEST(product.google_product_category_ids) AS product_category_id,
      UNNEST(destinations) AS destination,
      UNNEST(destination.approved_countries) AS approved_country
    WHERE
      _PARTITIONDATE = 'DATE'
  )
SELECT
  top_brands.brand,
  - The full category name is not supported in the new BestSellersTopBrands tables.
  - (SELECT name FROM top_brands.ranking_category_path
  - WHERE locale = 'en-US') AS ranking_category,
  top_brands.category_id,
  top_brands.rank,
  products.product_id,
  products.title
FROM
  latest_top_brands AS top_brands
INNER JOIN
  latest_products AS products
ON top_brands.brand = products.brand AND
   top_brands.category_id = product_category_id AND
   top_brands.country_code = products.approved_country;

In queste query, sostituisci quanto segue:

  • DATASET: il nome del set di dati
  • MERCHANT_ID: l'ID account commerciante
  • DATE: la data nel formato YYYY-MM-DD

Passaggi successivi