How to get the products ID, Impressions and Clicks, Cost and ROAS from Google Ads using Ads Script?

1,093 views
Skip to first unread message

Marcus D'Suza

unread,
Dec 27, 2021, 7:32:47 AM12/27/21
to AdWords API and Google Ads API Forum
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, 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;
}


Marcus D'Suza

unread,
Dec 27, 2021, 3:20:31 PM12/27/21
to AdWords API and Google Ads API Forum
Just to clarify the question, I need clicks, conversions, impressions, id, title and ROAS for a single product. So far I am able to get clicks, impressions, ctr, id, and titles for individual products. But I am not able to get ROAS and conversion. 

Google Ads API Forum Advisor

unread,
Dec 28, 2021, 12:03:17 AM12/28/21
to kaami...@gmail.com, adwor...@googlegroups.com
Hi Marcus,

Thank you for reaching out to us. However, I'm afraid that this forum channel can only provide technical assistance related to Google Ads API. With this, we would recommend to post your concern on Google Ads Scripts forum via this link instead for further assistance.

Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Tl2q9:ref

Marcus D'Suza

unread,
Dec 28, 2021, 4:38:16 AM12/28/21
to AdWords API and Google Ads API Forum
Hey Teejay, I appreciate your response, but you directed me here at Adwords Forum fro this post at Googe Scripts forum. I am not sure where to ask now? Should  I stay here? Becuase I posted in both forums. You directed me here from Ads Script here, and now directing me from here to Ads Script? Please, if you can guide me what to do.

Google Ads API Forum Advisor

unread,
Dec 28, 2021, 9:56:26 AM12/28/21
to kaami...@gmail.com, adwor...@googlegroups.com
Hi Marcus,

As you are using Ads scripts, please post your inquiry in the Ads scripts dedicated forum.

Thanks,
Matt
Google Ads API Team


Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Matt
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2Tl2q9:ref

Marcus D'Suza

unread,
Dec 28, 2021, 10:37:25 AM12/28/21
to AdWords API and Google Ads API Forum
Hey Matt, 

Hope you are doing great. I had been using Ads Script but that would not allow me to get the individual product statistics. That is when Teejy directed me here to this forum. Now I am looking for some solution using the Google Ads or Google Adwords API. I read through both documentations and came to this point that no new users can sign-up for developers token on Google Adwords API. But instead, users should be using the Google Ads API. 

Now I want to know, how can I retrieve product statistics using the Shopping Performace View resource in Google Ads API? I wanted to use the Shopping Performance Report resource from Adwords API but I do not have any developer token for that. 

Google Ads API Forum Advisor

unread,
Dec 28, 2021, 3:28:39 PM12/28/21
to kaami...@gmail.com, adwor...@googlegroups.com
Hi Marcus,

The shopping performance view provides product dimension level statistics. There is no ROAS metric for this view, but you can retrieve clicks, cost and impressions. Please note that the resources available in Ads API reporting can also be used in Ads scripts. Please see this table that maps AdWords API shopping performance to Ads API shopping performance. 

Regards,

Marcus D'Suza

unread,
Dec 28, 2021, 3:44:45 PM12/28/21
to AdWords API and Google Ads API Forum
Hi Matt,

Thank you so much for your answer. Just for clearance, I thought that Google Ads API can be used n (Java, C#, Python, PHP, Ruby, and Perl), after getting developer token from Google Ads Manager Account and OAuth Client ID and Secret from Google Cloud Project. But do you really mean I can query Google Ads API Reports (specifically the Shopping Performance View Report) in my Ads Script from the editor in Google Ads account. If yes, could you provide a link to a resource that has some example code? Because I couldn't find any. 

Google Ads API Forum Advisor

unread,
Dec 28, 2021, 8:50:57 PM12/28/21
to kaami...@gmail.com, adwor...@googlegroups.com

Hello Marcus,

Thanks for getting back to us.

Yes, we recommend utilizing the available client libraries when implementing the Google Ads API. As for this concern (But do you really mean I can query Google Ads API Reports (specifically the Shopping Performance View Report) in my Ads Script from the editor in Google Ads account.), yes, you can query Google Ads API reports via this guide. For more details related to the Google Ads scripts Search feature, we recommend that you raise it again to the Google Ads Scripts forum via this link.

Regards,

Google Logo
Mark Kevin Albios
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2Tl2q9:ref

Mhmoudahmdmohmmd homydt

unread,
Jan 2, 2022, 4:30:27 PM1/2/22
to kaami...@gmail.com, AdWords API and Google Ads API Forum
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/b1ac8b5c-86c2-4f16-80bc-e9e885e64fc7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages