> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# QuerySearchTermMetricsV2

# Package: googleAds

# Namespace: AnalyticsService

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

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

## Introduction

Retrieves a list of search terms that triggered a campaign's ads, given the provided filtering and sorting.
Supports both Smart campaigns and Performance Max Leads campaigns. Uses the Wix internal campaignId instead of the Google Ads resource name.

---

## REST API

### Schema

```
 Method: querySearchTermMetricsV2
 Description: Retrieves a list of search terms that triggered a campaign's ads, given the provided filtering and sorting. Supports both Smart campaigns and Performance Max Leads campaigns. Uses the Wix internal campaignId instead of the Google Ads resource name.
 URL: https://www.wixapis.com/_serverless/pa-google/v2/search-term-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:  campaignId
 Method parameters: 
   param name: campaignId | type: campaignId | description: Wix internal campaign GUID (GUID) of the campaign to query. | required: true | validation: format GUID
   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: paging | type: Paging | description: Paging information for an analytics query.  
        - name: nextPageToken | type: string | description: Token for retrieving the next page of results.  | validation: maxLength 100
        - name: pageSize | type: integer | description: Number of results to return.  
   param name: searchTermText | type: searchTermText | description: Filters results to search terms whose text contains this string. When omitted, all search terms are returned.  | validation: maxLength 1000
   param name: searchTermTextsFilter | type: SearchTermTextsFilter    
        - name: type | type: SearchTermTextFilterType | description: Whether to include or exclude search terms that match the provided list.  
             - enum:
             -     UNSPECIFIED: Unknown filter type. Do not use.
             -     MATCH: Return only search terms that appear in the provided list.
             -     NOT_MATCH: Return only search terms that do not appear in the provided list.
        - name: searchTermTexts | type: array<string> | description: Exact search term texts to filter by.  | validation: maxItems 1000, maxLength 1000
   param name: sort | type: SearchTermSorting    
        - name: field | type: SearchTermQueryFields | description: Metric field to sort by.  
             - enum:
             -     UNSPECIFIED: Unknown field. Do not use.
             -     IMPRESSIONS: Number of times the ad was shown for this search term.
             -     CLICKS: Number of clicks on the ad for this search term.
             -     COST: Total amount spent on ads triggered by this search term, in the account's currency.
             -     SEARCH_TERM: The search term text entered by the user.
        - name: order | type: SortOrder | description: Sort direction.  
             - enum:
             -     ASC: Ascending order.
             -     DESC: Descending order.
 Return type: QuerySearchTermMetricsV2Response
  - name: results | type: array<SearchTermMetrics> | description: Per-search-term metric results for the requested page.  | validation: maxItems 1000
     - name: impressions | type: integer | description: Number of times the ad was shown for this search term.  | read-only: true 
     - name: clicks | type: integer | description: Number of clicks on the ad for this search term.  | read-only: true 
     - name: cost | type: number | description: Total amount spent on ads triggered by this search term, in the account's currency.  | read-only: true 
     - name: searchTerm | type: string | description: The search term text entered by the user that triggered the ad.  | read-only: true | validation: maxLength 1000
  - name: summaryRow | type: SearchTermMetrics | description: Aggregated totals across all search terms, not just the current page.  
  - name: nextPageToken | type: string | description: Token to pass in the next request to retrieve the following page of results.  | validation: maxLength 1000


```

### Examples

### Query search term metrics for a campaign (V2)
Retrieves search term metrics using a Wix campaign ID, with optional text filtering and paging.

```curl
curl -X POST \
'https://www.wixapis.com/_serverless/pa-google/v2/search-term-metrics' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "campaignId": "b3f8e241-7c4a-4d19-a562-9f1e30d87c05",
  "searchTermText": "leather bag",
  "searchTermTextsFilter": {
    "type": "NOT_MATCH",
    "searchTermTexts": ["free leather bag", "cheap leather bag"]
  },
  "dateRange": {
    "custom": {
      "from": "2026-03-01",
      "to": "2026-03-31"
    }
  },
  "sort": {
    "field": "CLICKS",
    "order": "DESC"
  },
  "paging": {
    "pageSize": 10
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.promoteGoogleAds.performanceMetrics.querySearchTermMetricsV2(campaignId, options)
 Description: Retrieves a list of search terms that triggered a campaign's ads, given the provided filtering and sorting. Supports both Smart campaigns and Performance Max Leads campaigns. Uses the Wix internal campaignId instead of the Google Ads resource name.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  campaignId
 Method parameters: 
   param name: campaignId | type: string | description: Wix internal campaign GUID (GUID) of the campaign to query. | required: true | validation: format GUID
   param name: options | type: QuerySearchTermMetricsV2Options  none  
        - name: searchTermText | type: string | description: Filters results to search terms whose text contains this string. When omitted, all search terms are returned.  | validation: maxLength 1000
        - name: searchTermTextsFilter | type: SearchTermTextsFilter | description: Filters results to an explicit list of search term texts. When combined with searchTermText, only terms matching both conditions are returned.  
           - name: type | type: SearchTermTextFilterType | description: Whether to include or exclude search terms that match the provided list.  
                 - enum:
                 -     UNSPECIFIED: Unknown filter type. Do not use.
                 -     MATCH: Return only search terms that appear in the provided list.
                 -     NOT_MATCH: Return only search terms that do not appear in the provided list.
           - name: searchTermTexts | type: array<string> | description: Exact search term texts to filter by.  | validation: maxItems 1000, maxLength 1000
        - 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: SearchTermSorting | description: Sorting to apply. Defaults to descending by cost when omitted.  
           - name: field | type: SearchTermQueryFields | description: Metric field to sort by.  
                 - enum:
                 -     UNSPECIFIED: Unknown field. Do not use.
                 -     IMPRESSIONS: Number of times the ad was shown for this search term.
                 -     CLICKS: Number of clicks on the ad for this search term.
                 -     COST: Total amount spent on ads triggered by this search term, in the account's currency.
                 -     SEARCH_TERM: The search term text entered by the user.
           - name: order | type: SortOrder | description: Sort direction.  
                 - enum:
                 -     ASC: Ascending order.
                 -     DESC: Descending order.
        - name: paging | type: Paging | description: Paging to apply.  
           - name: nextPageToken | type: string | description: Token for retrieving the next page of results.  | validation: maxLength 100
           - name: pageSize | type: integer | description: Number of results to return.  
 Return type: PROMISE<QuerySearchTermMetricsV2Response>
  - name: results | type: array<SearchTermMetrics> | description: Per-search-term metric results for the requested page.  | validation: maxItems 1000
     - name: impressions | type: integer | description: Number of times the ad was shown for this search term.  | read-only: true 
     - name: clicks | type: integer | description: Number of clicks on the ad for this search term.  | read-only: true 
     - name: cost | type: number | description: Total amount spent on ads triggered by this search term, in the account's currency.  | read-only: true 
     - name: searchTerm | type: string | description: The search term text entered by the user that triggered the ad.  | read-only: true | validation: maxLength 1000
  - name: summaryRow | type: SearchTermMetrics | description: Aggregated totals across all search terms, not just the current page.  
  - name: nextPageToken | type: string | description: Token to pass in the next request to retrieve the following page of results.  | validation: maxLength 1000


```

### Examples

### Query search term metrics for a campaign (V2)
```javascript
import { performanceMetrics } from '@wix/promote-google-ads';

async function querySearchTermMetricsV2() {
  const response = await performanceMetrics.querySearchTermMetricsV2(
    'b3f8e241-7c4a-4d19-a562-9f1e30d87c05',
    {
      searchTermText: 'leather bag',
      searchTermTextsFilter: {
        type: 'NOT_MATCH',
        searchTermTexts: ['free leather bag', 'cheap leather bag'],
      },
      dateRange: {
        custom: {
          from: '2026-03-01',
          to: '2026-03-31',
        },
      },
      sort: {
        field: 'CLICKS',
        order: 'DESC',
      },
      paging: {
        pageSize: 10,
      },
    },
  );
}

/* Promise resolves to:
 * {
 *   "results": [
 *     {
 *       "searchTerm": "leather bag women",
 *       "impressions": 5632,
 *       "clicks": 421,
 *       "cost": 176.82
 *     },
 *     {
 *       "searchTerm": "leather handbag",
 *       "impressions": 3890,
 *       "clicks": 298,
 *       "cost": 125.16
 *     }
 *   ],
 *   "summaryRow": {
 *     "searchTerm": "",
 *     "impressions": 9522,
 *     "clicks": 719,
 *     "cost": 301.98
 *   },
 *   "nextPageToken": "CAoQAA"
 * }
 */

```

### querySearchTermMetricsV2 (self-managed)
Self-managed 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 querySearchTermMetricsV2(campaignId,options) {
  const response = await myWixClient.performanceMetrics.querySearchTermMetricsV2(campaignId,options);
};
```

---