Optimization Samples

The code samples below provide examples of common optimization functions using the AdWords API. Client Library.

Estimate keyword traffic

' Copyright 2017, Google Inc. All Rights Reserved.
'
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
'     http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.

Imports Google.Api.Ads.AdWords.Lib
Imports Google.Api.Ads.AdWords.v201710

Namespace Google.Api.Ads.AdWords.Examples.VB.v201710

  ''' <summary>
  ''' This code example gets keyword traffic estimates.
  ''' </summary>
  Public Class EstimateKeywordTraffic
    Inherits ExampleBase

    ''' <summary>
    ''' Main method, to run this code example as a standalone application.
    ''' </summary>
    ''' <param name="args">The command line arguments.</param>
    Public Shared Sub Main(ByVal args As String())
      Dim codeExample As New EstimateKeywordTraffic
      Console.WriteLine(codeExample.Description)
      Try
        codeExample.Run(New AdWordsUser)
      Catch e As Exception
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e))
      End Try
    End Sub

    ''' <summary>
    ''' Returns a description about the code example.
    ''' </summary>
    Public Overrides ReadOnly Property Description() As String
      Get
        Return "This code example gets keyword traffic estimates."
      End Get
    End Property

    ''' <summary>
    ''' Runs the code example.
    ''' </summary>
    ''' <param name="user">The AdWords user.</param>
    Public Sub Run(ByVal user As AdWordsUser)
      Using trafficEstimatorService As TrafficEstimatorService = CType(user.GetService(
          AdWordsService.v201710.TrafficEstimatorService), TrafficEstimatorService)

        ' Create keywords. Up to 2000 keywords can be passed in a single request.
        Dim keyword1 As New Keyword
        keyword1.text = "mars cruise"
        keyword1.matchType = KeywordMatchType.BROAD

        Dim keyword2 As New Keyword
        keyword2.text = "cheap cruise"
        keyword2.matchType = KeywordMatchType.PHRASE

        Dim keyword3 As New Keyword
        keyword3.text = "cruise"
        keyword3.matchType = KeywordMatchType.EXACT

        Dim keywords As Keyword() = New Keyword() {keyword1, keyword2, keyword3}

        ' Create a keyword estimate request for each keyword.
        Dim keywordEstimateRequests As New List(Of KeywordEstimateRequest)

        For Each keyword As Keyword In keywords
          Dim keywordEstimateRequest As New KeywordEstimateRequest
          keywordEstimateRequest.keyword = keyword
          keywordEstimateRequests.Add(keywordEstimateRequest)
        Next

        ' Create negative keywords.
        Dim negativeKeyword1 As New Keyword
        negativeKeyword1.text = "moon walk"
        negativeKeyword1.matchType = KeywordMatchType.BROAD

        Dim negativeKeywordEstimateRequest As New KeywordEstimateRequest
        negativeKeywordEstimateRequest.keyword = negativeKeyword1
        negativeKeywordEstimateRequest.isNegative = True
        keywordEstimateRequests.Add(negativeKeywordEstimateRequest)

        ' Create ad group estimate requests.
        Dim adGroupEstimateRequest As New AdGroupEstimateRequest
        adGroupEstimateRequest.keywordEstimateRequests = keywordEstimateRequests.ToArray
        adGroupEstimateRequest.maxCpc = New Money
        adGroupEstimateRequest.maxCpc.microAmount = 1000000

        ' Create campaign estimate requests.
        Dim campaignEstimateRequest As New CampaignEstimateRequest
        campaignEstimateRequest.adGroupEstimateRequests = New AdGroupEstimateRequest() _
            {adGroupEstimateRequest}

        ' See http://code.google.com/apis/adwords/docs/appendix/countrycodes.html
        ' for a detailed list of country codes.
        Dim countryCriterion As New Location
        countryCriterion.id = 2840 'US

        ' See http://code.google.com/apis/adwords/docs/appendix/languagecodes.html
        ' for a detailed list of language codes.
        Dim languageCriterion As New Language
        languageCriterion.id = 1000 'en

        campaignEstimateRequest.criteria = New Criterion() {countryCriterion, languageCriterion}

        Try
          ' Create the selector.
          Dim selector As New TrafficEstimatorSelector
          selector.campaignEstimateRequests =
              New CampaignEstimateRequest() {campaignEstimateRequest}

          ' Optional: Request a list of campaign level estimates segmented by platform.
          selector.platformEstimateRequested = True

          ' Get traffic estimates.
          Dim result As TrafficEstimatorResult = trafficEstimatorService.get(selector)

          ' Display the results.
          If ((Not result Is Nothing) AndAlso (Not result.campaignEstimates Is Nothing) _
              AndAlso (result.campaignEstimates.Length > 0)) Then
            Dim campaignEstimate As CampaignEstimate = result.campaignEstimates(0)

            ' Display the campaign level estimates segmented by platform.
            If Not campaignEstimate.platformEstimates Is Nothing Then
              For Each platformEstimate As PlatformCampaignEstimate In
                  campaignEstimate.platformEstimates
                Dim platformMessage As String = String.Format("Results for the platform with ID:" &
                    " {0} and name : {1}.", platformEstimate.platform.id,
                    platformEstimate.platform.platformName)

                DisplayMeanEstimates(platformMessage, platformEstimate.minEstimate,
                    platformEstimate.maxEstimate)
              Next
            End If

            If ((Not campaignEstimate.adGroupEstimates Is Nothing) AndAlso
                (campaignEstimate.adGroupEstimates.Length > 0)) Then
              Dim adGroupEstimate As AdGroupEstimate = campaignEstimate.adGroupEstimates(0)

              If (Not adGroupEstimate.keywordEstimates Is Nothing) Then
                For i As Integer = 0 To adGroupEstimate.keywordEstimates.Length - 1
                  Dim keyword As Keyword = keywordEstimateRequests.Item(i).keyword
                  Dim keywordEstimate As KeywordEstimate = adGroupEstimate.keywordEstimates(i)

                  If keywordEstimateRequests.Item(i).isNegative Then
                    Continue For
                  End If

                  Dim kwdMessage As String = String.Format("Results for the keyword with" &
                      " text = '{0}' and match type = '{1}':", keyword.text, keyword.matchType)
                  DisplayMeanEstimates(kwdMessage, keywordEstimate.min, keywordEstimate.max)
                Next i
              End If
            End If
          Else
            Console.WriteLine("No traffic estimates were returned.")
          End If
        Catch e As Exception
          Throw New System.ApplicationException("Failed to retrieve traffic estimates.", e)
        End Try
      End Using
    End Sub

    ''' <summary>
    ''' Displays the mean estimates.
    ''' </summary>
    ''' <param name="message">The message to display.</param>
    ''' <param name="minEstimate">The minimum stats estimate.</param>
    ''' <param name="maxEstimate">The maximum stats estimate.</param>
    Private Sub DisplayMeanEstimates(ByVal message As String, ByVal minEstimate As StatsEstimate,
        ByVal maxEstimate As StatsEstimate)
      ' Find the mean of the min and max values.
      Dim meanAverageCpc As Long = 0L
      Dim meanAveragePosition As Double = 0
      Dim meanClicks As Single = 0
      Dim meanTotalCost As Single = 0

      If (Not (minEstimate Is Nothing) AndAlso Not (maxEstimate Is Nothing)) Then
        If (Not (minEstimate.averageCpc Is Nothing) AndAlso
            Not (maxEstimate.averageCpc Is Nothing)) Then
          meanAverageCpc = CLng((minEstimate.averageCpc.microAmount +
              maxEstimate.averageCpc.microAmount) / 2)
        End If

        If minEstimate.averagePositionSpecified AndAlso maxEstimate.averagePositionSpecified Then
          meanAveragePosition = (minEstimate.averagePosition + maxEstimate.averagePosition) / 2
        End If

        If minEstimate.clicksPerDaySpecified AndAlso maxEstimate.clicksPerDaySpecified Then
          meanClicks = (minEstimate.clicksPerDay + maxEstimate.clicksPerDay) / 2
        End If
        If (Not (minEstimate.totalCost Is Nothing) AndAlso
            Not (maxEstimate.totalCost Is Nothing)) Then
          meanTotalCost = CLng((minEstimate.totalCost.microAmount +
              maxEstimate.totalCost.microAmount) / 2)
        End If
      End If

      Console.WriteLine(message)
      Console.WriteLine("  Estimated average CPC: {0}", meanAverageCpc)
      Console.WriteLine("  Estimated ad position: {0:0.00}", meanAveragePosition)
      Console.WriteLine("  Estimated daily clicks: {0}", meanClicks)
      Console.WriteLine("  Estimated daily cost: {0}", meanTotalCost)
    End Sub

  End Class

End Namespace

Get ad group bid simulations

' Copyright 2017, Google Inc. All Rights Reserved.
'
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
'     http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.

Imports Google.Api.Ads.AdWords.Lib
Imports Google.Api.Ads.AdWords.v201710

Namespace Google.Api.Ads.AdWords.Examples.VB.v201710

  ''' <summary>
  ''' This code example gets bid landscapes for an ad group. To get ad groups,
  ''' run GetAdGroups.vb.
  ''' </summary>
  Public Class GetAdGroupBidSimulations
    Inherits ExampleBase

    ''' <summary>
    ''' Main method, to run this code example as a standalone application.
    ''' </summary>
    ''' <param name="args">The command line arguments.</param>
    Public Shared Sub Main(ByVal args As String())
      Dim codeExample As New GetAdGroupBidSimulations
      Console.WriteLine(codeExample.Description)
      Try
        Dim adGroupId As Long = Long.Parse("INSERT_ADGROUP_ID_HERE")
        codeExample.Run(New AdWordsUser, adGroupId)
      Catch e As Exception
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e))
      End Try
    End Sub

    ''' <summary>
    ''' Returns a description about the code example.
    ''' </summary>
    Public Overrides ReadOnly Property Description() As String
      Get
        Return "This code example gets bid landscapes for an ad group. To get ad groups, run " &
            "GetAdGroups.vb"
      End Get
    End Property

    ''' <summary>
    ''' Runs the code example.
    ''' </summary>
    ''' <param name="user">The AdWords user.</param>
    ''' <param name="adGroupId">Id of the ad group for which bid simulations are
    ''' retrieved.</param>
    Public Sub Run(ByVal user As AdWordsUser, ByVal adGroupId As Long)
      Using dataService As DataService = CType(user.GetService(
          AdWordsService.v201710.DataService), DataService)

        ' Create the selector.
        Dim selector As New Selector
        selector.fields = New String() {
          AdGroupBidLandscape.Fields.AdGroupId, AdGroupBidLandscape.Fields.LandscapeType,
          AdGroupBidLandscape.Fields.LandscapeCurrent, AdGroupBidLandscape.Fields.StartDate,
          AdGroupBidLandscape.Fields.EndDate, BidLandscapeLandscapePoint.Fields.Bid,
          BidLandscapeLandscapePoint.Fields.LocalClicks,
          BidLandscapeLandscapePoint.Fields.LocalCost,
          BidLandscapeLandscapePoint.Fields.LocalImpressions
        }

        ' Set the filters.
        Dim adGroupPredicate As New Predicate
        adGroupPredicate.field = "AdGroupId"
        adGroupPredicate.operator = PredicateOperator.IN
        adGroupPredicate.values = New String() {adGroupId.ToString}

        selector.predicates = New Predicate() {
          Predicate.Equals(AdGroupBidLandscape.Fields.AdGroupId, adGroupId)
        }

        Try
          ' Get bid landscape for ad group.
          Dim page As AdGroupBidLandscapePage = dataService.getAdGroupBidLandscape(selector)
          If (((Not page Is Nothing) AndAlso (Not page.entries Is Nothing)) AndAlso
              (page.entries.Length > 0)) Then
            For Each bidLandscape As AdGroupBidLandscape In page.entries
              Console.WriteLine("Found ad group bid landscape with ad group id '{0}', " &
                  "type '{1}', current: '{2}', start date '{3}', end date '{4}', and " &
                  "landscape points", bidLandscape.adGroupId, bidLandscape.type,
                  bidLandscape.landscapeCurrent, bidLandscape.startDate, bidLandscape.endDate)
              Dim point As BidLandscapeLandscapePoint
              For Each point In bidLandscape.landscapePoints
                Console.WriteLine("- bid: {0} => clicks: {1}, cost: {2}, impressions: {3}",
                    point.bid.microAmount, point.bid.microAmount,
                    point.clicks, point.cost.microAmount, point.impressions)
              Next
            Next
          Else
            Console.WriteLine("No ad group bid landscapes were found.\n")
          End If
        Catch e As Exception
          Throw New System.ApplicationException("Failed to get ad group bid landscapes.", e)
        End Try
      End Using
    End Sub

  End Class

End Namespace

Get keyword bid simulations

' Copyright 2017, Google Inc. All Rights Reserved.
'
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
'     http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.

Imports Google.Api.Ads.AdWords.Lib
Imports Google.Api.Ads.AdWords.v201710

Namespace Google.Api.Ads.AdWords.Examples.VB.v201710

  ''' <summary>
  ''' This code example gets a bid landscape for an ad group and a keyword.
  ''' To get ad groups, run GetAdGroups.vb. To get keywords, run
  ''' GetKeywords.vb.
  ''' </summary>
  Public Class GetKeywordBidSimulations
    Inherits ExampleBase

    ''' <summary>
    ''' Main method, to run this code example as a standalone application.
    ''' </summary>
    ''' <param name="args">The command line arguments.</param>
    Public Shared Sub Main(ByVal args As String())
      Dim codeExample As New GetKeywordBidSimulations
      Console.WriteLine(codeExample.Description)
      Try
        Dim adGroupId As Long = Long.Parse("INSERT_ADGROUP_ID_HERE")
        Dim keywordId As Long = Long.Parse("INSERT_KEYWORD_ID_HERE")
        codeExample.Run(New AdWordsUser, adGroupId, keywordId)
      Catch e As Exception
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e))
      End Try
    End Sub

    ''' <summary>
    ''' Returns a description about the code example.
    ''' </summary>
    Public Overrides ReadOnly Property Description() As String
      Get
        Return "This code example gets a bid landscape for an ad group and a keyword. To " &
            "get ad groups, run GetAdGroups.vb. To get keywords, run GetKeywords.vb."
      End Get
    End Property

    ''' <summary>
    ''' Runs the code example.
    ''' </summary>
    ''' <param name="user">The AdWords user.</param>
    ''' <param name="adGroupId">Id of the ad group for which keyword bid
    ''' simulations are retrieved.</param>
    ''' <param name="keywordId">Id of the keyword for which bid simulations are
    ''' retrieved.</param>
    Public Sub Run(ByVal user As AdWordsUser, ByVal adGroupId As Long, ByVal keywordId As Long)
      Using dataService As DataService = CType(user.GetService(
          AdWordsService.v201710.DataService), DataService)

        ' Create the selector.
        Dim selector As New Selector
        selector.fields = New String() {
          CriterionBidLandscape.Fields.AdGroupId, CriterionBidLandscape.Fields.CriterionId,
          CriterionBidLandscape.Fields.StartDate, CriterionBidLandscape.Fields.EndDate,
          BidLandscapeLandscapePoint.Fields.Bid, BidLandscapeLandscapePoint.Fields.LocalClicks,
          BidLandscapeLandscapePoint.Fields.LocalCost,
          BidLandscapeLandscapePoint.Fields.LocalImpressions
        }

        selector.predicates = New Predicate() {
          Predicate.Equals(CriterionBidLandscape.Fields.AdGroupId, adGroupId),
          Predicate.Equals(CriterionBidLandscape.Fields.CriterionId, keywordId)
        }

        ' Select selector paging.
        selector.paging = Paging.Default

        Dim page As New CriterionBidLandscapePage

        Dim landscapePointsFound As Integer = 0
        Dim landscapePointsInLastResponse As Integer = 0

        Try
          Do
            ' Get bid landscape for keywords.
            page = dataService.getCriterionBidLandscape(selector)
            landscapePointsInLastResponse = 0

            ' Display bid landscapes.
            If ((Not page Is Nothing) AndAlso (Not page.entries Is Nothing)) Then
              Dim i As Integer = selector.paging.startIndex

              For Each bidLandscape As CriterionBidLandscape In page.entries
                Console.WriteLine("Found keyword bid landscape with ad group id ""{0}"", " &
                    "keyword id ""{1}"", start date ""{2}"", end date ""{3}"", and " &
                    "landscape points:", bidLandscape.adGroupId,
                    bidLandscape.criterionId, bidLandscape.startDate, bidLandscape.endDate)
                For Each bidLandscapePoint As BidLandscapeLandscapePoint _
                    In bidLandscape.landscapePoints
                  Console.WriteLine("- bid: {0} => clicks: {1}, cost: {2}, impressions: {3}",
                      bidLandscapePoint.bid.microAmount, bidLandscapePoint.clicks,
                      bidLandscapePoint.cost.microAmount, bidLandscapePoint.impressions)
                  landscapePointsInLastResponse += 1
                  landscapePointsFound += 1
                Next
              Next
            End If

            ' Offset by the number of landscape points, NOT the number
            ' of entries (bid landscapes) in the last response.
            selector.paging.IncreaseOffsetBy(landscapePointsInLastResponse)
          Loop While (landscapePointsInLastResponse > 0)
          Console.WriteLine("Number of keyword bid landscape points found: {0}",
              landscapePointsFound)
        Catch e As Exception
          Throw New System.ApplicationException("Failed to retrieve keyword bid landscapes.", e)
        End Try
      End Using
    End Sub

  End Class

End Namespace

Get keyword ideas

' Copyright 2017, Google Inc. All Rights Reserved.
'
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
'     http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.

Imports Google.Api.Ads.AdWords.Lib
Imports Google.Api.Ads.AdWords.v201710

Namespace Google.Api.Ads.AdWords.Examples.VB.v201710

  ''' <summary>
  ''' This code example retrieves keywords that are related to a given keyword.
  ''' </summary>
  Public Class GetKeywordIdeas
    Inherits ExampleBase

    ''' <summary>
    ''' Main method, to run this code example as a standalone application.
    ''' </summary>
    ''' <param name="args">The command line arguments.</param>
    Public Shared Sub Main(ByVal args As String())
      Dim codeExample As New GetKeywordIdeas
      Console.WriteLine(codeExample.Description)
      Try
        Dim adGroupId As Long = Long.Parse("INSERT_ADGROUP_ID_HERE")
        codeExample.Run(New AdWordsUser, adGroupId)
      Catch e As Exception
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e))
      End Try
    End Sub

    ''' <summary>
    ''' Returns a description about the code example.
    ''' </summary>
    Public Overrides ReadOnly Property Description() As String
      Get
        Return "This code example retrieves keywords that are related to a given keyword."
      End Get
    End Property

    ''' <summary>
    ''' Runs the code example.
    ''' </summary>
    ''' <param name="user">The AdWords user.</param>
    ''' <param name="adGroupId">ID of the ad group to use for generating ideas.</param>
    Public Sub Run(ByVal user As AdWordsUser, ByVal adGroupId As Long?)
      Using targetingIdeaService As TargetingIdeaService = CType(user.GetService(
          AdWordsService.v201710.TargetingIdeaService), TargetingIdeaService)

        ' Create selector.
        Dim selector As New TargetingIdeaSelector()
        selector.requestType = RequestType.IDEAS
        selector.ideaType = IdeaType.KEYWORD
        selector.requestedAttributeTypes = New AttributeType() {
          AttributeType.KEYWORD_TEXT,
          AttributeType.SEARCH_VOLUME,
          AttributeType.CATEGORY_PRODUCTS_AND_SERVICES
        }

        Dim searchParameters As New List(Of SearchParameter)

        ' Create related to query search parameter.
        Dim relatedToQuerySearchParameter As New RelatedToQuerySearchParameter()
        relatedToQuerySearchParameter.queries = New String() {
          "bakery", "pastries", "birthday cake"
        }
        searchParameters.Add(relatedToQuerySearchParameter)

        ' Add a language search parameter (optional).
        ' The ID can be found in the documentation:
        '   https://developers.google.com/adwords/api/docs/appendix/languagecodes
        Dim languageParameter As New LanguageSearchParameter()
        Dim english As New Language()
        english.id = 1000
        languageParameter.languages = New Language() {english}
        searchParameters.Add(languageParameter)

        ' Add network search parameter (optional).
        Dim networkSetting As New NetworkSetting()
        networkSetting.targetGoogleSearch = True
        networkSetting.targetSearchNetwork = False
        networkSetting.targetContentNetwork = False
        networkSetting.targetPartnerSearchNetwork = False

        Dim networkSearchParameter As New NetworkSearchParameter()
        networkSearchParameter.networkSetting = networkSetting
        searchParameters.Add(networkSearchParameter)

        ' Optional: Use an existing ad group to generate ideas.
        If adGroupId.HasValue() Then
          Dim SeedAdGroupIdSearchParameter As New SeedAdGroupIdSearchParameter()
          SeedAdGroupIdSearchParameter.adGroupId = adGroupId.Value
          searchParameters.Add(SeedAdGroupIdSearchParameter)
        End If

        ' Set the search parameters.
        selector.searchParameters = searchParameters.ToArray()


        ' Set selector paging (required for targeting idea service).
        Dim paging As Paging = Paging.Default

        Dim page As New TargetingIdeaPage()

        Try
          Dim i As Integer = 0
          Do
            ' Get related keywords.
            page = targetingIdeaService.get(selector)

            'Display the results.
            If Not page.entries Is Nothing AndAlso page.entries.Length > 0 Then
              For Each targetingIdea As TargetingIdea In page.entries
                For Each entry As Type_AttributeMapEntry In targetingIdea.data
                  ' Preferred: Use targetingIdea.data.ToDict() if you are not on Mono.
                  Dim ideas As Dictionary(Of AttributeType, AdWords.v201710.Attribute) =
                      MapEntryExtensions.ToDict(Of AttributeType, AdWords.v201710.Attribute)(
                          targetingIdea.data)

                  Dim keyword As String =
                    DirectCast(ideas(AttributeType.KEYWORD_TEXT), StringAttribute).value
                  Dim categorySet As IntegerSetAttribute =
                  DirectCast(ideas(AttributeType.CATEGORY_PRODUCTS_AND_SERVICES),
                      IntegerSetAttribute)

                  Dim categories As String = String.Join(", ", categorySet.value)

                  Dim averageMonthlySearches As Long =
                  DirectCast(ideas(AttributeType.SEARCH_VOLUME), LongAttribute).value

                  Dim averageCpc As Money = DirectCast(ideas(AttributeType.AVERAGE_CPC),
                    MoneyAttribute).value
                  Dim competition As Double = DirectCast(ideas(AttributeType.COMPETITION),
                    DoubleAttribute).value
                  Console.WriteLine("Keyword with text '{0}', average monthly search " +
                  "volume {1}, average CPC {2}, and competition {3:F2} was found with " +
                  "categories: {4}", keyword, averageMonthlySearches, averageCpc.microAmount,
                  competition, categories)
                Next
                i = i + 1
              Next
            End If
            selector.paging.IncreaseOffset()
          Loop While (selector.paging.startIndex < page.totalNumEntries)
          Console.WriteLine("Number of related keywords found: {0}", page.totalNumEntries)
        Catch e As Exception
          Throw New System.ApplicationException("Failed to retrieve related keywords.", e)
        End Try
      End Using
    End Sub

  End Class

End Namespace

Send feedback about...

AdWords API
AdWords API
Need help? Visit our support page.