facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
209 stars 160 forks source link

Get Amount spend from campaign #35

Closed Michael3434 closed 4 years ago

Michael3434 commented 6 years ago

Hey, I cannot get from a campagin the amount spend. I tryed many fields ( dayli_spend, spend, amount spend etc.. ) : undefined method `amount_spent' for # Any ideas ?

Thanks :)

euisan commented 6 years ago

You can get amount spent on campaign from insight data like below.

campaign = FacebookAds::Campaign.get(<CAMPAIGN_ID>)
campaign.insights(date_preset: "lifetime", fields: "spend").first
=> #<FacebookAds::AdsInsights {:spend=> <SPEND>, :date_start=> <START_DATE>, :date_stop=> <STOP_DATE>}>
aarhusgregersen commented 5 years ago

I can confirm that this works :-)

stale[bot] commented 4 years ago

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] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.