How to avoid PolicyViolationError beorehand in scripts

17 views
Skip to first unread message

Евгений Гардыш

unread,
Dec 20, 2018, 4:09:00 AM12/20/18
to AdWords API and Google Ads API Forum
Hi.

Sometimes I encountering PolicyViolationError during scripts work.
For example:
PHP Fatal error:  Uncaught Google\AdsApi\AdWords\v201809\cm\ApiException: [PolicyViolationError{super=PolicyViolationError.POLICY_ERROR @ operations[3].operand.criterion.text; trigger:'в +капсулах', key=PolicyViolationKey{policyName=ru_biologically_active_additive,violatingText +капсулах}, externalPolicyName=Google Реклама, externalPolicyUrl=, externalPolicyDescription=Перед показом это объявление или ключевое слово должно пройти проверку., isExemptable=true, violatingParts=[Part{index=6, length=11}]}, PolicyViolationError{super=PolicyViolationError.POLICY_ERROR @ operations[24].operand.criterion.text; trigger:'в +капсулах', key=PolicyViolationKey{policyName=ru_biologically_active_additive,violatingText +капсулах}, externalPolicyName=Google Реклама, externalPolicyUrl=, externalPolicyDescription=Перед показом это объявление или ключевое слово должно пройти пр in /adwords_api/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/Reflection.php on line 43

Is there any way to test keywords beforehand to exclude such keywords to avoid this kind of errors?

Can I download Policy keywords lists to check beforehand? Or is it exist some function to check keywords before main part of script starts?

Dhanya Sundararaju (AdWords API Team)

unread,
Dec 20, 2018, 10:20:55 AM12/20/18
to AdWords API and Google Ads API Forum
Hi,

You can set the $session->setValidateOnly(true); This will only validate the keyword. In other words, no objects will be created, but exceptions will still be thrown. You can refer to this sample code for validating TextAd and this guide for better clarity.

Regards,
Dhanya, AdWords API Team

Евгений Гардыш

unread,
Dec 20, 2018, 10:53:36 AM12/20/18
to AdWords API and Google Ads API Forum
Thanks for your reply. Already done using setValidateOnly + my own code + try/catch construction to avoid PHPscript stop.

The main thing for all who will use $session->setValidateOnly(true); in their working scripts - don`t forget to use $session->setValidateOnly(false); when you need to continue using working parts of your script...

четверг, 20 декабря 2018 г., 11:09:00 UTC+2 пользователь Евгений Гардыш написал:
Reply all
Reply to author
Forward
0 new messages