pinterest / api-quickstart

Code that makes it easy to get started with the Pinterest API.
Apache License 2.0
119 stars 44 forks source link

Unable to retrieve data filtered on targeting types #91

Closed chrizi42 closed 1 year ago

chrizi42 commented 1 year ago

Howdy!

We are trying to use the https://developers.pinterest.com/docs/api/v5/#operation/analytics/create_report endpoint with the targeting_types parameter but we can't see any difference in the data when we are using one or more of the targeting types versus not specifying any targeting types in the request. Is there some special kind of combination of parameters that we need in the request when using targeting types?

Here is an example request:

POST: https://api.pinterest.com/v5/ad_accounts/<id>/reports

body: {"start_date": "2023-04-01", "end_date": "2023-04-05", "level": "AD_GROUP", "view_window_days": 1, "engagement_window_days": 30, "click_window_days": 30, "granularity": "DAY", "report_format": "JSON", "conversion_report_time": "TIME_OF_AD_ACTION", "columns": ["AD_GROUP_ID", "AD_GROUP_NAME", "AD_GROUP_STATUS", "CAMPAIGN_ID", "CAMPAIGN_MANAGED_STATUS", "CAMPAIGN_NAME", "CAMPAIGN_STATUS", "CLICKTHROUGH_1", "CLICKTHROUGH_2", "ENGAGEMENT_1", "ENGAGEMENT_2", "IMPRESSION_1", "IMPRESSION_2", "OFFLINE_CHECKOUT_ROAS", "ONSITE_CHECKOUTS_1", "OUTBOUND_CLICK_1", "OUTBOUND_CLICK_2", "REPIN_1", "REPIN_2", "SPEND_IN_MICRO_DOLLAR"], "campaign_statuses": ["RUNNING", "PAUSED", "COMPLETED"], "targeting_types": ["LOCATION", "GENDER", "REGION", "COUNTRY"]}

davidchaiken commented 1 year ago

Hi! I'll see what I can find out from the development team.

davidchaiken commented 1 year ago

Hi, @chrizi42. Here's what our developer support team recommends:

To fix this, they need to set level to AD_GROUP_TARGETING instead of just AD_GROUP. For all advertising levels (i.e. CAMPAIGN, AD, etc), when pulling targeting data, the _TARGETING suffix will need to be added.

Please let me know if that works for you, and if you have any thoughts about how we could make this information more clear in our documentation.

davidchaiken commented 1 year ago

Hi, @chrizi42. Just wondering how that advice worked out for you? And any thoughts on how we can improve our documentation would be really helpful!

chrizi42 commented 1 year ago

Hi @davidchaiken , I think this will work for us, thank you! Regarding the documentation, it would be awesome if you could just add that these fields require the *_TARGETING levels. A short sentence about that could be added to the section describing targeting_types, something like this:

Array of strings (AdsAnalyticsTargetingType) [ 1 .. 5 ] items Items Enum: "KEYWORD" "APPTYPE" "GENDER" "LOCATION" "PLACEMENT" "COUNTRY" "TARGETED_INTEREST" "PINNER_INTEREST" "AUDIENCE_INCLUDE" "GEO" "AGE_BUCKET" "REGION" List of targeting types. Requires level "*_TARGETING".

davidchaiken commented 1 year ago

Thanks for your feedback again, @chrizi42.

I'm closing out this issue, because (based on your recommendation) we've changed the relevant API documentation page to say:

List of targeting types. Requires level to be a value ending in _TARGETING.