Posts under category Google

Regarding Google AdWords:

  1. Does their data contain details of the person/user who is generating the clicks/impressions? Such as employer, organization?
  2. Is there a way to see the geography of clicks/impressions?

Thank you! Ashish

I am building something to sort and add values from an API response. I ended up going with an interesting structure, and I just want to make sure there's nothing inherently wrong with it.

from collections import defaultdict # Helps create a unique nested default dict object # for code readability def dict_counter():     return defaultdict(lambda: 0) # Creates the nested defaultdict object ad_data = defaultdict(dict_counter) # Sorts each instance into its channel, and # adds the dict values incrimentally for ad in example:        # Collects channel and metrics     channel = ad['ad_group']['type_']     metrics = dict(         impressions= int(ad['metrics']['impressions']),         clicks     = int(ad['metrics']['clicks']),         cost       = int(ad['metrics']['cost_micros'])     )          # Adds the variables     ad_data[channel]['impressions'] += metrics['impressions']     ad_data[channel]['clicks'] += metrics['clicks']     ad_data[channel]['cost'] += metrics['cost'] 

The output is as desired. Again, I just want to make sure I'm not reinventing the wheel or doing something really inefficient here.

defaultdict(<function __main__.dict_counter()>,             {'DISPLAY_STANDARD': defaultdict(<function __main__.dict_counter.<locals>.<lambda>()>,                          {'impressions': 14, 'clicks': 4, 'cost': 9}),              'SEARCH_STANDARD': defaultdict(<function __main__.dict_counter.<locals>.<lambda>()>,                          {'impressions': 6, 'clicks': 2, 'cost': 4})}) 

Here's what my input data would look like:

example = [     {         'campaign':          {             'resource_name': 'customers/12345/campaigns/12345',             'status': 'ENABLED',             'name': 'test_campaign_2'         },         'ad_group': {             'resource_name': 'customers/12345/adGroups/12345',             'type_': 'DISPLAY_STANDARD'},         'metrics': {             'clicks': '1', 'cost_micros': '3', 'impressions': '5'         },         'ad_group_ad': {             'resource_name': 'customers/12345/adGroupAds/12345~12345',             'ad': {                 'resource_name': 'customers/12345/ads/12345'             }         }     },     {         'campaign':          {             'resource_name': 'customers/12345/campaigns/12345',             'status': 'ENABLED',             'name': 'test_campaign_2'         },         'ad_group': {             'resource_name': 'customers/12345/adGroups/12345',             'type_': 'SEARCH_STANDARD'},         'metrics': {             'clicks': '2', 'cost_micros': '4', 'impressions': '6'         },         'ad_group_ad': {             'resource_name': 'customers/12345/adGroupAds/12345~12345',             'ad': {                 'resource_name': 'customers/12345/ads/12345'             }         }     },     {         'campaign':          {             'resource_name': 'customers/12345/campaigns/12345',             'status': 'ENABLED',             'name': 'test_campaign_2'         },         'ad_group': {             'resource_name': 'customers/12345/adGroups/12345',             'type_': 'DISPLAY_STANDARD'},         'metrics': {             'clicks': '3', 'cost_micros': '6', 'impressions': '9'         },         'ad_group_ad': {             'resource_name': 'customers/12345/adGroupAds/12345~12345',             'ad': {                 'resource_name': 'customers/12345/ads/12345'             }         }     } ] 

Thanks!

I have set it up adsupport, adservices, iad frameworks and more, but still no conversions on Google Ads as a conversion.

Google ads takes first_open but no subscription_convert or renew...

Any idea?

I have tried it with different ad accounts but no difference.

  1. Does anybody know after how much time or how many requests does refresh token expires in Google ads API? I created refresh token here https://developers.google.com/oauthplayground.
  2. Does anyone know what is the impersonated email in server account in Google ads API? I created server account in Google cloud project. If I run python code with Service Account configuration with generated json_key_file_path and same impersonated_email as my email account with which I created project then I get an error google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', {'error': 'unauthorized_client', 'error_description': 'Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.'}). If I put for impersonated_email client_email that I got from generated jon file I get an error: User in the cookie is not a valid Ads user.

I try to make a keyword searches system for our employ and i have google ads developer token But I cannot able to find any CURL or PHP CURL setup guide.

Two reference links Ad API Examples
Method: customers.generateKeywordIdeas

An example from Google's documentation:

curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/campaignBudgets:mutate" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data "{ 'operations': [   {     'create': {       'name': 'My Campaign Budget #${RANDOM}',       'amountMicros': 500000,     }   },   {     'create': {       'name': 'My Campaign Budget #${RANDOM}',       'amountMicros': 500000,     }   } ] }" 

I try this code but got Error

    <?          $ch = curl_init();          curl_setopt($ch, CURLOPT_URL, 'https://googleads.googleapis.com/v11/customers/(MANAGER_CUSTOMER_ID):generateKeywordIdeas');     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_POST, 1);     curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n\n\"keywordSeed\": {\n    \"keywords\": [\n    \"cofee\"\n  ]\n  }\n}");          $headers = array();     $headers[] = 'Content-Type: application/json';     $headers[] = 'Login-Customer-Id: (MANAGER_CUSTOMER_ID)';     $headers[] = 'Developer-Token: DEVELOPER_TOKEN';     $headers[] = 'Authorization: Bearer (OAUTH_ACCESS_TOKEN)';     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);          $result = curl_exec($ch);     if (curl_errno($ch)) {         echo 'Error:' . curl_error($ch);     }     print_r($result);     curl_close($ch); 

I'm not getting any output