google-ads-api
google-ads-api copied to clipboard
Customer report showing previous day's data when date_constant is 'TODAY'
I have a service that queries customer reports every 10 minutes on a cron job, and I've been noticing data from previous days recently started to "leak" into the next day. Upon further inspection, it seems that there's 2 points at which the report shows data from the previous day: slightly past midnight and at 3am. I was wondering if this is a known issue and if anyone has had success handling it properly without discarding useful data.
I call the report like this
const apiClient = new GoogleAdsApi({
client_id: GOOGLE_ADS_API_CLIENT_ID,
client_secret: GOOGLE_ADS_API_CLIENT_SECRET,
developer_token: GOOGLE_ADS_API_DEVELOPER_TOKEN,
});
const customer = apiClient.Customer({
customer_id: customerId,
refresh_token: refreshToken,
login_customer_id: loginCustomerId,
});
const rows = await customer.report({
entity: 'ad_group_ad',
attributes: [
'customer.time_zone',
'campaign.id',
'ad_group.id',
'ad_group_ad.ad.id',
'campaign.name',
'ad_group.name',
'ad_group_ad.ad.name',
],
metrics: [
'metrics.cost_micros',
'metrics.clicks',
'metrics.impressions',
],
date_constant: 'TODAY',
});
Even though I'm requesting data for 'TODAY'
, I still see data from the previous day at midnight and 3am. My first instinct was to look for a field in the query that would tell me the date for the data returned, but I couldn't find any such field. Does it exist? Otherwise, is there a way to guarantee that the report will only return today's data?