Greetings People! 

I hope you are having a great time. 

I was using Google Ads Script (JS) to extract the statistics of the product 
from the Google Ads account but it seems like there is no direct support 
for it. Following this conversation on Google Ads Script Group 
<https://groups.google.com/u/2/g/adwords-scripts/c/ZAVaSez_6FI>, I was 
directed to this Group. 

Using *metrics *and *segments *from *MerchantPerformanceView *I am able to 
extract impressions, clicks, and ctr of products along with ids. But I also 
need to get the cost and  ROAS for each product based on which I have 
categorize products using pre-set criteria. 

Is it possible to do this using Adword API? Also, can I use Adword API 
inside Google Ads Script that will be hosted on the Google Ads account? In 
addition to all other queries, can I use Adword API using javascript? 

I really am stuck with this task and I am not sure whether it is possible 
or not, please respond. 

*The code I have written so far. *
function productList( ) {
  // Merchent Id from Google Merchent Account
  var merchantId = "My-Google-Merchent-ID"; // Integer

  // Query to retrieve required data - this was the best i could come up 
with
  var query = "SELECT segments.offer_id, metrics.clicks, metrics.ctr, 
metrics.impressions FROM MerchantPerformanceView WHERE segments.date 
BETWEEN '2021-01-01' AND '2021-12-24'";
  var pageSize = 20;
  var pageToken;
  var productsDetails = [];
  
  do {
    // Get 20 produts per page - for performance measures
    var resource = {
      "query": query,
      "pageSize": pageSize,
      "pageToken": pageToken
    }
    
    // Get 20 products
    var reports = ShoppingContent.Reports.search(resource, merchantId);
    // Add them to the array
    productsDetails = productsDetails.concat(reports.results);
    // Get next page token
    pageToken = reports.nextPageToken;
  
  // Repeat above until no more pages are found
  } while (pageToken);
  
  // Return array of all products metrics
  return productsDetails; 
}


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/02df016e-c00e-448a-8e5d-957031114737n%40googlegroups.com.
  • Ho... Marcus D'Suza
    • ... Marcus D'Suza
      • ... Mhmoudahmdmohmmd homydt
    • ... 'Google Ads API Forum Advisor' via AdWords API and Google Ads API Forum
      • ... Marcus D'Suza
        • ... 'Google Ads API Forum Advisor' via AdWords API and Google Ads API Forum
          • ... Marcus D'Suza
            • ... 'Google Ads API Forum Advisor' via AdWords API and Google Ads API Forum
              • ... Marcus D'Suza
                • ... 'Google Ads API Forum Advisor' via AdWords API and Google Ads API Forum

Reply via email to