Posts under category google-ads-api

I am using:

https://developers.google.com/analytics/devguides/collection/protocol/v1/

for server side tracking.

This is the set-up:

  • Google analytics account.
  • Google adwords account.
  • Adwords account is linked to the analytics account.

I create an ad in adwords, the user clicks the ads, the user visits the third party website, the third party website make a https POST request with the visitor gclid from adwords. This is stored in a mysql database.

In the google adwords account I have an event for conversion created. (Using the offline tracking conversion works, but the only reason why I would prefer to use measurement protocol is because the offline tracking only accepts the conversions after 90 minutes. )

And I send the page views and conversion in this way:

/**  * @param $gclid  * @param $clientId  * @return \TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse  */ private function sendPageView($gclid, $clientId){     $this->analytics         ->setProtocolVersion(1)         ->setTrackingId(self::GLOBAL_TRACKING_ID)         ->setGoogleAdwordsId($gclid)         ->setAnonymizeIp(true)         ->setClientId($clientId);     return $this->analytics->sendPageview(); } /**  * @param $gclid  * @param $clientId  * @return \TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse  */ private function sendConversion($gclid, $clientId, $url){     $this->analytics         ->setProtocolVersion(1)         ->setTrackingId(self::GLOBAL_TRACKING_ID)         ->setGoogleAdwordsId($gclid)         ->setAnonymizeIp(true)         ->setClientId($clientId)         ->setEventAction('s2s')         ->setEventCategory('Lead')         ;     return $this->analytics->sendEvent(); } 

Response:

object(TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse)#1008 (3) {   ["httpStatusCode":protected]=>   int(200)   ["requestUrl":protected]=>   string(164) "https://ssl.google-analytics.com/collect?v=1&tid=UA-1XXXXX-1&gclid=EAIaIQobChMInvrxopLZ5gIVXXXXXXXXXXXXXXXXXXXX_BwE&aip=1&cid=1&ea=s2s&ec=Lead&t=event"   ["responseBody":protected]=>   string(35) "GIF89a�����,D;" } 

So the response is 200, however the conversion is not recorded anywhere, and I am not sure if I should be sending any other parameter, or how to debug the issue.

I am making a web application that will automate some actions on Google AdWords. The web application can be used by anyone that has an AdWords account.

I am a bit puzzled by the AdWords API, as it is a different from other Google APIs, in terms that it needs two additional config parameters: developerToken and clientCustomerId, a per their documentation:

https://developers.google.com/adwords/api/docs/guides/first-api-call

When constructing the AdWordsClient object, I need to provide the developerToken and clientCustomerId, in order to push data to AdWords.

My question is whether these two parameters (developerToken, clientCustomerId) need to be different for each user that will use my web application?

It seems that I am able to post data to different accounts with an unrelated developerToken, which does not make sense.

Can I get the clientCustomerId from an API endpoint, so I don't require my users to manually input tokens and ids to the web app, and do the complete authentication with oAuth?

My code is working, I am asking more of the philosophy why I need these two parameters, and if I can avoid asking the user to manually copy them from the AdWords dashboard into my application?

I am new to Google AdWords API. There is no mention of Keyword in UpdateKeyword class of Google AdWords API, It is only used to update MaxCPC using criterionId. Normally Google AdWords API's are pretty simple, but I am not getting how to update keyword properties. How do I update keyword, KeywordmMatchType, and maxCPC?

  public static void runExample(       AdWordsServicesInterface adWordsServices,       AdWordsSession session,       Long adGroupId,       Long keywordId)       throws RemoteException {     // Get the AdGroupCriterionService.     AdGroupCriterionServiceInterface adGroupCriterionService =         adWordsServices.get(session, AdGroupCriterionServiceInterface.class);     // Create ad group criterion with updated bid.     Criterion criterion = new Criterion();     criterion.setId(keywordId);     BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();     biddableAdGroupCriterion.setAdGroupId(adGroupId);     biddableAdGroupCriterion.setCriterion(criterion);     // Create bids.     BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();     CpcBid bid = new CpcBid();     bid.setBid(new Money(null, 10000000L));     biddingStrategyConfiguration.setBids(new Bids[] {bid});     biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);     // Create operations.     AdGroupCriterionOperation operation = new AdGroupCriterionOperation();     operation.setOperand(biddableAdGroupCriterion);     operation.setOperator(Operator.SET);     AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[] {operation};     // Update ad group criteria.     AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);     // Display ad group criteria.     for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {       if (adGroupCriterionResult instanceof BiddableAdGroupCriterion) {         biddableAdGroupCriterion = (BiddableAdGroupCriterion) adGroupCriterionResult;         CpcBid criterionCpcBid = null;         // Find the criterion-level CpcBid among the keyword's bids.         for (Bids bids : biddableAdGroupCriterion.getBiddingStrategyConfiguration().getBids()) {           if (bids instanceof CpcBid) {             CpcBid cpcBid = (CpcBid) bids;             if (BidSource.CRITERION.equals(cpcBid.getCpcBidSource())) {               criterionCpcBid = cpcBid;             }           }         }         System.out.printf(             "Ad group criterion with ad group ID %d, criterion ID %d, type "                 + "'%s', and bid %d was updated.%n",             biddableAdGroupCriterion.getAdGroupId(),             biddableAdGroupCriterion.getCriterion().getId(),             biddableAdGroupCriterion.getCriterion().getCriterionType(),             criterionCpcBid.getBid().getMicroAmount());       }     }   } } 

We have connected AdWords to our Google Analytics views and it works: AdWords campaigns are shown in Google Analytics. For deeper analysis we would like to analyze the data also in BigQuery.

We have setup the import from Google Analytics to BigQuery using a data view which is linked to AdWords. The import itself works, but if we search in BigQuery for TrafficCampaigns with TrafficMedium = cpc (AdWords-Campaigns), the campaigns are missing (null).

We are also importing all AdWords data directly to BigQuery, but we could not find how to relate this data to the Google Analytics data.

Does anybody know how this works? What do we have to do to link the AdWords campaigns with the Google Analytics data in BigQuery?

Thanks for your help! Kind regards, Al

Screenshot of GA-Export in BQ

I'm trying to fetch the audiences (Custom intent, Custom affinity) of all my enabled google display campaigns.

I thought I can get it through the CampaignCriterionService, but the returned data is empty.

     campaign_criterion_service = ADWORDS_CLIENT.GetService(         'CampaignCriterionService', version='v201809')     selector = {         'fields': ['CampaignId', 'Id', 'CriteriaType', "PlacementUrl",                    'KeywordText', "ChannelName", "AppId", "DisplayName", "CampaignStatus", "CampaignName"],         'predicates': [{             'field': 'CriteriaType',             'operator': 'IN',             'values': [                 'CUSTOM_AFFINITY',                 'CUSTOM_INTENT'             ]         },         {             'field': 'CampaignStatus',             'operator': 'IN',             'values': [                 'ENABLED'             ]         }         ],         'paging': {             'startIndex': 0,             'numberResults': 500         }     }     page = campaign_criterion_service.get(selector) 

Any clues?