Google AdWords API – Part 3

The third article is about how to get adtexts, placements and keywords from Google AdWords API.


You can get adtexts from the AdGroupAdService. The difference to campaigns and adgroups is, that we can get now actual data that is used by AdWords. This data is displayed at the Google AdWords user interface from Google:

  • Klicks
  • Impressionen
  • CPC (Cost per Click)
  • Conversions
  • CTR (Click trough rate)
  • Position

The whole list can be found here.

You can get the values the following way:

At the selector I also use a dateRange. So for this example, I only get daily values (I only want data from one day). For this you can also define date ranges like a week or so. If you do, you will get summed values.

An adtext is defined by:

  • Headline
    A headline for the text ad.

  • Description1
    The first row of text.
  • Description2
    The second row of text.
  • DisplayUrl
    The URL which is displayed to the user.
  • Url
    A URL which is used. Can be different than the URL that is displayed.


You can get keywords and playemenct with the same Service (AdGroupCriterionService). It is very similar to the adtext code:

For placements you can additionally get name and url of it.

Thats all. You can get all data from Google. I use this method to get daily values and store it into database. There I can compute weekly and monthly values. If you want to see campaign or adgroup values, you have to sum up keywords and placements or adtexts.

Part 1 | Part 2 | Part 4 | Part 5 | Part 6

(Visited 2,785 times, 1 visits today)

11 Responses

  1. Thank you for this example, unfortunately i’ve tested and adwords return me :

    an error has occurred: [SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’AverageCpc’, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’AveragePosition’, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Clicks’, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Conversions’, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Cost’, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Ctr’, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Impressions’]

    I don’t know why, and you ?

    • Hello!
      INVALID_FIELD_NAME occurs if the given field does not exist in the current used Adwords API version. You can find a list of all possible fields for each service under this link: Google Adwords API. It depends on which API version you are using. In the current version, AverageCpc is not a valid field for AdGroupAdService, so please fill in correct field names at $selector->fields = array()! Hope this helps 😉

  2. José says:

    Hi, what is $adGroupId? And, where I get it?

    • This article shows you for example how the get TextAds with “function GetTextAds”. On of its params is adGroupId. You can get an adGroupId the same way as TextAds. For this you need campaignId which you can also get the same way. In Part 2 of my article series I describe this steps in detail!

  3. Kurian says:

    I was trying to use this code. But looks likes the api has changed. Can you please tell me how can i get the data available in “GetKeywords”. I am looking for ‘Clicks’, ‘Conversions’, ‘Cost’, ‘Ctr’, ‘Impressions’ for the keywords

    Will you be able to help

    • The API is highly dynamic and Google changes things every 6 months or so…my last status was, that you have to use reports. This is the last working source I have

      hope this helps!

  4. Vikrant says:

    i have a client library in of v201502 and i want to fecth all the clicks,item-id,impressions,cost,conversion of all the campaigns within a given date range from the google adword api.please help me its too urgent.if anyone has any example its better.thanks in advance

    • KEYWORDS_PERFORMANCE_REPORT? See my comment above

      • Vikrant says:

        Thanks for the help Werner but now client want to fetch all this using google analytics api.Actually i already fetch data from this but i am not able to fetch a single campaign data from analytics api like(Shopping item id,clicks,cost,conversion etc.). if you know about this please help me.

Leave a Reply

Your email address will not be published. Required fields are marked *