Skip to content
CLI

Befehle der CLI

Jede Befehlsgruppe von productmetrics mit ihren Befehlen, dem Scope, den jeder braucht, und den wichtigsten Flags, dazu productmetrics capabilities und productmetrics call.

productmetrics hat einen Befehl pro Operation der öffentlichen API, gruppiert nach dem Teil vor dem Punkt in ihrer Capability-ID.

Einen Befehl finden

Die aktuelle Liste kommt immer vom Server:

# alle Operationen: Befehl, Scope, ob sie Daten ändert
productmetrics capabilities
productmetrics capabilities --search "merchant center"
productmetrics capabilities --scope write --json
# eine Gruppe
productmetrics <group> --help
# ein Befehl: Request, Scope, alle Flags, ein Beispiel
productmetrics <group> <command> --help

So lesen Sie die Tabellen

  • Command ist productmetrics <group> <command>. productmetrics call <capability-id> führt dieselbe Operation aus: productmetrics call google_ads.list_accounts ist productmetrics google-ads list-accounts.
  • What it does verlinkt die Seite der Operation in der API-Referenz, mit jedem Feld.
  • Scope ist der eine Scope, den Ihre Anmeldung braucht. Siehe Authentifizierung.
  • Must pass listet die Flags, ohne die der Befehl fehlschlägt: seine Pflichtfelder in Pfad, Query und Body sowie --body-file, --if-match, --auto-idempotency-key oder --yes, wo die Operation sie braucht. Alle anderen Flags stehen in productmetrics <group> <command> --help.
  • Mit Deletes markierte Befehle lassen sich nicht rückgängig machen. In einem Terminal bittet productmetrics Sie, statt --yes die ID einzutippen.

IDs stammen aus früheren Ergebnissen, nie aus Vermutungen: property_id und company_id aus productmetrics whoami, Installations-, Verbindungs- und Scope-IDs aus productmetrics tracking get-configuration, Regel-IDs aus productmetrics product-rules list.

Onboarding

Wo Sie im Onboarding von Product Metrics stehen, und wie es weitergeht.

CommandWhat it doesScopeMust pass
productmetrics onboarding get-stateGet onboarding stateread
productmetrics onboarding update-stepMove onboarding to a stepsetup--step
productmetrics onboarding set-account-typeSet account typesetup--account-type
productmetrics onboarding set-google-ads-connection-modeSet Google Ads connection modesetup--google-ads-connection-mode
productmetrics onboarding completeComplete onboardingsetup
productmetrics onboarding skipSkip onboardingsetup

Einrichtung

CommandWhat it doesScopeMust pass
productmetrics setup get-statusGet setup statusread

Die Antwort enthält journey_stage, user.google_grant, hub.company.next_action und hub.property.next_action.

Workspaces und Abrechnung

CommandWhat it doesScopeMust pass
productmetrics properties listList propertiesread
productmetrics companies listList workspacesread
productmetrics companies createCreate workspacesetup--name, --auto-idempotency-key
productmetrics billing create-checkout-linkCreate a checkout linksetup--company-id
productmetrics invitations sendInvite teammateswrite--company-id, --invitees
productmetrics usage get-ad-spendGet ad spend usageread--company-id, --start-date, --end-date

invitations send nimmt die eingeladenen Personen als JSON in --invitees (oder den ganzen Body in --body). Jede Rolle ist admin, editor oder viewer:

productmetrics invitations send \
  --company-id <company_id> \
  --invitees '[{ "email": "anna@example.com", "role": "editor" }]'

Google-Zugriff gewähren, Google-Ads-Konten verbinden (das legt Properties an), Conversion-Aktionen und Kundenlisten.

CommandWhat it doesScopeMust pass
productmetrics google get-connect-linkGet the Google connect linksetup--scope
productmetrics google-ads list-accountsList reachable Google Ads accountsread
productmetrics google-ads list-property-connectionsList Google Ads connectionsread--company-id
productmetrics google-ads create-property-connectionConnect a Google Ads accountsetup--company-id, --connection-mode, --customer-id
productmetrics google-ads list-pending-invitesList pending Google Ads invitesread--company-id
productmetrics google-ads send-inviteInvite a Google Ads accountsetup--company-id, --customer-id
productmetrics google-ads recheck-property-connectionRecheck a Google Ads connectionsetup--property-id
productmetrics google-ads delete-property-connectionDeletes. Disconnect a Google Ads accountsetup--property-id, --yes
productmetrics google-ads get-setup-statusGet workspace setup statusread--company-id
productmetrics google-ads get-plan-resultsGet plan resultsread--property-id
productmetrics google-ads get-conversion-actionsGet conversion action readinessread--property-id
productmetrics google-ads create-conversion-actionsCreate conversion actionssetup--property-id, --company-id
productmetrics google-ads get-customer-listsGet customer listsread--property-id, --company-id
productmetrics google-ads create-customer-listsCreate customer listssetup--property-id, --company-id

Merchant Center

CommandWhat it doesScopeMust pass
productmetrics merchant-center create-connectionConnect Merchant Centersetup--property-id, --merchant-id
productmetrics merchant-center recheck-connectionRecheck a Merchant Center connectionsetup--property-id
productmetrics merchant-center delete-connectionDeletes. Disconnect Merchant Centersetup--property-id, --yes
productmetrics merchant-center inspect-auto-setupInspect Merchant Center auto-setupread--property-id
productmetrics merchant-center get-auto-setup-statusGet Merchant Center auto-setup statusread--property-id
productmetrics merchant-center apply-auto-setupApply Merchant Center auto-setupsetup--property-id

Shops und Tracking

Einen Shop verbinden und prüfen, ob Käufe ankommen.

CommandWhat it doesScopeMust pass
productmetrics stores select-platformChoose the store platformsetup--company-id, --platform
productmetrics stores connectConnect a storesetup--company-id, --provider
productmetrics stores create-woocommerce-setup-claimNew WooCommerce setup tokensetup--installation-id
productmetrics tracking get-configurationGet tracking configurationread--company-id, --property-id
productmetrics tracking get-commerce-configurationGet store connectionsread--company-id
productmetrics tracking create-website-installationTrack a websitesetup--company-id, --verified-domain
productmetrics tracking get-last-purchaseCheck tracking worksread--company-id, --installation-id
productmetrics tracking get-shopware6-statusGet Shopware 6 statusread--company-id, --installation-id
productmetrics tracking update-installation-featuresSet the cookie consent manager and tracking featuressetup--company-id, --installation-id, --identity-discovery, --dynamic-checkout-observation, --cmp-adapter, --expanded-bot-signals, --server-authoritative-attribution-mode
productmetrics tracking update-margin-policySet the profit cost fallback and margin costssetup--company-id, --connection-id, --expected-revision, --policy, --auto-idempotency-key
productmetrics tracking update-scope-dimensionsSet a store’s countries and currenciessetup--company-id, --scope-id, --installation-id, --country-codes, --path-prefixes, --locale-codes, --currency-codes
productmetrics tracking set-scope-destinationSend a store’s purchases to Google Adssetup--company-id, --scope-id, --installation-id, --property-id, --pageview-destination, --consent-policy-version
productmetrics tracking assign-propertyAssign a store to a propertysetup--company-id, --scope-id, --installation-id, --property-id
productmetrics tracking get-enhanced-conversionsGet enhanced conversions readinessread--company-id, --property-id

stores connect antwortet je nach Plattform:

PlattformAntwortExit-Code
Shopifymode: redirect und eine authorizationUrl zum Genehmigen im Shopify-Admin4, next_action.type: "browser"
WooCommerce, Shopware 6 (--store-url)mode: plugin_claim und ein einmaliges Setup-Token, das vor claim.expiresAt in das Product-Metrics-Plugin eingefügt wird4, next_action.type: "store_plugin"
Lightspeed C-Series (--cluster, --shop-domain, --shop-id, --api-key, --api-secret)mode: provisioning: Die Verbindung wird eingerichtet

Übergeben Sie auch --auto-idempotency-key, damit eine Wiederholung keine zweite Verbindung startet. stores connect und stores create-woocommerce-setup-claim verbergen das Setup-Token, es sei denn, Sie übergeben --show-secrets. Danach zeigt productmetrics tracking get-commerce-configuration, wie die Verbindung aktiv wird.

Ein WooCommerce-Shop mit Plugin 1.0.12 oder neuer sendet beim Koppeln sein Land und seine Währung. Für jeden anderen Shop setzen Sie sie mit tracking update-scope-dimensions vor tracking update-margin-policy: Die Standard-Margenkosten (marginDefaultCatalog in tracking get-configuration) brauchen genau ein Land und eine Währung pro Shop-Scope.

Destinations

Destinations für die Meta Conversions API und die OpenAI Conversions API (ChatGPT Ads), eine pro Property.

CommandWhat it doesScopeMust pass
productmetrics destinations list-metaList Meta destinationsread--company-id
productmetrics destinations set-metaSave Meta destinationsetup--company-id, --property-id, --pixel-id, --test-event-code, --enabled
productmetrics destinations test-metaSend Meta test eventsetup--company-id, --property-id
productmetrics destinations delete-metaDeletes. Delete Meta destinationsetup--company-id, --property-id, --yes
productmetrics destinations list-openaiList ChatGPT Ads (OpenAI Conversions API) destinationsread--company-id
productmetrics destinations set-openaiSave ChatGPT Ads (OpenAI Conversions API) destinationsetup--company-id, --property-id, --pixel-id, --enabled
productmetrics destinations test-openaiSend ChatGPT Ads (OpenAI Conversions API) test eventsetup--company-id, --property-id
productmetrics destinations delete-openaiDeletes. Delete ChatGPT Ads (OpenAI Conversions API) destinationsetup--company-id, --property-id, --yes

Einstellungen

Einstellungen von Product Segmentation: lesen, eine empfohlene Mindestzahl an Klicks abrufen, einen Entwurf in der Vorschau ansehen, speichern. Jeder Befehl nimmt --feed-scope (eine Feed-ID oder all).

CommandWhat it doesScopeMust pass
productmetrics settings getGet Product Segmentation settingsread--property-id
productmetrics settings recommend-min-clicksRecommend minimum clicksread--property-id
productmetrics settings previewPreview Product Segmentation settingsread--property-id, --body-file
productmetrics settings preview-strategyPreview segmentation strategyread--property-id, --body-file
productmetrics settings updateSave Product Segmentation settingswrite--property-id, --labelizer-settings
productmetrics settings get --property-id <property_id> --json > settings.json
productmetrics settings recommend-min-clicks --property-id <property_id>
productmetrics settings preview \
  --property-id <property_id> \
  --feed-scope <feed> \
  --body-file draft.json
productmetrics settings update \
  --property-id <property_id> \
  --body-file new-settings.json \
  --if-match '"<settings_version>"'

Produktregeln

Regeln, die Segmente oder Prioritäten für die Produkte überschreiben, auf die sie zutreffen. Jeder Befehl nimmt --feed-scope.

CommandWhat it doesScopeMust pass
productmetrics product-rules listList product rulesread--property-id
productmetrics product-rules get-impactGet product rules impactread--property-id
productmetrics product-rules previewPreview product rule conditionsread--property-id, --when-cols, --when-ops, --when-vals
productmetrics product-rules createCreate a product rulewrite--property-id, --name, --when-cols, --when-ops, --when-vals, --target-cols, --action, --action-value
productmetrics product-rules reorderReorder product ruleswrite--property-id, --rules
productmetrics product-rules updateUpdate a product rulewrite--property-id, --rule-id
productmetrics product-rules toggleTurn a product rule on or offwrite--property-id, --rule-id
productmetrics product-rules deleteDeletes. Delete a product rulewrite--property-id, --rule-id, --yes

Feed

CommandWhat it doesScopeMust pass
productmetrics feed-source-settings getGet feed source settingsread--property-id
productmetrics feed-source-settings updateSave feed source settingswrite--property-id, --product-segment, --category-priority
productmetrics feed generateGenerate the feed nowwrite--property-id

Lagerbestand

CommandWhat it doesScopeMust pass
productmetrics inventory-settings getGet inventory planning settingsread--property-id
productmetrics inventory-settings updateSave an inventory planning settingwrite--property-id, --store-id, --scope-kind, --lead-time-days, --safety-buffer-days
productmetrics inventory get-stateGet inventory stateread--property-id

Shopdaten

Die eigenen Daten des Shops. Bestellungen, Business Health und Lagerbestand brauchen Pro.

CommandWhat it doesScopeMust pass
productmetrics orders get-availabilityCheck orders are availableread
productmetrics orders listList ordersread--company-id, --storefront-scope-id
productmetrics orders getGet an orderread--company-id, --order-id, --storefront-scope-id
productmetrics store list-shopsList shopsread--property-id
productmetrics store get-health-sliceGet Business Healthread--property-id, --window-days, --compare
productmetrics store get-health-seriesGet Business Health seriesread--property-id, --weeks, --compare
productmetrics store list-health-productsList Business Health productsread--property-id, --window-days
productmetrics analytics get-statusGet analytics statusread--property-id
productmetrics data queryQuery the lakeread--property-id, --sql
productmetrics insights getGet an insight cardread--property-id, --spot
productmetrics tracking get-configuration \
  --company-id <company_id> \
  --property-id <property_id>
productmetrics orders list \
  --company-id <company_id> \
  --storefront-scope-id <scope_id> \
  --limit 20
productmetrics data query \
  --property-id <property_id> \
  --sql "select count(*) from orders" \
  --max-rows 10

Feedback

productmetrics feedback sendet Feedback über feedback.send (Scope read) an das Team von Product Metrics. Es ist kein Support-Kanal; lassen Sie personenbezogene Daten weg. Die Nachricht kann das Argument oder --message sein; --about <capability-id> füllt --context und --feature, und --request-id fügt die Request-ID eines fehlgeschlagenen Aufrufs hinzu.

productmetrics feedback \
  --sentiment negative \
  --about settings.update \
  --request-id <request_id> \
  --message "The save answered 500 twice."

Capabilities und call

productmetrics capabilities listet jede Operation, die der Server anbietet, mit dem Befehl, der sie ausführt, ihrem Scope und ob sie Daten ändert. Mit --json hat jeder Eintrag außerdem command, secret_fields und browser_step.

FlagWas es tut
--search <text>Nur Operationen, deren ID, Titel oder Beschreibung diesen Text enthält
--scope read|setup|writeNur Operationen, die diesen Scope brauchen

productmetrics call <capability-id> führt eine Operation über ihre ID aus (mit _ oder -), mit denselben Feld-Flags wie der generierte Befehl:

productmetrics call google_ads.list_accounts
productmetrics call settings.get --param propertyId=<property_id> --json

Flags, die jeder API-Befehl nimmt

Neben seinen Feld-Flags nimmt jeder API-Befehl diese.

FlagWhat it does
--param <key=value>Set a path parameter by its API name (wins over its field flag)
--query <key=value>Set a query parameter by its API name (wins over its field flag)
--body <json>The JSON body; its keys win over field flags
--body-file <path>Read the JSON body from a file
--body-stdinRead the JSON body from stdin
--idempotency-key <uuid>Idempotency-Key header: the same key makes a retry safe
--auto-idempotency-keySend a new random Idempotency-Key (a failed call prints it for the retry)
--if-match <version>If-Match header: the version of the resource this change is based on
--show-secretsPrint fields the API marks as secret instead of hiding them
--yesConfirm an operation that deletes data, without a prompt
--dry-runPrint the request that would be sent, and send nothing

Nur diese Befehle nehmen einen Idempotency-Key; bei jedem anderen ist --auto-idempotency-key oder --idempotency-key ein Verwendungsfehler (Exit-Code 2):

  • productmetrics companies create (required)
  • productmetrics stores connect
  • productmetrics tracking update-margin-policy (required)

Wie geht es weiter?