Hi there,
Thanks for raising this to us.
It's great that you've figured it out on your own. However, let me provide a more context when it comes to date ranges.
Hope this helps.
Regards,
|
||||||
Hi there,
Harry hare, teammate of Mark on the Google Ads Scripts Team. Allow me to assist you further.
Mark and I made a couple of tests, but we can't seem to replicate the issue that you have mentioned. Please see below two date range approaches that you can test on your end. If the issue still persists, please let us know and kindly provide a screenshot showing the issue so that we will be able to check this on our end.
var dateFrom = "20210201"
var dateTo = "20210201"
var camIter = AdsApp.campaigns().withCondition("Status = ENABLED").forDateRange(dateFrom, dateTo).get();
while(camIter.hasNext()){
var campaign = camIter.next();
Logger.log(campaign.getId() + " - " +campaign.getName())
}
Logger.log("==================");
var report = AdsApp.report(
'SELECT CampaignName, Clicks, Impressions, Cost ' +
'FROM CAMPAIGN_PERFORMANCE_REPORT ' +
'WHERE Impressions < 10 ' +
'DURING ' +dateFrom + ','+dateTo);
var rows = report.rows();
while (rows.hasNext()) {
var row = rows.next();
var campaignName = row['CampaignName'];
var clicks = row['Clicks'];
var impressions = row['Impressions'];
var cost = row['Cost'];
Logger.log(campaignName + ',' + clicks + ',' + impressions + ',' + cost)
Let me know also if you have other questions
Thanks,
|
||||||
Hi,
I can't seem to replicate the error you are encountering. Both ways should work if the date values are both type of string and if the sheets returns the values as numbers, it will only work with the report query. Please be informed that the getValue() method returns the value of the top-left cell in the range. The value may be of type Number, Boolean, Date, or String depending on the value of the cell. You may set cell format by navigating to Format > Number in the Sheets menu.
Kindly provide your CID and script name so that I can take a closer look on what causes the issue that you are encountering and assist you further. You may send them here or privately via the reply to author option. If this option is not available at your end, you may send it through our email (googleadsscr...@google.com) instead.
Hello,
Thanks for coming back and informing us that the issue you have encountered is now resolved. Let me know if you have other questions or concerns.
Hi Jan,
Thanks for sharing your script and for extending your knowledge to this Google Ads Scripts community.
Let us know if you have any questions/concerns related to Google Ads Scripts. We'll be happy to assist you.
Regards,
|
||||||