|
| 1 | +--- |
| 2 | +title: 'Creating a DPA Campaign' |
| 3 | +description: 'Creating a DPA Campaign - Step-by-Step' |
| 4 | +--- |
| 5 | + |
| 6 | +The following example assumes you have installed, configured, and authorized your app and user using twurl. twurl is a command-line tool in the spirit of cURL that gracefully handles X OAuth authentication. twurl is a great tool for quickly testing and debugging Ads API (and REST API) functionality. To see the full headers of the request and response, use -t to trace the call, roughly equivalent to cURL’s -v option. |
| 7 | + |
| 8 | +For this example, we will create a Dynamic Product Ads (DPA) campaign. |
| 9 | + |
| 10 | +Retrieve the account id. |
| 11 | + |
| 12 | +```bash |
| 13 | +twurl -H ads-api.x.com /12/accounts/ |
| 14 | +``` |
| 15 | + |
| 16 | +```json |
| 17 | +{ |
| 18 | + "request": { |
| 19 | + "params": {} |
| 20 | + }, |
| 21 | + "data": [ |
| 22 | + { |
| 23 | + "name": "Test account for @AdsAPI", |
| 24 | + "timezone": "America/Los_Angeles", |
| 25 | + "timezone_switch_at": null, |
| 26 | + "id": "xxxxxx", |
| 27 | + "created_at": "2014-03-09T00:41:49Z", |
| 28 | + "salt": "f9f9d5a5f23075c618da5eb1d1a9df57", |
| 29 | + "updated_at": "2015-01-29T00:41:49Z", |
| 30 | + "approval_status": "ACCEPTED", |
| 31 | + "deleted": false |
| 32 | + } |
| 33 | + ], |
| 34 | + "data_type": "account", |
| 35 | + "total_count": 1, |
| 36 | + "next_cursor": null |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +Retrieve the funding instrument id.\ |
| 41 | +Hit the GET accounts/:account_id/funding_instruments API using the account id retrieved in the previous command. |
| 42 | + |
| 43 | +```bash |
| 44 | +twurl -H ads-api.x.com /12/accounts/xxxxxx/funding_instruments |
| 45 | +``` |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "data": [ |
| 50 | + { |
| 51 | + "cancelled": true, |
| 52 | + "created_at": "2014-03-09T00:41:49Z", |
| 53 | + "credit_limit_local_micro": null, |
| 54 | + "currency": "USD", |
| 55 | + "deleted": false, |
| 56 | + "description": null, |
| 57 | + "end_time": null, |
| 58 | + "funded_amount_local_micro": null, |
| 59 | + "id": "yyyy", |
| 60 | + "type": null, |
| 61 | + "updated_at": "2014-05-29T00:41:49Z" |
| 62 | + } |
| 63 | + ], |
| 64 | + "data_type": "funding_instrument", |
| 65 | + "next_cursor": null, |
| 66 | + "request": { |
| 67 | + "params": { |
| 68 | + "account_id": "xxxxxx" |
| 69 | + } |
| 70 | + }, |
| 71 | + "total_count": 1 |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +## Step 1: Create campaign |
| 76 | + |
| 77 | +Create a campaign and associate it with the funding instrument.\ |
| 78 | +Specify a start time and a budget for the campaign. |
| 79 | + |
| 80 | +- Required fields: funding instrument, campaign name, budget (total/daily), start time, and ads account ID |
| 81 | + |
| 82 | +```bash |
| 83 | +twurl -H ads-api.x.com -d "funding_instrument_id={FUNDING_INSTRUMENT_ID}&name={CAMPAIGN_NAME}&total_budget_amount_local_micro={TOTAL_BUDGET}&daily_budget_amount_local_micro={DAILY_BUDGET}&start_time={START_TIME}" /12/accounts/{ADS_ACCOUNT_ID}/campaigns | jq |
| 84 | +``` |
| 85 | + |
| 86 | +## Step 2: Create line item with Sales objective |
| 87 | + |
| 88 | +Create a line item associated with the campaign. |
| 89 | + |
| 90 | +- Required fields: campaign id (from Step 1), product type, placements, objective, goal, entity status, primary web event tag, catalog id, product set id, creative_source, ads_account_id |
| 91 | +- catalog_id and product_set_id can be found in your shopping manager |
| 92 | +- creative_source should always be DYNAMIC_PRODUCT_CREATIVE |
| 93 | +- objective should always be WEBSITE_CLICKS |
| 94 | +- goal should always be WEBSITE_CONVERSIONS |
| 95 | + |
| 96 | +```bash |
| 97 | +twurl -H ads-api.x.com -d "campaign_id={CAMPAIGN_ID}&product_type={product_type}&placements={PLACEMENTS}&objective=WEBSITE_CLICKS&goal=WEBSITE_CONVERSIONS&entity_status={entity_status}&primary_web_event_tag={WEB_EVENT_TAG}&catalog_id={catalog_id}&product_set_id={product_set_id}&creative_source=DYNAMIC_PRODUCT_CREATIVE" /12/accounts/{ADS_ACCOUNT_ID}/line_items | jq |
| 98 | +``` |
| 99 | + |
| 100 | +- After this step, the campaign will be available to see in X's Ads Manager. |
| 101 | + |
| 102 | +## Step 3: Create DPA card |
| 103 | + |
| 104 | +Create a DPA card. |
| 105 | + |
| 106 | +- Required parameters: ads account ID and URL: |
| 107 | +- The URL must start with https://twitter.com - any additional UTM can be appended on afterwards like in the example below: |
| 108 | + - ```https://twitter.com?utm_source=%7B%7Bsite_source%7D%7D``` |
| 109 | +- Optionally, you can choose the format of your card by specifying creative_type with one of the following values: "CAROUSEL", "SINGLE", "COLLECTION". If not specified, your card will be created as a carousel card. |
| 110 | + |
| 111 | +```bash |
| 112 | +twurl -X POST -H ads-api.twitter.com -A "Content-Type: application/json" "/12/accounts/{ADS_ACCOUNT_ID}/dynamic_product_cards" -d '{"url": "{URL}", "creative_type": "{CREATIVE_TYPE}"}' | jq |
| 113 | +``` |
| 114 | + |
| 115 | +## Step 4: Create Post |
| 116 | + |
| 117 | +Create a post. |
| 118 | + |
| 119 | +- Required parameters: ads account ID, user ID, card URI (from Step 3), text, name, & dynamic product ad |
| 120 | +- dynamic_product_ad should always be set to true |
| 121 | + |
| 122 | +```bash |
| 123 | +twurl -X POST -H "https://ads-api.twitter.com" "/12/accounts/{ADS_ACCOUNT_ID}/tweet?as_user_id={USER_ID}1&card_uri=card%3A%2F%2F{CARD_URI}&text={POST_TEXT}&name={POST_NAME}%201&dynamic_product_ad=true" | jq |
| 124 | +``` |
| 125 | + |
| 126 | +## Step 5: Associate post with line item |
| 127 | + |
| 128 | +Associate the post with the line item. |
| 129 | + |
| 130 | +- Required parameters: ads account id, line item id (from Step 2) and tweet id (id_str from Step 4) |
| 131 | + |
| 132 | +```bash |
| 133 | +twurl -X POST -H "https://ads-api.twitter.com" "/12/accounts/{ADS_ACCOUNT_ID}/promoted_tweets?line_item_id={line_item_id}&tweet_ids={tweet_id}" | jq |
| 134 | +``` |
| 135 | + |
| 136 | +If advertisers want to see the card in the UI - it will also be available. |
0 commit comments