Come esportare i termini di ricerca di Google Ads più performanti in Fogli Google
Come esportare i termini di ricerca di Google Ads più performanti in Fogli Google
Come esportare i termini di ricerca di Google Ads più performanti in Fogli Google

Come esportare i termini di ricerca di Google Ads più performanti in Fogli Google utilizzando Apps Script

Ti è piaciuto questo articolo?
Share it on social media!
Contenuto

Se gestisci campagne Performance Max o a corrispondenza generica, conosci già questa problematica. Google nasconde le query di ricerca reali. Questo script le recupera. Si collega direttamente al tuo Centro Clienti, acquisisce le query convertite e le inserisce in un foglio di calcolo Google con CPA e tasso di conversione calcolati.

Il nostro script, "Come esportare i termini di ricerca di Google Ads più performanti in Fogli Google utilizzando Apps Script", è perfetto per le agenzie che gestiscono più clienti o per i professionisti del marketing che vogliono smettere di tirare a indovinare.

Let’s break it down.

What Export Top Performing Google Ads Search Terms Script Does

  • Estrae 6 mesi di dati di query su tutte le campagne
  • Filtra la spazzatura: termini di marca e rumore a bassa conversione
  • Calcola il costo per conversione e il tasso di conversione
  • Rilascia tutto in un foglio Google pulito, una scheda per account

Come aggiungere uno script di Google Ads

Nella sezione Script viene impostata tutta l'automazione in blocco all'interno di Google Ads MCC.

1. Log in to your MCC (Manager Account) and go to Tools > Bulk Actions > Scripts

2. Click the blue plus (+) button to create a new script

Si apre l'editor di script. Non preoccuparti, non dovrai scrivere codice da zero. Incollerai uno script già scritto. Cliccando su questo pulsante si crea un contenitore di script vuoto per l'automazione.

Dai un nome al tuo script

Dare un nome allo script è essenziale per la gestione e la pianificazione a lungo termine.

3. Name the script so it’s easy to identify later

Nella parte superiore della finestra dell'editor di script, vedrai un campo per inserire un nome. Usa un nome chiaro, come "Report sui termini di ricerca più performanti". Questo ti aiuterà a riconoscere lo script in seguito, quando gestirai più script o account.

You can name it Top Performing Actual Search Terms and drop in the script (included at the bottom of this post).

Dai un nome al tuo script

Dai un nome allo script

4. Paste the entire script into the editor

function main() {
// Set the destination Google Sheet URL
var spreadsheetUrl = 'Paste Your Google Sheet URL Here';

// Get the account name to dynamically name the sheet
var accountName = AdsApp.currentAccount().getName();

// Use the account name to label the tab inside the spreadsheet
var sheetName = accountName + ' - Top Performing Terms PC 90 Days';

// Open the spreadsheet by URL
var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);

// Get the sheet by name, or create it if it doesn't exist
var sheet = spreadsheet.getSheetByName(sheetName) || spreadsheet.insertSheet(sheetName);

// Clear any existing data from the sheet
sheet.clear();

// Write header row to the spreadsheet
sheet.getRange('A1').setValue('Campaign Name');
sheet.getRange('B1').setValue('Ad Group Name');
sheet.getRange('C1').setValue('Search Term');
sheet.getRange('D1').setValue('Conversions');
sheet.getRange('E1').setValue('Conversion Value');
sheet.getRange('F1').setValue('Cost Per Conversion (CPA)');
sheet.getRange('G1').setValue('Conversion Rate (%)');

// Set the custom date range for reporting (format: YYYYMMDD)
var startDate = '20230315';
var endDate = '20240915';

// Build the query from the Search Query Performance Report
var report = AdsApp.report(
"SELECT CampaignName, AdGroupName, Query, Conversions, ConversionValue, Cost, Clicks " +
"FROM SEARCH_QUERY_PERFORMANCE_REPORT " +
"WHERE Conversions > 0 " +
"DURING " + startDate + "," + endDate
);

// Get report rows and set starting row for data insertion
var rows = report.rows();
var rowNumber = 2;

// Iterate through each row of the report
while (rows.hasNext()) {
var row = rows.next();

// Lowercase the search term for consistent brand filtering
var searchTerm = row['Query'].toLowerCase();
var conversions = parseFloat(row['Conversions']);

// Skip rows with less than 1 conversion
if (conversions < 1) continue;

// Exclude branded terms to avoid polluting the report
if (searchTerm.includes('parker chase') || searchTerm.includes('parker-chase') || searchTerm.includes('endeavor schools')) {
continue;
}

// Optional generic filter - add or remove terms here
if (
searchTerm.includes('creative') ||
searchTerm.includes('learning') ||
searchTerm.includes('content')
) {
continue;
}

// Extract cost and click values to calculate performance
var cost = parseFloat(row['Cost']);
var clicks = parseFloat(row['Clicks']);

// Calculate cost per conversion (CPA)
var cpa = conversions > 0 ? cost / conversions : 0;

// Calculate conversion rate
var conversionRate = clicks > 0 ? (conversions / clicks) * 100 : 0;

// Format values
cpa = cpa.toFixed(2);
conversionRate = conversionRate.toFixed(2);

// Write the row to the spreadsheet
sheet.getRange(rowNumber, 1).setValue(row['CampaignName']);
sheet.getRange(rowNumber, 2).setValue(row['AdGroupName']);
sheet.getRange(rowNumber, 3).setValue(row['Query']);
sheet.getRange(rowNumber, 4).setValue(conversions);
sheet.getRange(rowNumber, 5).setValue(row['ConversionValue']);
sheet.getRange(rowNumber, 6).setValue('$' + cpa); // Include dollar sign for CPA
sheet.getRange(rowNumber, 7).setValue(conversionRate + '%'); // Add percentage symbol

// Move to the next row in the sheet
rowNumber++;
}

// Log how many rows were processed
Logger.log('Export completed. Total rows processed: ' + (rowNumber - 2));
}

Cosa puoi personalizzare nello script

The script includes several marked settings you can adjust before running it. These are all inside the script's comment blocks and are meant to be changed based on your specific goals, reporting range, or formatting preferences.

Here’s a breakdown of what you can modify and why:

1. Spreadsheet URL

var spreadsheetUrl = 'https://docs.google.com/spreadsheets/d/xxxxx/edit';

What it does:
This is where the script sends your data. Replace the placeholder URL with the link to your Google Sheet. If you're using multiple email addresses, ensure the Sheet is shared with the Google account tied to your MCC.

2. Date Range Settings

var startDate = '20230315';
var endDate = '20240915';

What it does:
This controls the reporting window. Dates must be formatted as YYYYMMDD. You can adjust these to match whatever time frame you're analyzing, the last 30 days, the last 90 days, custom quarterly ranges, etc.

3. Sheet Name Behavior

var sheetName = accountName + ' - Top Performing Terms PC 90 Days';

What it does:
This line dynamically names the Sheet tab based on the account running the script. You can change the text string portion ('—Top Performing Terms PC 90 Days') if you want to label reports differently. This is useful when running across multiple brands or sub-accounts.

4. Branded Term Filtering

if (searchTerm.includes('parker chase') || searchTerm.includes('parker-chase') || searchTerm.includes('endeavor schools')) {
continue;
}

What it does:
This section excludes any branded terms from your report. You can update this list by adding or removing .includes() conditions. For example, if you want to exclude “MyBrand,” just add:

|| searchTerm.includes('mybrand')

Utilizzare sempre le lettere minuscole poiché lo script converte tutte le query in lettere minuscole.

5. Generic Term Filtering

if (
searchTerm.includes('creative') ||
searchTerm.includes('learning') ||
searchTerm.includes('content')
) {
continue;
}

What it does:
This optional filter weeds out terms that aren’t brand-specific but still muddy the data, like “learning” or “creative.” You can add or remove filters here based on what you consider noise.

6. Performance Threshold

if (conversions < 1) continue;

What it does:
This line removes queries with no conversions. You can increase this threshold if you want, only for higher-performing terms. For example, change to:

if (conversions < 3) continue;
...to include only search terms with 3+ conversions in the date range.

7. Sheet Output Formatting

sheet.getRange(rowNumber, 6).setValue('$' + cpa);
sheet.getRange(rowNumber, 7).setValue(conversionRate + '%');

What it does:
This controls how CPA and conversion rate are written on the sheet. You can edit or delete the string additions to remove symbols (e.g., $ or %).

Campi di output

Una volta eseguito correttamente, lo script popolerà il tuo Foglio Google con una tabella strutturata. Ogni riga rappresenta un termine di ricerca che ha generato almeno una conversione nell'intervallo di date specificato.

Primo piano di Google Sheet che mostra la formattazione pulita delle metriche di rendimento delle parole chiave più performanti

L'esempio di Google Sheet

Campi di output

Lo script genera un set di colonne sulle prestazioni nel tuo Foglio Google, fornendo una visione chiara del contributo di ciascun termine di ricerca. Queste includono i nomi della campagna e del gruppo di annunci per monitorare il punto in cui il termine è stato attivato, il termine di ricerca effettivamente digitato dall'utente, il numero di conversioni generate, il valore di conversione totale, il costo medio per conversione e il tasso di conversione complessivo. Ogni campo è fondamentale per capire cosa funziona e quali sprechi vengono generati.

  • Campaign Name
    Name of the campaign where the ad was triggered

  • Ad Group Name
    An ad group that matched the search term

  • Search Term
    The exact phrase the user typed into Google

  • Conversions
    Number of tracked conversions from that term

  • Conversion Value
    The total value of those conversions, based on your account settings

  • Cost Per Conversion (CPA)
    The average cost to generate one conversion from that search term

  • Conversion Rate (%)
    Percentage of clicks that resulted in a conversion

Come potrebbe essere migliorato questo script

This script is a solid foundation, but it can go further depending on how deep you want your reporting to go. If you manage multiple brands or accounts under one MCC, adding campaign labels or filters can help isolate data by brand or business unit. Scheduling the script to run automatically on a weekly or monthly basis saves time and ensures consistent reports. You can build logic to send alerts when key metrics, such as CPA or conversion rate, cross certain thresholds. For more granular analysis, you can combine this with other reports  KEYWORDS_PERFORMANCE_REPORT to get match-type breakdowns. Inside the Sheet, adding pivot tables or conditional formatting can surface insights faster. And if you want to go visual, the data can be pulled into Looker Studio for dashboards your clients can understand.

  • Aggiungi etichette di campagna o filtri a livello di account per segmentare i dati tra MCC di grandi dimensioni

  • Utilizza la pianificazione integrata per automatizzare i report settimanali o mensili

  • Attiva avvisi e-mail quando il CPA supera un valore specifico o il tasso di conversione scende al di sotto di una soglia

  • Unisci i dati di altri report, come KEYWORDS_PERFORMANCE_REPORT, per suddividere i tipi di corrispondenza

  • Aggiungi riepiloghi pivot di base o formattazione condizionale direttamente in Fogli

  • Collega l'output a Looker Studio per dashboard delle prestazioni visive

Considerazioni finali: Powered by Bright Vessel

Noi di Bright Vessel realizziamo strumenti di automazione personalizzati come questo per i clienti che necessitano di informazioni chiare sulle prestazioni da ambienti pubblicitari disordinati. Se sei stanco di dover rovistare in dashboard scadenti o di dover eseguire cinque esportazioni manuali per ottenere i dati di cui hai bisogno, questo script è solo uno dei tanti modi in cui semplifichiamo il processo.

Consulta la nostra guida dettagliata correlata su "Come monitorare lo stato degli obiettivi di Google Ads negli account MCC utilizzando Fogli Google e Apps Script" per un altro metodo per automatizzare il monitoraggio su larga scala.

Need a version of this that integrates with Slack, builds Looker dashboards, or connects multiple ad accounts into a master sheet? We can make it. Parliamo.

    Ottieni il tuo audit SEO gratuito

    Modulo di verifica SEO gratuito

    "*" indicates required fields

    Questo campo serve per la convalida e non dovrebbe essere modificato.
    Contenuto
    Ti è piaciuto questo articolo?
    Share it on social media!
    Ottieni il tuo audit SEO gratuito

    Modulo di verifica SEO gratuito

    "*" indicates required fields

    Questo campo serve per la convalida e non dovrebbe essere modificato.
    Ottieni il tuo audit SEO gratuito

    Modulo di verifica SEO gratuito

    "*" indicates required fields

    Questo campo serve per la convalida e non dovrebbe essere modificato.
    Ti è piaciuto questo articolo?
    Share it on social media!

    Dai un'occhiata a un altro post del blog!

    Torna a tutti i post del blog
    © 2024 Bright Vessel. Tutti i diritti riservati.
    chevron-downfreccia sinistra