Sigurd - Thanks for your suggestion. I just tested via AWQL and this solves my problem. Interestingly, I built a couple of different "spend check" functions, with one using getStats and the other doing a query of reports, and now I can see the benefits in using AWQL to handle this. With AWQL, we do get the matches by name, exactly as desired!! Ejay, thanks for always answering quickly, and Sigurd, thank you for the idea that was easy to test and even easier to implement since I already had the function in my MCC_Library. BTW -- where is the best place for me to share my completed function libraries? Should I just upload to Github and share links/descriptions in this forum? I want to give back to the community since it's given me so much! Thanks again - Christopher |
function main() { var campaignName = 'discovery'; // something that identifies all discovery campaigns var timePeriod = 'LAST_7_DAYS'; var report = AdsApp.report( 'SELECT ' + 'Cost, CampaignName ' + 'FROM CAMPAIGN_PERFORMANCE_REPORT ' + 'WHERE CampaignName CONTAINS_IGNORE_CASE ' + campaignName + ' ' + 'DURING ' + timePeriod ); var rows = report.rows(); var campaignNames = []; var campaignCosts = []; while (rows.hasNext()) { var row = rows.next(); var costS = JSON.stringify(row['Cost']).replace(',',''); var costD = JSON.parse(costS); var costFloat = parseFloat(costD); campaignCosts.push(costFloat) campaignNames.push(row['CampaignName'])} var summedCampaignCosts = 0; for (var key in campaignCosts) { summedCampaignCosts += campaignCosts[key]; } Logger.log('Total spend on campaigns with "' + campaignName + '" in the name during the ' + timePeriod.toLowerCase().replace(/_/g,' ') +': ' + summedCampaignCosts.toFixed(2) + '\n\nCampaigns:\n\n' + campaignNames.join('\n'));}
Hi Sigurd,
Thank you for helping the other developers in this forum.
However, the discovery campaign type is currently not supported in the Google Ads scripts and in any report types.
Also, upon checking the provided code, I can see that you are filtering the campaign by its name and not by its campaign type. So, I am assuming that all the campaigns that has ‘discovery’ on its name are discovery campaign type and you can get its information, especially the cost. With this, could you provide the customer ID and the name of the script where you’ve implemented the provided code so I can confirm this with the rest of the team. You can provide the requested information via Reply privately to author option.
Regards,
Ejay
Google Ads Scripts Team
|
||||||