> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# QueryPerformanceMetrics

# Package: googleAds

# Namespace: AnalyticsService

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/ads/google-ads/performance-metrics-v1/query-performance-metrics.md

## Permission Scopes:
View google ads campaigns: SCOPE.PROMOTE.VIEW-GOOGLE-ADS

## Introduction

Retrieves a list of daily performance metrics for a campaign, given the provided filtering and sorting.
Queries clicks, impressions, CTR, cost, leads, and phone calls from Google Ads in parallel.
Use the fields parameter to control which metrics are returned. When includePreviousPeriod is true,
the response also includes a previousPeriodSummaryRow and trends showing decimal percentage changes.

---

## REST API

### Schema

```
 Method: queryPerformanceMetrics
 Description: Retrieves a list of daily performance metrics for a campaign, given the provided filtering and sorting. Queries clicks, impressions, CTR, cost, leads, and phone calls from Google Ads in parallel. Use the fields parameter to control which metrics are returned. When includePreviousPeriod is true, the response also includes a previousPeriodSummaryRow and trends showing decimal percentage changes.
 URL: https://www.wixapis.com/_serverless/pa-google/v1/performance-metrics
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  campaignResourceName
 Method parameters: 
   param name: campaignResourceName | type: campaignResourceName | description: Google Ads resource name of the campaign to query, in the format `customers/{customerId}/campaigns/{campaignId}`. | required: true | validation: maxLength 1000
   param name: dateRange | type: DateRange | description: A date range used to filter analytics queries, either predefined or custom.  
    - ONE-OF: 
     - name: custom | type: CustomDateRange | description: Custom date range.  
        - name: from | type: string | description: Start date, in `YYYY-MM-DD` format.  | validation: maxLength 20
        - name: to | type: string | description: End date, in `YYYY-MM-DD` format.  | validation: maxLength 20
     - name: predefined | type: PredefinedDateRange | description: Predefined date range.  
         - enum:
         -     UNSPECIFIED: Not specified.
         -     TODAY: Today only.
         -     YESTERDAY: Yesterday only.
         -     LAST_7_DAYS: The last 7 days not including today.
         -     LAST_BUSINESS_WEEK: The 5 day business week, Monday through Friday, of the previous business week.
         -     THIS_MONTH: All days in the current month.
         -     LAST_MONTH: All days in the previous month.
         -     LAST_14_DAYS: The last 14 days not including today.
         -     LAST_30_DAYS: The last 30 days not including today.
         -     THIS_WEEK_SUN_TODAY: The period between the previous Sunday and the current day.
         -     THIS_WEEK_MON_TODAY: The period between the previous Monday and the current day.
         -     LAST_WEEK_SUN_SAT: The 7-day period starting with the previous Sunday.
         -     LAST_WEEK_MON_SUN: The 7-day period starting with the previous Monday.
         -     LIFETIME: Since the beginning of the campaign.
   param name: fields | type: array<fields> | description: Metrics to include in each result row. When omitted, defaults to clicks, impressions, CTR, cost, phone calls, and date.  | validation: maxItems 1000
                 - enum:
                 -     UNSPECIFIED: Unknown field. Do not use.
                 -     IMPRESSIONS: Number of times the ad was shown.
                 -     CLICKS: Number of clicks on the ad.
                 -     CTR: Click-through rate expressed as a decimal, for example 0.05 for 5%.
                 -     DATE: The date of the metric row, in YYYY-MM-DD format.
                 -     PHONE_CALLS: Number of phone calls initiated through the ad.
                 -     LEADS: Number of leads generated by the campaign.
                 -     COST: Total amount spent on the campaign in the account's currency.
                 -     COST_PER_CLICK: Average cost per click in the account's currency.
                 -     CLICKS_BY_AD_NETWORK_TYPE: Click count broken down by ad network type.
                 -     IMPRESSIONS_BY_AD_NETWORK_TYPE: Impression count broken down by ad network type.
   param name: includePreviousPeriod | type: includePreviousPeriod | description: When true, the response includes previousPeriodSummaryRow and trends showing percentage changes relative to the equivalent preceding period.  
   param name: sort | type: PerformanceSorting    
        - name: field | type: PerformanceQueryFields | description: Metric field to sort by.  
        - name: order | type: SortOrder | description: Sort direction.  
             - enum:
             -     ASC: Ascending order.
             -     DESC: Descending order.
 Return type: QueryPerformanceMetricsResponse
  - name: results | type: array<PerformanceMetrics> | description: Daily performance metric rows for the requested date range.  | validation: maxItems 1000
     - name: impressions | type: integer | description: Number of times the ad was shown.  
     - name: clicks | type: integer | description: Number of clicks on the ad.  
     - name: ctr | type: number | description: Click-through rate expressed as a decimal, for example 0.05 for 5%.  
     - name: date | type: string | description: Date of this metric row, in YYYY-MM-DD format.  
     - name: campaignResourceName | type: string | description: Google Ads resource name of the campaign, in the format `customers/{customerId}/campaigns/{campaignId}`.  
     - name: phoneCalls | type: integer | description: Number of phone calls initiated through the ad.  
     - name: leads | type: integer | description: Number of leads generated by the campaign.  
     - name: cost | type: number | description: Total amount spent in the account's currency. Already converted from micros.  
     - name: clicksByAdNetworkType | type: AdNetworkTypeSegmentation | description: Click count broken down by the ad network that served the ad.  
        - name: search | type: integer | description: Count of the metric attributed to Google Search.  
        - name: other | type: integer | description: Count of the metric attributed to ad networks not individually listed here. For Smart campaigns this includes all non-search networks such as display, video, and partner networks. For Performance Max campaigns this captures any networks beyond the ones explicitly broken out below.  
        - name: gmail | type: integer | description: Count of the metric attributed to Gmail placements.  
        - name: youtube | type: integer | description: Count of the metric attributed to YouTube placements.  
        - name: discover | type: integer | description: Count of the metric attributed to Google Discover placements.  
        - name: display | type: integer | description: Count of the metric attributed to the Google Display Network.  
        - name: searchPartners | type: integer | description: Count of the metric attributed to Google Search partner sites.  
     - name: impressionsByAdNetworkType | type: AdNetworkTypeSegmentation | description: Impression count broken down by the ad network that served the ad.  
  - name: summaryRow | type: PerformanceMetrics | description: Aggregated totals across all result rows.  
  - name: previousPeriodSummaryRow | type: PerformanceMetrics | description: Aggregated totals for the equivalent preceding period. Only present when includePreviousPeriod was true.  
  - name: trends | type: PerformanceMetricsTrends | description: Decimal percentage changes between the current and previous period summary rows. Only present when includePreviousPeriod was true.  
     - name: impressions | type: number | description: Impressions change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  | validation: format double
     - name: clicks | type: number | description: Clicks change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  | validation: format double
     - name: ctr | type: number | description: CTR change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  | validation: format double
     - name: phoneCalls | type: number | description: Phone calls change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  | validation: format double
     - name: leads | type: number | description: Leads change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  | validation: format double
     - name: cost | type: number | description: Cost change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  | validation: format double


```

### Examples

### Query performance metrics for a campaign
Retrieves daily performance metrics for a Google Ads campaign over a custom date range, including previous period comparison.

```curl
curl -X POST \
'https://www.wixapis.com/google-ads/v1/performance-metrics' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "campaignResourceName": "customers/3827461950/campaigns/7412836509",
  "dateRange": {
    "custom": {
      "from": "2026-03-01",
      "to": "2026-03-31"
    }
  },
  "fields": ["DATE", "IMPRESSIONS", "CLICKS", "CTR", "COST", "LEADS"],
  "sort": {
    "field": "DATE",
    "order": "DESC"
  },
  "includePreviousPeriod": true
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.promoteGoogleAds.performanceMetrics.queryPerformanceMetrics(campaignResourceName, options)
 Description: Retrieves a list of daily performance metrics for a campaign, given the provided filtering and sorting. Queries clicks, impressions, CTR, cost, leads, and phone calls from Google Ads in parallel. Use the fields parameter to control which metrics are returned. When includePreviousPeriod is true, the response also includes a previousPeriodSummaryRow and trends showing decimal percentage changes.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  campaignResourceName
 Method parameters: 
   param name: campaignResourceName | type: string | description: Google Ads resource name of the campaign to query, in the format `customers/{customerId}/campaigns/{campaignId}`. | required: true | validation: maxLength 1000
   param name: options | type: QueryPerformanceMetricsOptions  none  
        - name: dateRange | type: DateRange | description: Date range to query. When omitted, defaults to the campaign lifetime.  
           - ONE-OF: 
              - name: custom | type: CustomDateRange | description: Custom date range.  
                 - name: from | type: string | description: Start date, in `YYYY-MM-DD` format.  | validation: maxLength 20
                 - name: to | type: string | description: End date, in `YYYY-MM-DD` format.  | validation: maxLength 20
              - name: predefined | type: PredefinedDateRange | description: Predefined date range.  
                     - enum:
                     -     UNSPECIFIED: Not specified.
                     -     TODAY: Today only.
                     -     YESTERDAY: Yesterday only.
                     -     LAST_7_DAYS: The last 7 days not including today.
                     -     LAST_BUSINESS_WEEK: The 5 day business week, Monday through Friday, of the previous business week.
                     -     THIS_MONTH: All days in the current month.
                     -     LAST_MONTH: All days in the previous month.
                     -     LAST_14_DAYS: The last 14 days not including today.
                     -     LAST_30_DAYS: The last 30 days not including today.
                     -     THIS_WEEK_SUN_TODAY: The period between the previous Sunday and the current day.
                     -     THIS_WEEK_MON_TODAY: The period between the previous Monday and the current day.
                     -     LAST_WEEK_SUN_SAT: The 7-day period starting with the previous Sunday.
                     -     LAST_WEEK_MON_SUN: The 7-day period starting with the previous Monday.
                     -     LIFETIME: Since the beginning of the campaign.
        - name: sort | type: PerformanceSorting | description: Sorting to apply. Defaults to descending by date when omitted.  
           - name: field | type: PerformanceQueryFields | description: Metric field to sort by.  
                 - enum:
                 -     UNSPECIFIED: Unknown field. Do not use.
                 -     IMPRESSIONS: Number of times the ad was shown.
                 -     CLICKS: Number of clicks on the ad.
                 -     CTR: Click-through rate expressed as a decimal, for example 0.05 for 5%.
                 -     DATE: The date of the metric row, in YYYY-MM-DD format.
                 -     PHONE_CALLS: Number of phone calls initiated through the ad.
                 -     LEADS: Number of leads generated by the campaign.
                 -     COST: Total amount spent on the campaign in the account's currency.
                 -     COST_PER_CLICK: Average cost per click in the account's currency.
                 -     CLICKS_BY_AD_NETWORK_TYPE: Click count broken down by ad network type.
                 -     IMPRESSIONS_BY_AD_NETWORK_TYPE: Impression count broken down by ad network type.
           - name: order | type: SortOrder | description: Sort direction.  
                 - enum:
                 -     ASC: Ascending order.
                 -     DESC: Descending order.
        - name: fields | type: array<PerformanceQueryFields> | description: Metrics to include in each result row. When omitted, defaults to clicks, impressions, CTR, cost, phone calls, and date.  | validation: maxItems 1000
        - name: includePreviousPeriod | type: boolean | description: When true, the response includes previousPeriodSummaryRow and trends showing percentage changes relative to the equivalent preceding period.  
 Return type: PROMISE<QueryPerformanceMetricsResponse>
  - name: results | type: array<PerformanceMetrics> | description: Daily performance metric rows for the requested date range.  | validation: maxItems 1000
     - name: impressions | type: integer | description: Number of times the ad was shown.  
     - name: clicks | type: integer | description: Number of clicks on the ad.  
     - name: ctr | type: number | description: Click-through rate expressed as a decimal, for example 0.05 for 5%.  
     - name: date | type: string | description: Date of this metric row, in YYYY-MM-DD format.  
     - name: campaignResourceName | type: string | description: Google Ads resource name of the campaign, in the format `customers/{customerId}/campaigns/{campaignId}`.  
     - name: phoneCalls | type: integer | description: Number of phone calls initiated through the ad.  
     - name: leads | type: integer | description: Number of leads generated by the campaign.  
     - name: cost | type: number | description: Total amount spent in the account's currency. Already converted from micros.  
     - name: clicksByAdNetworkType | type: AdNetworkTypeSegmentation | description: Click count broken down by the ad network that served the ad.  
        - name: search | type: integer | description: Count of the metric attributed to Google Search.  
        - name: other | type: integer | description: Count of the metric attributed to ad networks not individually listed here. For Smart campaigns this includes all non-search networks such as display, video, and partner networks. For Performance Max campaigns this captures any networks beyond the ones explicitly broken out below.  
        - name: gmail | type: integer | description: Count of the metric attributed to Gmail placements.  
        - name: youtube | type: integer | description: Count of the metric attributed to YouTube placements.  
        - name: discover | type: integer | description: Count of the metric attributed to Google Discover placements.  
        - name: display | type: integer | description: Count of the metric attributed to the Google Display Network.  
        - name: searchPartners | type: integer | description: Count of the metric attributed to Google Search partner sites.  
     - name: impressionsByAdNetworkType | type: AdNetworkTypeSegmentation | description: Impression count broken down by the ad network that served the ad.  
  - name: summaryRow | type: PerformanceMetrics | description: Aggregated totals across all result rows.  
  - name: previousPeriodSummaryRow | type: PerformanceMetrics | description: Aggregated totals for the equivalent preceding period. Only present when includePreviousPeriod was true.  
  - name: trends | type: PerformanceMetricsTrends | description: Decimal percentage changes between the current and previous period summary rows. Only present when includePreviousPeriod was true.  
     - name: impressions | type: number | description: Impressions change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  
     - name: clicks | type: number | description: Clicks change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  
     - name: ctr | type: number | description: CTR change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  
     - name: phoneCalls | type: number | description: Phone calls change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  
     - name: leads | type: number | description: Leads change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  
     - name: cost | type: number | description: Cost change as a decimal percentage, for example 0.10 for a 10% increase or -0.05 for a 5% decrease.  


```

### Examples

### Query performance metrics for a campaign
```javascript
import { performanceMetrics } from '@wix/promote-google-ads';

async function queryPerformanceMetrics() {
  const response = await performanceMetrics.queryPerformanceMetrics(
    'customers/3827461950/campaigns/7412836509',
    {
      dateRange: {
        custom: {
          from: '2026-03-01',
          to: '2026-03-31',
        },
      },
      fields: ['DATE', 'IMPRESSIONS', 'CLICKS', 'CTR', 'COST', 'LEADS'],
      sort: {
        field: 'DATE',
        order: 'DESC',
      },
      includePreviousPeriod: true,
    },
  );
}

/* Promise resolves to:
 * {
 *   "results": [
 *     {
 *       "date": "2026-03-31",
 *       "campaignResourceName": "customers/3827461950/campaigns/7412836509",
 *       "impressions": 1820,
 *       "clicks": 128,
 *       "ctr": 0.0703,
 *       "cost": 54.20,
 *       "leads": 3
 *     },
 *     {
 *       "date": "2026-03-30",
 *       "campaignResourceName": "customers/3827461950/campaigns/7412836509",
 *       "impressions": 1654,
 *       "clicks": 114,
 *       "ctr": 0.0689,
 *       "cost": 48.72,
 *       "leads": 2
 *     }
 *   ],
 *   "summaryRow": {
 *     "campaignResourceName": "customers/3827461950/campaigns/7412836509",
 *     "impressions": 47381,
 *     "clicks": 3316,
 *     "ctr": 0.0699,
 *     "cost": 1408.65,
 *     "leads": 87
 *   },
 *   "previousPeriodSummaryRow": {
 *     "campaignResourceName": "customers/3827461950/campaigns/7412836509",
 *     "impressions": 41020,
 *     "clicks": 2874,
 *     "ctr": 0.0700,
 *     "cost": 1215.40,
 *     "leads": 71
 *   },
 *   "trends": {
 *     "impressions": 0.155,
 *     "clicks": 0.154,
 *     "ctr": -0.001,
 *     "cost": 0.159,
 *     "leads": 0.225
 *   }
 * }
 */

```

### queryPerformanceMetrics (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { performanceMetrics } from '@wix/promote-google-ads';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { performanceMetrics },
  // Include the auth strategy and host as relevant
});


async function queryPerformanceMetrics(campaignResourceName,options) {
  const response = await myWixClient.performanceMetrics.queryPerformanceMetrics(campaignResourceName,options);
};
```

---