Gettting the campign objective in the API


#1

Hi Guys

I am trying to call the campaign objectives from the API when we try pull stats from the API call. We are unable to locate where this information is and was hoping someone can help us locate this.

Thanks


#2

Hi @the7starsMusic! The objective is at the line item level: https://dev.twitter.com/ads/reference/post/accounts/%3Aaccount_id/line_items. But all line items within a campaign must have the same objective, so it’s enough to get the objective of just one line item within that campaign, in case the campaign has more line items.


#3

Hi Majoritasdev

Thanks for the helpful info, this has helped and we have now found the information we need


#4

I’m glad to hear that, @the7starsMusic. :slight_smile: Good luck!


#5

Thanks @majoritasdev for your suggestions.
Can you @majoritasdev or anybody help me out to get this Twitter Campaign Objective API URL: https://dev.twitter.com/ads/reference/post/accounts/%3Aaccount_id/line_items implemented with twitter Ads API while I am trying to get campaign list for a user account?


#6

Hi, @the7starsMusic. Could you please clarify what you’re trying to do? Are you trying to create line items for existing campaigns?


#7

Hey Juan

We have built a tool that pulls metrics from the ads API that we use with you. When I tried to get the API approved I was told we had to show we were using the correct campaign objective.

What we are trying to do is find a way in the admin panel, make the campaign objective used visible so that when I come to try get the API lifted it won’t fail again.

If easier I would do a screen share with you to show you what we have done. All I am after is allowing API calls to come through without any major limits.


#8

Thanks for your comment, @mcrwebdesign.

When calling the GET /1/stats/accounts/:account_id endpoint, you do not need to specify the campaign objective. Below is an example request using twurl.

$ twurl -H ads-api.twitter.com "/1/stats/accounts/xxxxx?entity=CAMPAIGN&entity_ids=1abc2&start_time=2016-09-01&end_time=2016-09-02&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER" | jq
{
  "data_type": "stats",
  "time_series_length": 1,
  "data": [
    {
      "id": "1abc2",
      "id_data": [
        {
          "segment": null,
          "metrics": {
            "impressions": [
              140
            ],
            "tweets_send": null,
            "qualified_impressions": null,
            "follows": [
              3
            ],
            "app_clicks": null,
            "retweets": null,
            "likes": [
              21
            ],
            "engagements": [
              2006
            ],
            "clicks": [
              140
            ],
            "card_engagements": null,
            "replies": null,
            "url_clicks": [
              99
            ],
            "carousel_swipes": null
          }
        }
      ]
    }
  ],
  "request": {
    "params": {
      "start_time": "2016-09-01T00:00:00Z",
      "segmentation_type": null,
      "entity_ids": [
        "1abc2"
      ],
      "end_time": "2016-09-02T00:00:00Z",
      "country": null,
      "placement": "ALL_ON_TWITTER",
      "granularity": "DAY",
      "entity": "CAMPAIGN",
      "platform": null,
      "metric_groups": [
        "ENGAGEMENT"
      ]
    }
  }
}

If you need to access the objective, you do this at the line item-level. For a specific campaign:

$ twurl -H ads-api.twitter.com "/1/accounts/xxxxx/line_items?campaign_ids=9z87y" | jq
{
  "request": {
    "params": {
      "account_id": "xxxxx",
      "campaign_ids": [
        "9z87y"
      ]
    }
  },
  "data": [
    {
      "bid_type": "MAX",
      "advertiser_user_id": 123456789987654321,
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "start_time": null,
      "bid_amount_local_micro": 5000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "end_time": null,
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "TWEET_ENGAGEMENTS",
      "id": "5hijk",
      "paused": false,
      "account_id": "xxxxx",
      "optimization": "DEFAULT",
      "categories": [],
      "currency": "USD",
      "created_at": "2016-07-15T00:00:00Z",
      "tracking_tags": [],
      "updated_at": "2016-07-15T00:00:00Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "9z87y",
      "creative_source": "MANUAL",
      "deleted": false
    }
  ],
  "data_type": "line_item",
  "total_count": 1,
  "next_cursor": null
}

Here, you can see that this campaign has a TWEET_ENGAGEMENTS objective. Every line item under a campaign must share the same objective type, @majoritasdev mentioned earlier.


#9

Thanks Juan

We have already managed to get this, but we are unsure on how you wish for us to display this in our graphs as no one sees the admin panel.

It is hard to explain here without screen sharing so you can see what we are trying to achieve

Thanks

Warren (AKA mcrwebdesign)


#10

@the7starsMusic: Is this what you’re looking for?

This is an example from ads.twitter.com, which shows that this is a Tweet engagements campaign.

Your best bet will be to speak with the individuals who suggested you show the campaign objective for guidance on what they expect.