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;
}