Class AdWordCriterionService

Description

AdWords Lib Criterion Class

Use this class to work with Google AdWords Criterion Service CriterionService provides operations for accessing, modifying, and creating Criteria (Keywords and Websites) in an AdGroup.

Located in /services/AdWordCriterionService.inc

AdWordService
   |
   --AdWordCriterionService
Method Summary
 AdWordCriterionService AdWordCriterionService (string $soapToolkit)
 object|false addCriteria (array $newCriteria, [string $clientEmail = ''])
 object|false checkCriteria (array $criteria, [object AdWordLanguageTarget $languageTarget = ''], [object AdWordGeoTarget $geoTarget = ''], [string $clientEmail = ''])
 array|false getAllCriteria (int $adGroupId, [string $clientEmail = ''])
 array|false getCampaignNegativeCriteria (int $campaignId, [string $clientEmail = ''])
 array|false getCriteria (int $adGroupId, array $criterionIds, [string $clientEmail = ''])
 array|false getCriterionStats (int $adGroupId, array $criterionIds, string $start, string $end, [string $clientEmail = ''])
 bool removeCriteria (int $adGroupId, array $criterionIds, [string $clientEmail = ''])
 bool setCampaignNegativeCriteria (array $campaignId, array $criteria, [string $clientEmail = ''])
 bool updateCriteria (array $criteria, [string $clientEmail = ''])
Methods

AdWordCriterionService Constructor. It takes one parameter - name of a supported by AdWords Lib SOAP toolkit

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  ?>
Please use defined constants for supported by AdWords Lib toolkit names

AdWordCriterionService AdWordCriterionService (string $soapToolkit)
  • string $soapToolkit: name of a supported by AdWords Lib SOAP Toolkit

Adds a new Criteria to an AdGroup.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$newCriteria is an array of objects of class AdWordCriterion
  5.  $response $criterionService->addCriteria($newCriteria);
  6.  if ($response === false// if an error appears
  7.          $errr $criterionService->getLastError()//get error object
  8.          echo $errr->toString()//output error
  9.          exit();
  10.  }
  11.  //$response is an array of objects of class AdWordCriterion which hold the new created criteria
  12.  ?>

object|false addCriteria (array $newCriteria, [string $clientEmail = ''])
  • array $newCriteria: array of objects of class AdWordCriterion
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Check a batch of criteria for policy errors.

The number of criteria in the batch is limited to the maximum number of criteria per adgroup.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$criteria is an array of objects of class AdWordCriterion
  5.  //$languageTarget is an object of class AdWordLanguageTarget
  6.  //$geoTarget is an object of class AdWordGeoTarget
  7.  $response $criterionService->checkCriteria($criteria$languageTarget$geoTarget);
  8.  if ($response === false// if an error appears
  9.          $errr $criterionService->getLastError()//get error object
  10.          echo $errr->toString()//output error
  11.          exit();
  12.  }
  13.  //$response is an array of objects of class ApiError which hold a list of policy errors
  14.  ?>

object|false checkCriteria (array $criteria, [object AdWordLanguageTarget $languageTarget = ''], [object AdWordGeoTarget $geoTarget = ''], [string $clientEmail = ''])

Return a list of criteria associated with this AdGroup.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$adGroupId - ID of the adGroup
  5.  $response $criterionService->getAllCriteria($adGroupId);
  6.  if ($response === false// if an error appears
  7.          $errr $criterionService->getLastError()//get error object
  8.          echo $errr->toString()//output error
  9.          exit();
  10.  }
  11.  //$response is an array of objects of class AdWordCriterion
  12.  ?>

array|false getAllCriteria (int $adGroupId, [string $clientEmail = ''])
  • int $adGroupId: ID of the adGroup
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Gets a list of the negative criteria associated with a campaign.

Negative criteria determine where the ads in the campaign will not be displayed. Negative website criteria indicate websites where the ads will not appear. Negative keyword criteria indicate keywords that cause the ads to be excluded from display.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$campaignId - ID of the campaign
  5.  $response $criterionService->getCampaignNegativeCriteria($campaignId);
  6.  if ($response === false// if an error appears
  7.          $errr $criterionService->getLastError()//get error object
  8.          echo $errr->toString()//output error
  9.          exit();
  10.  }
  11.  //$response is an array of objects of class AdWordCriterion
  12.  ?>

array|false getCampaignNegativeCriteria (int $campaignId, [string $clientEmail = ''])
  • int $campaignId: ID of the campaign
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Return a list of criteria with the specified IDs associated with this AdGroup.

This function will only return criteria associated with one AdGroup at a time. Invalid IDs are ignored.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$adGroupId - ID of the adGroup
  5.  //$criterionId1, $criterionId2 - Criterion IDs
  6.  $criterionIds array($criterionId1$criterionId2);
  7.  $response $criterionService->getCriteria($adGroupId$criterionIds);
  8.  if ($response === false// if an error appears
  9.          $errr $criterionService->getLastError()//get error object
  10.          echo $errr->toString()//output error
  11.          exit();
  12.  }
  13.  //$response is an array of objects of class AdWordCriterion
  14.  ?>

array|false getCriteria (int $adGroupId, array $criterionIds, [string $clientEmail = ''])
  • int $adGroupId: ID of the adGroup
  • array $criterionIds: array of Criterion IDs
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Get statistics for a list of criteria in an ad group.

See StatsRecord for details about the statistics returned. The time granularity is one day. We use data types that include timezone information so that the dates can be properly normalized. (Note that statistics are not included for negative criteria.)

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$adGroupId - ID of the adGroup
  5.  //$criterionId1, $criterionId2 - Criterion IDs
  6.  $criterionIds array($criterionId1$criterionId2);
  7.  $start '2005-01-01T00:00:00Z';
  8.  $end '2005-02-01T00:00:00Z';
  9.  $response $criterionService->getCriterionStats($adGroupId$criterionIds$start$end);
  10.  if ($response === false// if an error appears
  11.          $errr $criterionService->getLastError()//get error object
  12.          echo $errr->toString()//output error
  13.          exit();
  14.  }
  15.  //$response is an array of objects of class AdWordStatsRecord
  16.  ?>

array|false getCriterionStats (int $adGroupId, array $criterionIds, string $start, string $end, [string $clientEmail = ''])
  • int $adGroupId: ID of the adGroup
  • array $criterionIds: array of Criteria IDs
  • string $start: beginning of the period
  • string $end: end of of the period
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Remove a list of Criteria from an AdGroup.

Note that there is no 'undo' for this operation.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$adGroupId - ID of the adGroup
  5.  //$criterionId1, $criterionId2 - Criterion IDs
  6.  $criterionIds array($criterionId1$criterionId2);
  7.  $response $criterionService->removeCriteria($adGroupId$criterionIds);
  8.  if ($response === false// if an error appears
  9.          $errr $criterionService->getLastError()//get error object
  10.          echo $errr->toString()//output error
  11.          exit();
  12.  }
  13.  //$response == true
  14.  ?>

bool removeCriteria (int $adGroupId, array $criterionIds, [string $clientEmail = ''])
  • int $adGroupId: ID of the adGroup
  • array $criterionIds: Criterion IDs
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Removes all existing negative criteria from a campain and sets new negative criteria for the specified campaign.

Negative criteria determine where the ads in the campaign will not be displayed. Negative website criteria indicate websites where the ads will not appear. Negative keyword criteria indicate keywords that cause the ads to be excluded from display.

Calling this method with a null or empty list clears the negative criteria for the campaign. If your campaign already has some negative criteria and you want to add more, first call getCampaignNegativeCriteria, then add the new negative criteria to the results and send the complete set of negative criteria to setCampaignNegativeCriteria.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$criteria is an array of objects of class AdWordCriterion
  5.  $response $criterionService->setCampaignNegativeCriteria($campaignId$criteria);
  6.  if ($response === false// if an error appears
  7.          $errr $criterionService->getLastError()//get error object
  8.          echo $errr->toString()//output error
  9.          exit();
  10.  }
  11.  //$response is true on success, false on failure
  12.  ?>

bool setCampaignNegativeCriteria (array $campaignId, array $criteria, [string $clientEmail = ''])
  • array $campaignId: the campaign id
  • array $criteria: array of objects of class AdWordCriterion
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Update all mutable fields associated with these Criteria.

Only the maxCpc, maxCpm, negative, and destinationUrl fields are mutable.

Example:

  1.  <?php
  2.  $criterionService new AdWordCriterionService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$criterion1, $criterion2 is an object of class AdWordCriterion
  5.  $criteria array($criterion1$criterion2);
  6.  $response $criterionService->updateKeywordList($criteria);
  7.  if ($response === false// if an error appears
  8.          $errr $classKW->getLastError()//get error object
  9.          echo $errr->toString()//output error
  10.          exit();
  11.  }
  12.  //$response == true
  13.  ?>

bool updateCriteria (array $criteria, [string $clientEmail = ''])
  • array $criteria: array of objects of class AdWordCriterion
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Inherited Methods

Inherited From AdWordService

 AdWordService::AdWordService()
 AdWordService::callService()
 AdWordService::getAccount()
 AdWordService::getClientCustomerId()
 AdWordService::getClientEmail()
 AdWordService::getLastError()
 AdWordService::getResponseHeaders()
 AdWordService::setAccount()
 AdWordService::setClientCustomerId()
 AdWordService::setClientEmail()

Documentation generated on Mon, 10 Sep 2007 15:07:17 +0300 by phpDocumentor 1.3.2