Posts tagged with facebook-ads

I am using the Facebook Ads connector in AWS AppFlow to transfer Facebook Ads data. While I can successfully transfer all data objects, the data for ads is being accumulated over the entire lifetime of the ads rather than on a daily basis.

For instance, when generating reports using Facebook's Graph API, I retrieve daily data as follows:

https://graph.facebook.com/{ad_id}/insights?fields={field_names}&time_range={'since':'2021-08-19','until':'2021-08-20'} https://graph.facebook.com/{ad_id}/insights?fields={field_names}&time_range={'since':'2021-08-20','until':'2021-08-21'} https://graph.facebook.com/{ad_id}/insights?fields={field_names}&time_range={'since':'2021-08-21','until':'2021-08-22'} 

I would like to achieve the same daily data transfer using AWS AppFlow for the entire duration the ad has been running. How can I configure AWS AppFlow to transfer the ads data on a daily basis instead of the accumulated data over the ad's lifetime? Any guidance or examples would be greatly appreciated.

I have got the following data transferred for the lifetime of ad run between 2021-08-17 and 2024-06-05

{"account_currency":"USD","account_id":"","account_name":"","actions":[{"action_type":"onsite_conversion.post_save","value":"7"},{"action_type":"comment","value":"10"},{"action_type":"link_click","value":"433"},{"action_type":"post","value":"39"},{"action_type":"like","value":"3969"},{"action_type":"post_reaction","value":"2847"},{"action_type":"page_engagement","value":"7305"},{"action_type":"post_engagement","value":"3336"}],"ad_id":"","ad_name":"","adset_id":"","adset_name":"","buying_type":"AUCTION","campaign_id":"","campaign_name":"","clicks":"8000", "date_start":"2021-08-17","date_stop":"2024-06-05" 

What I need is a daily level data transfer for all the days between 2021-08-17 and 2024-06-05 i.e, for all the days the ad has run.

I am running this command on my terminal :

C:\Ad-Library-API-Script-Repository-main\python> py fb_ads_library_api_cli.py -t (token) -f "id,page_id,page_name,ad_creative_bodies,spend,demographic_distribution,bylines,ad_delivery_start_time" -c "CA" -s "climate" --after-date "2024-05-01" save_to_csv file.csv 

And I get the following error :

Traceback (most recent call last): File "C:\Ad-Library-API-Script-Repository-main\python\fb_ads_library_api_cli.py", line 147, in main() File "C:\Ad-Library-API-Script-Repository-main\python\fb_ads_library_api_cli.py", line 134, in main save_to_csv( File "C:\Ad-Library-API-Script-Repository-main\python\fb_ads_library_api_operators.py", line 96, in save_to_csv with open(output_file, "w") as csvfile: ^^^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied. 

Does anyone have a solution ? i'm not sure I understand how the Permission system works in the Graph Api.

I have tried adding "encoding="utf-8" in the fb_ads_library_api_operators file to fix the encoding issue, but it didn't work (i am able to get one dataset then i get the same error all over again)

When I am trying to update the targeting of an AdSet, an error is returned. Session URL : https://developers.facebook.com/tools/explorer/321102689698722/?session_id=1408717453113278

{ "error": { "message": "Invalid parameter", "type": "OAuthException", "code": 100, "error_subcode": 3858082, "is_transient": false, "error_user_title": "Creative Must Provide enroll_status for Standard Enhancements", "error_user_msg": "This creative is eligible for Standard Enhancements, but enroll_status was not provided. Please choose whether you want to turn on standard enhancements or not. Learn more here: https://fburl.com/hyth50xo", "fbtrace_id": "AEIUzfYUlrFTKB8KAgPcVoz" } } 

But the enroll_status for Standard Enhancements is set in as OPT_IN for all the creatives inside the AdSet. Session URL : https://developers.facebook.com/tools/explorer/321102689698722/?session_id=425543010193929

[ { "degrees_of_freedom_spec": { "creative_features_spec": { "standard_enhancements": { "enroll_status": "OPT_IN" } } }, "id": "120208488275990030" } ] 

It's not an advantage+ ad. It's happening for most of the objectives.

I'm using official Facebbok API for getting ads with /ads_archive endpoint.

Example request:

curl -G \ -d "search_terms='oil'" \ -d "ad_reached_countries=['US']" \ -d "fields=id,ad_creation_time,ad_creative_bodies,ad_creative_link_captions,ad_creative_link_descriptions,ad_creative_link_titles,ad_delivery_start_time,ad_delivery_stop_time,ad_snapshot_url,age_country_gender_reach_breakdown,beneficiary_payers,bylines,currency,delivery_by_region,demographic_distribution,estimated_audience_size,eu_total_reach,impressions,languages,page_id,page_name,publisher_platforms,spend,target_ages,target_gender,target_locations" \ -d "access_token={ACCESS_TOKEN}" \ "https://graph.facebook.com/v19.0/ads_archive" 

Response does include Facebook Page ID. It also includes publisher_platforms field containing Instagram or/and Facebook. But no Instagram ID or username.

I find it weird, because web version of Ad Library (running under private API) shows that data. Example link

How can I get Instagram username using Official Ad Library API?

I've already passed all fields from Archived Ad Schema to my request.

Scraping private API seems hard, because it seems sensitive to proxies.

During checking traffic source on e-commerce website i get confused.

I know that param gclid=.. means that user is tagged by GoogleAds, while fbclid works the same way but with facebook.

However, I dont understand what does it mean while they are both together in single url, like: www.example.com?gclid=CjwKCAiAyrXiBRAjEiwATI95mafT26kwak0CFBgICH0ZlLqafSBuyyoUBVZihf22pPdG9QK8DUmiZBoCh8YQAvD_BwE&gclsrc=aw.ds&fbclid=IwAR0oihEZbw0Q43GXiv4YW9n_G9odTEcpxzLtMxjYYqgrTt5EM-BcKqrJyuU

Is it possible that google ads is displaying ads on facebook and that is why gclid and fbclid are attached to url at the same time?