Hi Henry,
Thanks for raising this to us.
The easiest way to determine those stats depending on the date range is by using the getStatsFor() method. To compare the last 30 days, you can simply use the getStatsFor(dateRange) method having a predefined date range. However, to compare the previous 30 days, you can use the getStatsFor(dateFrom, dateTo) method wherein you would need to define your dateFrom and dateTo ranges.
Regards,
|
||||||
Hi Henry,
Harry here, teammate of Mark on the Google Ads Scripts Team. Allow me to assist you this time.
It is not possible to define the comparison window as the 30 days before the last 30 days & the same 30 day window of last year by using the LAST_30_DAYS date range. This said range will only filter data in between of the last 30 days not including today. Please see Date ranges for your reference.
With that said, you would have to use the getStatsFor(dateFrom, dateTo). If you would like to do this dynamically, then you would just have to make use of the JavaScript Date object. I haven't done this myself, but this should be possible. For example, generate the from and to date ranges for the month of January, February and March respectively.
Thanks,
|
||||||