How can we access the Ads Action Stats list in the Facebook Marketing API, using the Python SDK?

958 Views Asked by At

I have been trying to access the list on the Facebook Ads API for a few days now but haven't been able to make any headway.

I need to pull the purchase_roas field which is part of the Ads Action Stats List. However, I'm not able to do so.

I'm using the Python SDK and have been looking all over the place for some examples but haven't been able to find any!

Any directions or sample code would really help here. Thanks so much in advance.

1

There are 1 best solutions below

1
On BEST ANSWER

This is an example code of fetching the ROAS on an ad account:

    insights = FBAdAccount(fbid=adaccount_fb_id).get_insights(
            params={'date_preset':AdsInsights.DatePreset.lifetime},
            fields=[AdsInsights.Field.actions,
                    AdsInsights.Field.website_purchase_roas,
                    AdsInsights.Field.mobile_app_purchase_roas,
                    ])

Note that the website_purchase_roas returns a list rather than a number. In addition - if your ad account has no ROAS no list would be returned.