facebook-java-business-sdk icon indicating copy to clipboard operation
facebook-java-business-sdk copied to clipboard

Using Marketing API to fetch AdInsights with breakdown hourly, but no hourly data returned

Open adl-rjohns opened this issue 4 years ago • 7 comments

Marketing API v7.0 (java libs)

I am attempting to pull hourly metric data but the returned report does not contain hourly information. Here is some pseudo code so you can see how I'm trying to get it:

AdAccount.APIRequestGetInsightsAsync insightsRequest = new AdAccount(ac.getId(), context).getInsightsAsync(); insightsRequest.setLevel( AdsInsights.EnumLevel.VALUE_ADSET ); insightsRequest.setBreakdowns(Arrays.asList(AdsInsights.EnumBreakdowns.VALUE_HOURLY_STATS_AGGREGATED_BY_AUDIENCE_TIME_ZONE)); // fields == "adset_id","campaign_id","impressions","inline_link_clicks","spend,action_values","actions","date_start" insightsRequest.requestFields( Arrays.asList(fields) ); AdReportRun report = insightsRequest.execute();

I'm expecting data returned in this report to include hourly info, something like this: ... { "impressions": "172", "date_start": "2020-06-23", "date_stop": "2020-06-23", "hourly_stats_aggregated_by_audience_time_zone": "01:00:00 - 01:59:59" ... } ...

However, the data I get back looks like this .... { "impressions": "172", "date_start": "2020-06-23", "date_stop": "2020-06-23", ... } ....

which is to say, the "hourly_stats_aggregated_by_audience_time_zone": "01:00:00 - 01:59:59" data is never present in the json. As such I have no hourly information.

Any insight as to why this might be, or what I may be doing incorrectly would be most appreciated.### Which SDK version are you using?

adl-rjohns avatar Jul 01 '20 22:07 adl-rjohns

Answering my own question here. The problem was that the AdsInsights class in the

facebook-java-business-sdk.7.0.0

java lib is missing the following data members:

@SerializedName("hourly_stats_aggregated_by_advertiser_time_zone") 
private String mHourlyStatsAggregatedByAdvertiserTimeZone = null; 

@SerializedName("hourly_stats_aggregated_by_audience_time_zone") 
private String mHourlyStatsAggregatedByAudienceTimeZone = null;

Apparently, the last time these fields were present was in the 6.0.0 version of the same lib. I checked the change logs and there is no indication that these fields have been deprecated or removed so this is almost certainly an oversight of some sort. To whomever can update the latest java jdk libs, please restore these fields as well as the product_id data member which is also missing. Thanks.

adl-rjohns avatar Jul 23 '20 15:07 adl-rjohns

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 12:12 stale[bot]

This is still an issue that I would very much like to see get resolved.

adl-rjohns avatar Dec 25 '20 23:12 adl-rjohns

If I'm not mistaken, this issue seems like one that would be relatively straight forward to fix. Is it not the case that the codegen file:

facebook-business-sdk-codegen/api_specs/specs/AdsInsights.json

needs to add back these:

{ "name": "hourly_stats_aggregated_by_advertiser_time_zone", "type": "string" }
{ "name": "hourly_stats_aggregated_by_audience_time_zone", "type": "string" }
{ "name": "program_id", "type": "string" }

adl-rjohns avatar Dec 30 '20 15:12 adl-rjohns

Hi @alducent ,

I am facing issue with getting age and gender breakdown. Using FB business sdk 8.

			AdAccount.APIRequestGetInsights insightsRequest = account.getInsights().setTimeRange(datePreset)
					.setBreakdowns(List.of(AdsInsights.EnumBreakdowns.VALUE_AGE, AdsInsights.EnumBreakdowns.VALUE_GENDER));

No fields return for age and gender and many are null objects. But, this is working fine with curl request. Any idea?

RushiJeavio avatar Jun 17 '21 15:06 RushiJeavio

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 09 '22 02:01 stale[bot]

same issue with sdk 15.0

tianzhang-os avatar Mar 15 '23 05:03 tianzhang-os