facebook / facebook-nodejs-business-sdk

Node.js SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
489 stars 226 forks source link

How to get the total spent amount for a campaign? #281

Open phillipmohr opened 5 months ago

phillipmohr commented 5 months ago

I'm trying to get the total amount that has been spent for a specific campaign. How can I do that?

Which SDK version are you using?

const insightsPromise = new Campaign(campaignId).getInsights([AdsInsights.Fields.ad_name, AdsInsights.Fields.spend]);

What's the issue?

When I access the spend field, it only returns a value if the campaign is still active. If the campaign is inactive, I do not get a value.

My approach:

const adSetsPromise = new Campaign(campaignId).getAdSets([AdSet.Fields.id, AdSet.Fields.daily_budget, AdSet.Fields.lifetime_budget]);

Expected Results:

Get the total amount spent.