Retrieve top level ad unit

342 views
Skip to first unread message

Steven Kamradt

unread,
Jun 22, 2018, 5:45:40 PM6/22/18
to Google's DoubleClick for Publishers API Forum
I am attempting to pull the top level ad unit, and I am not retrieving anything.  My query looks like the following:

WHERE PARENTID=0

This used to work just fine, but lately is not returning anything. Is there a trick to returning the top level ad unit?

Vincent Racaza (DFP API Team)

unread,
Jun 25, 2018, 4:14:02 AM6/25/18
to Google's DoubleClick for Publishers API Forum
Hi Steven,

To retrieve the top level ad units, you can explicitly set the adUnitView field of the ReportQuery to TOP_LEVEL. Or, if you have not set this field, then by default, it will return the top level ad units. Also, for your filter, by PARENTID, did you mean that you are filtering by PARENT_AD_UNIT_ID? If yes, then I am not 100% sure why the value of your filter is 0. Do you have any special reasons for this?

Also, if the top level ad units are really not returned on your end, then can you provide to me your complete SOAP request and response logs with your network code so I can further check? You may use the Reply privately to author option.

Thanks,
Vincent Racaza, DFP API Team

Steven Kamradt

unread,
Jun 26, 2018, 12:45:43 PM6/26/18
to Google's DoubleClick for Publishers API Forum
What I am trying to do is get a complete list of all available ad units so I can cache them in my application.  I am attempting to use the InventoryService getAdUnitsByStatement which mostly works except I need to know what nodes are at the top of the tree.  For many API releases the statement "WHERE parentId=0" would return the topmost node, but I am finding that it is not consistent across all of my customer installations. Where it once worked fine, it is now starting to return no records.  Is there a more consistent method of returning what the top of the ad unit tree looks like?

Vincent Racaza (DFP API Team)

unread,
Jun 27, 2018, 4:30:31 AM6/27/18
to Google's DoubleClick for Publishers API Forum
Hi Steven,

I will just answer to you publicly so the other forum users can see my answer if they bump into this thread.

Thanks for this explanation. I initially thought that you are referring to generating reports via ReportService. For the InventoryService, the filter "parentId = 0" would only return one ad unit per DFP network, and this ad unit is the root/network ad unit. If what you are referring by top level ad units are the next level ad units after the root ad unit, then after that query (where parentId = 0) that gets the root ad unit, you need to get the ad unit ID of this root ad unit and then use it in your next query as filter for the parentId field. This will then return the child ad units of your root ad unit.

For the network code that you provided privately, I was able to get the root ad unit by filtering by parentId = 0. However, for the next level of ad units, I only got one ad unit using the ad unit ID of the root ad unit as parentId filter. After that, I then used the ad unit ID of the previous returned data as parentId filter and it returned 64 ad units which are your actual top level ad units (except for root ad unit) based on the DFP UI. So you can also emulate this on your end (three queries, instead of two queries) to get the top level ad units in this specific DFP network.

Let me know if you have further clarifications.

Mark Morgioni

unread,
Apr 10, 2019, 4:27:18 PM4/10/19
to Google Ad Manager API Forum
Hi Vincent,

I found this thread and I have a similar question - I'm currently specifying 'HIERARCHICAL' for adUnitView in my report query. Is there a way to specify the number of ad levels I would like to receive in a report? 

Best,

Mark

admanagerapi...@google.com

unread,
Apr 11, 2019, 2:19:53 AM4/11/19
to google-doubleclick...@googlegroups.com
Hi Mark,

There's currently no way to specify the number of ad levels you may retrieve in a report as HIERARCHICAL adUnitView will show each descendant on a row of its own, however, you may filter the report on PARENT_AD_UNIT_ID to specify the ad unit level to report on, so basically, you could walk the Ad Unit tree (like this Java example) to get all the ad units of a specific ad unit level and break your reports up that way. 

Let me know if you have further clarifications.

Thanks,
Kevin Soriano, Ad Manager API Team
______________________________________________________________________
 An important reminder: v201805 has been deprecated.

 Give us your feedback:
     Feedback Survey

 Also find us on our blog and discussion group:
     http://googleadsdeveloper.blogspot.com/search/label/ad_manager_api
     https://developers.google.com/ad-manager/api/community

--
You received this message because you are subscribed to the Google Groups "Google Ad Manager API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages