Posts under category Google

I have a Wordpress page and I need to track all clicks as Google Ads conversion so I've found that I can use the entire page as a link with the following code:

<html>     <body onclick='window.location.href="http://google.com"'>     </body> </html>

Then I need to activate the Google conversion tag at every click and the conversion script are:

<!-- Event snippet for Solicitar cotação conversion page In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> <script>function gtag_report_conversion(url) {   var callback = function () {     if (typeof(url) != 'undefined') {       window.location = url;     }   };   gtag('event', 'conversion', {       'send_to': 'AW-ID/AWID',       'event_callback': callback   });   return false; }</script>

Ok, so please, how can I make every click count as a conversion?

Thank you very much.

My code is working fine on Dev server but throws Error on Staging server, am I missing anything on Staging?

Error: Fatal Error (1): Failed to parse binary descriptor in [../app/Vendor/googleads/google-ads-php/metadata/Google/Ads/GoogleAds/V8/Services/ConversionUploadService.php, line 124]

Thanks in advance.

I have followed this guide Quick start but it did not work. I am using google-ads-api PHP library can be found here. I did follow it generated Refresh token. Client ID and Secret Id of my cloud project which which is of type WEB, Published and has access to google ads api.

My developer token is approved. after following all this I made call to google-ads-api and it said bad request after that it returned user authentication failed, request failed. After that

I followed this guide to generate access token and placed it in my ini. It still shows the bad request failed and the message Details: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Full error message is here

[2021-08-27T11:14:41.690565+02:00] google-ads.WARNING: Request made: Host: "googleads.googleapis.com", Method: "/google.ads.googleads.v8.services.KeywordPlanIdeaService/GenerateKeywordIdeas", CustomerId: 4278642742, RequestId: "Gl-RPU4lhQ9V1-u38_GVXA", IsFault: 1, FaultMessage: "["Authentication of the request failed."]" [2021-08-27T11:14:41.719424+02:00] google-ads.NOTICE: Request


Method Name: /google.ads.googleads.v8.services.KeywordPlanIdeaService/GenerateKeywordIdeas Host: googleads.googleapis.com Headers: { "x-goog-api-client": "gl-php/7.4.21 gapic/ gax/1.7.1 grpc/1.39.0", "x-goog-request-params": "customer_id=4278642742", "developer-token": "REDACTED" } Request: {"customerId":"4278642742","language":"languageConstants/1000","geoTargetConstants":["geoTargetConstants/1008021","geoTargetConstants/1014312"],"keywordPlanNetwork":"GOOGLE_SEARCH_AND_PARTNERS","keywordSeed":{"keywords":["Social media management is the process of managing your online presence on social media platforms like Facebook, Instagram, and Twitter by creating, publishing, and analyzing content you post. Managing social media also includes engaging and interacting with social media users. You can use tools, services, and social media managers to oversee your social media management.","No matter how you approach social media management, whether with the help of an agency or a toolset, it’s essential to understand more than social media management’s definition. You want to know what it includes, as well as how to make it a success for your company."]}}

Response

Headers: { "request-id": "Gl-RPU4lhQ9V1-u38_GVXA", "date": "Fri, 27 Aug 2021 09:14:47 GMT", "alt-svc": "h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"" }

Fault

Status code: 16 Details: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. Failure: {"errors":[{"errorCode":{"authenticationError":"AUTHENTICATION_ERROR"},"message":"Authentication of the request failed."}],"requestId":"Gl-RPU4lhQ9V1-u38_GVXA"} Request with ID 'Gl-RPU4lhQ9V1-u38_GVXA' has failed. Google Ads failure details: authentication_error: Authentication of the request failed.

The code I am running

     public static function main(){                 if (!class_exists(Server::class)) {                     echo 'Please install "react/http" package to be able to run this example';                     exit(1);                 }                          $loop = Factory::create();                 // Creates a socket for localhost with random port.                 $socket = new \React\Socket\Server(0, $loop);                          print 'Enter your OAuth2 client ID here: ';                 $clientId = trim(fgets(STDIN));                          print 'Enter your OAuth2 client secret here: ';                 $clientSecret = trim(fgets(STDIN));                          $redirectUrl = str_replace('tcp:', 'http:', $socket->getAddress());                 $oauth2 = new OAuth2(                     [                         'clientId' => $clientId,                         'clientSecret' => $clientSecret,                         'authorizationUri' => self::AUTHORIZATION_URI,                         'redirectUri' => $redirectUrl . self::OAUTH2_CALLBACK_PATH,                         'tokenCredentialUri' => CredentialsLoader::TOKEN_CREDENTIAL_URI,                         'scope' => self::SCOPE,                         // Create a 'state' token to prevent request forgery. See                         // https://developers.google.com/identity/protocols/OpenIDConnect#createxsrftoken                         // for details.                         'state' => sha1(openssl_random_pseudo_bytes(1024))                     ]                 );                          $authToken = null;                          $server = new Server(                     $loop,                     function (ServerRequestInterface $request) use ($oauth2, $loop, &$authToken){                         // Stops the server after tokens are retrieved.                         if (!is_null($authToken)) {                             $loop->stop();                         }                                  // Check if the requested path is the one set as the redirect URI.                         if (                             $request->getUri()->getPath()                             !== parse_url($oauth2->getRedirectUri(), PHP_URL_PATH)                         ) {                             return new Response(                                 404,                                 ['Content-Type' => 'text/plain'],                                 'Page not found'                             );                         }                                  // Exit if the state is invalid to prevent request forgery.                         $state = $request->getQueryParams()['state'];                         if (empty($state) || ($state !== $oauth2->getState())) {                             throw new UnexpectedValueException(                                 "The state is empty or doesn't match expected one." . PHP_EOL                             );                         };                                  // Set the authorization code and fetch refresh and access tokens.                         $code = $request->getQueryParams()['code'];                         $oauth2->setCode($code);                         $authToken = $oauth2->fetchAuthToken();                                  $refreshToken = $authToken['refresh_token'];                         print 'Your refresh token is: ' . $refreshToken . PHP_EOL;                                  $propertiesToCopy = '[GOOGLE_ADS]' . PHP_EOL;                         $propertiesToCopy .= 'developerToken = "INSERT_DEVELOPER_TOKEN_HERE"' . PHP_EOL;                         $propertiesToCopy .=  <<<EOD         ; Required for manager accounts only: Specify the login customer ID used to authenticate API calls.         ; This will be the customer ID of the authenticated manager account. You can also specify this later         ; in code if your application uses multiple manager account + OAuth pairs.         ; loginCustomerId = "INSERT_LOGIN_CUSTOMER_ID_HERE"         EOD;                         $propertiesToCopy .= PHP_EOL . '[OAUTH2]' . PHP_EOL;                         $propertiesToCopy .= "clientId = \"{$oauth2->getClientId()}\"" . PHP_EOL;                         $propertiesToCopy .= "clientSecret = \"{$oauth2->getClientSecret()}\"" . PHP_EOL;                         $propertiesToCopy .= "refreshToken = \"$refreshToken\"" . PHP_EOL;                                  print 'Copy the text below into a file named "google_ads_php.ini" in your home '                             . 'directory, and replace "INSERT_DEVELOPER_TOKEN_HERE" with your developer '                             . 'token:' . PHP_EOL;                         print PHP_EOL . $propertiesToCopy;                                  return new Response(                             200,                             ['Content-Type' => 'text/plain'],                             'Your refresh token has been fetched. Check the console output for '                                 . 'further instructions.'                         );                     }                 );                          $server->listen($socket);                 printf(                     'Log into the Google account you use for Google Ads and visit the following URL '                         . 'in your web browser: %1$s%2$s%1$s%1$s',                     PHP_EOL,                     $oauth2->buildFullAuthorizationUri(['access_type' => 'offline'])                 );                          $loop->run();             }          ```                   Lastly this is my                   google_ads_php.ini file                   ```[GOOGLE_ADS]         ; Required AdWords API properties. Details can be found at:         ; https://developers.google.com/adwords/api/docs/guides/basic-concepts#soap_and_xml         developerToken = "AIzaSyDpRMH__DIsA6mdCchZKJeFoDwq4l*****"         clientCustomerId = "427-864-*****"                  ; Optional. Set a friendly application name identifier.         ; userAgent = "INSERT_USER_AGENT_HERE"                  ; Optional additional AdWords API settings.         ; endpoint = "https://adwords.google.com/"         ; isPartialFailure = false                  ; Optional setting for utility usage tracking in the user agent in requests.         ; Defaults to true.         ; includeUtilitiesInUserAgent = true                  [ADWORDS_REPORTING]         ; Optional reporting settings.         ; isSkipReportHeader = false         ; isSkipColumnHeader = false         ; isSkipReportSummary = false         ; isUseRawEnumValues = false                  [OAUTH2]         ; Required OAuth2 credentials. Uncomment and fill in the values for the         ; appropriate flow based on your use case. See the README for guidance:         ; https://github.com/googleads/googleads-php-lib/blob/master/README.md#getting-started                  ; For installed application or web application flow.         [OAUTH2]         clientId = "4016385****-eu0426e2lm7tlin2qa0kou4qfk80****.apps.googleusercontent.com"         clientSecret = "DPBf9pMtBHWZSk2hB*******"         refreshToken = "1//03nOACQc-vMyhCgYIARAAGAMSNwF-L9Irj8qSRZlvPdzR4n6_EbfHMLtt_tZNxJpOmZFJPLG7EAuaI-hYPB1GDQ-************"         access_token= "ya29.a0ARrdaM-eqkzlCJLcqOmVvVujzjaYnuzi3cfUGKrEG3GTlGpaoJ5Z3feK5eL_l7VrwnYYPFRqjqlDQ1eQO9FA2M8VsKbwXAI77NUsz7QxHCTo65YJHSQ5QzDOMu8Xkrzcp2Kg8KYKotTHVJ2Kiw**********"         ; For service account flow.         ; jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE"         ; scopes = "https://www.googleapis.com/auth/adwords"         ; impersonatedEmail = "INSERT_EMAIL_OF_ACCOUNT_TO_IMPERSONATE_HERE"                  [SOAP]         ; Optional SOAP settings. See SoapSettingsBuilder.php for more information.         ; compressionLevel = <COMPRESSION_LEVEL>                  [CONNECTION]         ; Optional proxy settings to be used by requests.         ; If you don't have username and password, just specify host and port.         ; proxy = "protocol://user:pass@host:port"         ; Enable transparent HTTP gzip compression for all reporting requests.         ; enableReportingGzip = false                  [LOGGING]         ; Optional logging settings.         ; soapLogFilePath = "path/to/your/soap.log"         ; soapLogLevel = "INFO"         ; reportDownloaderLogFilePath = "path/to/your/report-downloader.log"         ; reportDownloaderLogLevel = "INFO"         ; batchJobsUtilLogFilePath = "path/to/your/bjutil.log"         ; batchJobsUtilLogLevel = "INFO"

I am using google-ads-api module in nodejs to connect with Google Ads API.

I am using this code block to get Customer

const customer = client.Customer({     customer_id: 'XXX-XXX-XXXX',     refresh_token: refreshToken, }) 

I have used XXX-XXX-XXXX, XXXXXXXXXX, XXXX-XXX-XXX format for customer_id but still it is returning this error

GoogleAdsFailure {   errors: [     GoogleAdsError {       error_code: [ErrorCode],       message: "Invalid customer ID ''."     }   ],   request_id: 'OcUdfalh_N0U4hTJUd6c6g' }