Pmax search query optimizer (all time)
This script allows you to understand which search terms are triggering your ads and how these keywords are performing in terms of generating user clicks. This data is valuable for evaluating the performance of your keywords and making informed decisions about how to optimize your campaigns.
To set up this script, follow these steps:
Open your Google Ads account.
Go to the "Tools & Settings" menu and select "Scripts".
Click the "Create" or "+" button to create a new script.
Copy and paste the following script.
function main() {
// Enter your sheet URL, the campaign ID, and sheet name below
let sheetUrl = 'INSERT-SPREADSHEET-URL'; // Enter sheet URL between the quotes
let campaignId = 'INSERT-CAMPAIGN-ID'; // Enter pmax campaign ID between quotes
let sheetName = 'INSERT-SHEET-NAME'; // Enter the name of the sheet where you want to export data
// Don't touch code below this line
let ss = SpreadsheetApp.openByUrl(sheetUrl);
// Get today’s date in YYYY-MM-DD format
let today = Utilities.formatDate(new Date(), AdsApp.currentAccount().getTimeZone(), 'yyyy-MM-dd');
let query = AdsApp.report(
`
SELECT
campaign_search_term_insight.category_label,
metrics.clicks,
metrics.impressions,
metrics.conversions,
metrics.conversions_value
FROM campaign_search_term_insight
WHERE
segments.date BETWEEN '2000-01-01' AND '${today}'
AND campaign_search_term_insight.campaign_id = '${campaignId}'
ORDER BY metrics.conversions
`
);
// Use the sheetName variable to specify the sheet
query.exportToSheet(ss.getSheetByName(sheetName));
} // end main
Replace the spreadsheet URL, sheet name, and campaign name.
Save the script.
Review and authorize the script to access your Google Ads and Google Sheets accounts.
Run the script manually for the first time to populate the initial values in the spreadsheet.
(Optional) Schedule the script to run on a specific cadence (ie: daily, weekly, monthly, etc.)
Note: Ensure that you have the necessary permissions to access and modify the target Google Spreadsheet.
Last updated