Skip to content

Sandbox Ad Account Testing Environment

Tomas Kacur edited this page May 22, 2018 · 3 revisions

Facebook ads application(Facebook app with Marketing api) allows to create an use ad sandbox account through which the whole create ad hierarchy can be created.

Create Sandbox account

  • go to Facebook App -> Marketing Api -> Tools
  • create a sandbox.
  • associate a Facebook Page with it(if you dont have one create a dummy facebook page under your account)

image

Get User Access Token of Sandbox ad account

  • go to Facebook App -> Roles -> Test Users
  • find Sandbox Ad Account in Test Users
  • clink on Edit -> Get Access Token For This Test User

image

You can alternatively set password and log in to the facebook however using facebook ad manager is restricted.

Create an Ad with Sandbox ad account

for details see this: https://developers.facebook.com/docs/marketing-api/buying-api Follow these steps:

0. Get Ad Account Id

GET to https://graph.facebook.com/v3.0/me/adaccounts?access_token=<token> should return object with id like act_1234567890

1. Create Campaign

POST to

https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/campaigns?access_token=<token>
&name=L3 With Lifetime Budget&objective=LINK_CLICKS&status=PAUSED

2. Create AdSet

POST to

https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/adsets?access_token=<token>

body form-data params:

name:my ad set fb target
billing_event:IMPRESSIONS
bid_amount:100
daily_budget:1000
campaign_id: CAMPAIGN_ID
targeting:{"geo_locations":{"countries":["US"]},"publisher_platforms":["facebook"]}
start_time:2018-05-20T04:45:17+0000
end_time:2018-05-28T04:45:17+0000
optimization_goal:REACH

3. Upload some picture

curl \
  -F 'filename=@path_to_some_picture' \
  -F 'access_token=<token>' \
  https://graph.facebook.com/v2.11/<AD_ACCOUNT_ID>/adimages

retrieve url and hash to the picture via call to GET https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/adimages?access_token=<token>&fields=url,hash

4. Create Ad Creative

POST to https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/adcreatives?access_token=<token> body form-data

name:blabla creative
object_story_spec:{ "link_data": { "image_hash": "<IMAGE_HASH>", "link": "<IMAGE_URL>", "message": "try it out"     },    "page_id": "<ASSOCIATED_FACEBOOK_PAGE_ID>"}

5. Create an Ad

POST to

https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/ads?access_token=<TOKEN>
&name=my ad 4&status=ACTIVE&creative={"creative_id":"<AD_CREATIVE_ID>"}&adset_id=<ADSET_ID>

repeat this to fill ad accounts with more data..