Posts tagged with google-ads-script

I am working with Google Ads Scripts. Based on my use case, I need to get the impressions, clicks, and other statistics about the products I have in my Google Ads account.

These product statistics will be analyzed in the script and based on certain criteria a Google Sheet document will be updated. The script goes like, retrieving all products (along with their statistics) from Google Ads account, see if the products impression and clicks meet a category (30 Impression, 1 click = Category "A", 20 Impressions, 0 Clicks = "Category B"), determines the product category, open Google Sheet hosted on Google Drive and updates the Category column in the Sheet based on product name or id.

Currently, I am facing an issue with retrieving Products and their statistics from Google Ads Account using Ads Script. I used the following code snippets to look for products but found no method or class that would help me achieve my desired results. I can only retrieve the productGroups, AdGroups, and Campaigns but none of them allow me to extract individual products.

function productGroup(){   var prodGroupIter = AdsApp.productGroups().get();   while (prodGroupIter.hasNext()){     Logger.log("prodGroup: ")     var prodGroup = prodGroupIter.next();     Logger.log(prodGroup.getValue());   } } function adGroup() {   var adGroupIterator = AdsApp.adGroups().get();   while (adGroupIterator.hasNext()) {     var adGroup = adGroupIterator.next();     Logger.log("adGroup: ")     Logger.log(adGroup.getName());   } } function campaign(){   var campIter = AdsApp.campaigns().get();   while (campIter.hasNext()){     var ads = campIter.next().ads().get();     while(ads.hasNext()){       Logger.log(ads.next().getStatsFor("LAST_30_DAYS"));     }   } } function sheet() {   var sheetURL = "https://docs.google.com/spreadsheets/d/1W0zhRrQa1P7qjQf0eXXw-QzdcPKAlDPiVBOcIVEfDgw/edit#gid=1428103052";   var sheet = SpreadsheetApp.openByUrl(sheetURL); } function main(){   campaign();   adGroup();   productGroup(); } 

I then reached out to the Ads Script support team and found out that it is not possible. But they suggested that I can use Shopping Performance Report, Product Partition Report, shopping_performance_view or product_group_view. They are part of AdWord API, and I do not know how to work with them.

So, I am looking for a Google Ads Script that would help me get a list of products (with detailed statistics) from Googe Ads and I am stuck with how to use the above-mentioned AdWord reporting endpoints to do it.

Here is the list of products in my Google Ads Account. They are 107 products along with their statistics.

Please, help with at least comments, ideas, and suggestions, I can write code but I am not sure what I am missing on

I've tried to run this GAQL on an MCC, but didn't get any rows.

ads-script:

campaignIds query =SELECT customer.id, campaign.resource_name, campaign.name FROM campaign WHERE campaign.id IN ("123456"); _rowsToMap(accountToCampaignsMap, AdsApp.report(query, REPORTING_OPTIONS));     }     function _rowsToMap(map, response) {       rows = response.rows();       while (rows.hasNext()) {         var row = rows.next();         Logger.log(JSON.stringify(row)); ... } 

Even though I see it in the UI under this MCC

What am I missing?

I am having a hard time to find a documentation for web conversion tracking for Google Ads.

I would like to understand more about the HTTP POST request that is sent to Google. I can see there is a good documentation for mobile apps: https://developers.google.com/app-conversion-tracking/api/request-response-specs?hl=en#conversion_tracking_request

Is there similar documentation for web? I would like to understand more how i could send conversions to Google creating manually my HTTP request.

I am aware of the Offline conversions API (https://developers.google.com/google-ads/api/docs/samples/upload-offline-conversion), but it doesn't support the new parameters as wbraid

I've been trying to run some sample code from the official docs.

But I get an error: Invalid reporting query: ACCOUNT_PERFORMANCE_REPORT. (file Code.gs, line 18)

The official sample from the official doc: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_report

My code:

function main() {   var spreadsheet = SpreadsheetApp.create("Report output");    //var report = AdsApp.report("SELECT Id, PolicySummary FROM ACCOUNT_PERFORMANCE_REPORT DURING LAST_30_DAYS");   var report = AdsApp.report("SELECT Clicks, Impressions, AverageCpc, HourOfDay FROM ACCOUNT_PERFORMANCE_REPORT DURING LAST_MONTH");    report.exportToSheet(spreadsheet.getActiveSheet());    Logger.log("Report available at " + spreadsheet.getUrl()); } 

I try to run the following ad-words from my adwords script editor.

My final goal is to be able to run query1 or query2

//conversion_action var query1 = "SELECT conversion_action.app_id, conversion_action.attribution_model_settings.attribution_model, conversion_action.attribution_model_settings.data_driven_model_status, conversion_action.category, conversion_action.click_through_lookback_window_days, conversion_action.counting_type, conversion_action.firebase_settings.event_name, conversion_action.firebase_settings.project_id, conversion_action.id, conversion_action.include_in_conversions_metric,  conversion_action.name, conversion_action.owner_customer,  conversion_action.resource_name, conversion_action.status, conversion_action.tag_snippets, conversion_action.third_party_app_analytics_settings.event_name, conversion_action.third_party_app_analytics_settings.provider_name, conversion_action.type, conversion_action.value_settings.always_use_default_value, conversion_action.value_settings.default_currency_code, conversion_action.value_settings.default_value, conversion_action.view_through_lookback_window_days,  metrics.conversion_last_conversion_date FROM conversion_action WHERE metrics.conversion_last_conversion_date > '2020-01-01'"; var TimeFrame = spreadsheet.getRangeByName("Last_x_days").getValue(); var now = new Date(); var from = new Date(now.getTime() - 10 * MILLIS_PER_DAY); var query2 = "SELECT conversion_action.firebase_settings.event_name,  conversion_action.type, conversion_action.name,conversion_action.resource_name, conversion_action.third_party_app_analytics_settings.event_name, metrics.conversion_last_conversion_date FROM conversion_action WHERE metrics.conversion_last_conversion_date > '" + Utilities.formatDate(from, AdsApp.currentAccount().getTimeZone(), 'yyyy-MM-dd') + "'"; var report = AdWordsApp.report(query2, { apiVersion: 'v8' }); 

But I get a vague error:

We're sorry, a server error occurred. Please wait a bit and try again. (file code.gs, line 25) which is the last code line here

What can it be?