LIKE bug?

21 views
Skip to first unread message

Joseph Lindsay

unread,
Jun 14, 2024, 2:49:10 AM (7 days ago) Jun 14
to Google Ads Scripts Forum
I'm seeing queries using LIKE %string% will not match 0 instances.

For example LIKE %string%

will match "blah string blah"

but will not match "string blah" or "blah string"

in SQL % is supposed to match 0 or more, but in GAQL is matches 1 or more.

This is likely a bug.

Google Ads Scripts Forum Advisor

unread,
Jun 14, 2024, 6:01:19 AM (7 days ago) Jun 14
to adwords...@googlegroups.com

Hi,

Thank you for reaching out to the Google Ads Scripts support team.

I would like to inform you that GAQL has its own functionalities and some of them might be different from the SQL. I would recommend that you go through the “Google Ads Query Language Grammar” document for more information. Kindly use “%string” to match results with “blah string” and “string%” to match the results with “string blah”. 

I hope this helps! Get back to us with the below details if you still face any issues.

  • Google Ads account ID/CID
  • Name of the affected script
  • Shareable spreadsheet link if you are using any sheet in your script
You can share the requested details via Reply privately to the author option or a direct private reply to this email. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02tJKkR:ref" (ADR-00240899)

Thanks,
 
Google Logo Google Ads Scripts Team


Disha Sharma

unread,
Jun 14, 2024, 8:27:56 AM (7 days ago) Jun 14
to Google Ads Scripts Forum
function main() {
  var sheetUrl = 'https://docs.google.com/spreadsheets/d/1bSoKQgmZ-MeYtlPImYDkim8TpvCfU94i0vHxiO08qwE/edit?gid=0#gid=0';
  var sheetName = 'Campaign Reprot'; // Change this to your specific sheet name

  // Open spreadsheet and get the sheet
  var spreadsheet = SpreadsheetApp.openByUrl(sheetUrl);
  var sheet = spreadsheet.getSheetByName(sheetName);

  // Clear the existing content
  sheet.clear();

  // Define your report
  var report = AdsApp.report(
    "SELECT UAC_MH_Google_Order_Req_NeedHelp, Impressions, Clicks, Cost, Installs, CostPerInstall, Leads, CostPerLead " +
    "FROM CAMPAIGN_PERFORMANCE_REPORT " +
    "DURING LAST_30_DAYS"
  );

  // Get the rows from the report
  var rows = report.rows();

  // Create an array to store data
  var data = [];
  data.push(['UAC_MH_Google_Order_Req_NeedHelp', 'Impressions', 'Clicks', 'Cost', 'Installs', 'Cost per Install', 'Leads', 'Cost per Lead']); // Add headers

  // Loop through the rows and add to the data array
  while (rows.hasNext()) {
    var row = rows.next();
    data.push([
      row['UAC_MH_Google_Order_Req_NeedHelp'],
      row['Impressions'],
      row['Clicks'],
      row['Cost'],
      row['Installs'],
      row['CostPerInstall'],
      row['Leads'],
      row['CostPerLead']
    ]);
  }

  // Paste data into the sheet
  sheet.getRange(1, 1, data.length, data[0].length).setValues(data);
Reply all
Reply to author
Forward
0 new messages