Dev Suggestions for Keywords

ads
targeting
reach-estimation
api

#1

@juanshishido - since you are very active, I’m going to tag you in this.

I have some feedback from developers in regards to the recent reach_estimate keyword support feature you released:

As shown below, the standard is to send empty space character encoding “%20” - but this does not work - it interprets the '%20" as part of a keyword, see twurl below:

twurl -H 'ads-api.twitter.com' '/1/accounts/18ce53yrq2p/reach_estimate?product_type=PROMOTED_TWEETS&bid_amount_local_micro=150000&currency=USD&campaign_daily_budget_amount_local_micro=550000&objective=TWEET_ENGAGEMENTS&phrase_keywords=game%20of%20thrones' | python -m json.tool

{
    "errors": [
        {
            "code": "NOT_FOUND",
            "message": "Keyword(s) game%20of%20thrones was not found"
        }
    ],
    "request": {
        "params": {}
    }
}

When attempting to format x-www-form-urlencoded type requests with “+” encoding as blank space does not output desired phrase. It also believes “game+of+thrones” is a giant keyword that would be present in a tweet. See twurl below:

twurl -H 'ads-api.twitter.com' '/1/accounts/18ce53yrq2p/reach_estimate?product_type=PROMOTED_TWEETS&bid_amount_local_micro=150000&currency=USD&campaign_daily_budget_amount_local_micro=550000&objective=TWEET_ENGAGEMENTS&phrase_keywords=game+of+thrones' | python -m json.tool
{
    "data": {
        "count": null,
        "engagements": null,
        "estimated_daily_spend_local_micro": null,
        "impressions": null,
        "infinite_bid_count": {
            "max": 0,
            "min": 0
        }
    },
    "data_type": "reach_estimate",
    "request": {
        "params": {
            "account_id": "18ce53yrq2p",
            "bid_amount_local_micro": 150000,
            "campaign_daily_budget_amount_local_micro": 550000,
            "currency": "USD",
            "followers_of_users": null,
            "objective": "TWEET_ENGAGEMENTS",
            "phrase_keywords": [
                "game+of+thrones"
            ],
            "product_type": "PROMOTED_TWEETS"
        }
    }
}

An empty space character is considered an “unsafe” character per IETF RFC1738. However, empty spaces are currently the only way that the API endpoint receives phrases with spaces.

twurl -H 'ads-api.twitter.com' '/1/accounts/18ce53yrq2p/reach_estimate?product_type=PROMOTED_TWEETS&bid_amount_local_micro=150000&currency=USD&campaign_daily_budget_amount_local_micro=550000&objective=TWEET_ENGAGEMENTS&phrase_keywords=game of thrones' | python -m json.tool
{
    "data": {
        "count": {
            "max": 313,
            "min": 209
        },
        "engagements": {
            "max": 11,
            "min": 7
        },
        "estimated_daily_spend_local_micro": {
            "max": 660000,
            "min": 440000
        },
        "impressions": {
            "max": 395,
            "min": 263
        },
        "infinite_bid_count": {
            "max": 979237,
            "min": 652824
        }
    },
    "data_type": "reach_estimate",
    "request": {
        "params": {
            "account_id": "18ce53yrq2p",
            "bid_amount_local_micro": 150000,
            "campaign_daily_budget_amount_local_micro": 550000,
            "currency": "USD",
            "followers_of_users": null,
            "objective": "TWEET_ENGAGEMENTS",
            "phrase_keywords": [
                "game of thrones"
            ],
            "product_type": "PROMOTED_TWEETS"
        }
    }
}

Can we add support to having ‘%20’ characters as part of the keyword phrase to go along with the standard? Let me know if you have any questions.


#2

Hey @msbukkuri,

This is actually a feature of twurl and not a behavior of the Ads API endpoint. Twurl will automatically URL-encode any of the strings you pass to it before they are passed to the API, unless you use the --raw-data option, which is only for writes. You’ll see that when you pass these as spaces using twurl and enable --trace the URI passed to the Twitter API is safely encoded:

twurl -H ads-api.twitter.com "/1/accounts/18ce53yrq2p/reach_estimate?product_type=PROMOTED_TWEETS&bid_amount_local_micro=150000&currency=USD&campaign_daily_budget_amount_local_micro=550000&objective=TWEET_ENGAGEMENTS&phrase_keywords=game of thrones" --trace |jsonpretty
opening connection to ads-api.twitter.com:443...
opened
starting SSL for ads-api.twitter.com:443...
SSL established
<- "GET /1/accounts/18ce53yrq2p/reach_estimate?product_type=PROMOTED_TWEETS&bid_amount_local_micro=150000&currency=USD&campaign_daily_budget_amount_local_micro=550000&objective=TWEET_ENGAGEMENTS&phrase_keywords=game+of+thrones HTTP/1.1
...
{
  "data_type": "reach_estimate",
  "data": {
    "impressions": {
      "min": 263,
      "max": 395
    },
    "count": {
      "min": 209,
      "max": 313
    },
    "infinite_bid_count": {
      "min": 661022,
      "max": 991533
    },
    "engagements": {
      "min": 7,
      "max": 11
    },
    "estimated_daily_spend_local_micro": {
      "min": 440000,
      "max": 660000
    }
  },
  "request": {
    "params": {
      "bid_amount_local_micro": 150000,
      "product_type": "PROMOTED_TWEETS",
      "objective": "TWEET_ENGAGEMENTS",
      "account_id": "18ce53yrq2p",
      "currency": "USD",
      "followers_of_users": null,
      "phrase_keywords": [
        "game of thrones"
      ],
      "campaign_daily_budget_amount_local_micro": 550000
    }
  }
}

#3

Thanks for the note and the response! Appreciate the clarification.