How can I get a Product's Landing Page URL from SHOPPING_PERFORMANCE_REPORT

55 views
Skip to first unread message

Roy Steves

unread,
Sep 21, 2016, 7:06:59 PM9/21/16
to AdWords Scripts Forum
I'm working on a script that's using the SHOPPING_PERFORMANCE_REPORT to do a number of quality control checks for my Shopping Campaign, at the product level.

One of the things I need to make this really work is the landing page URL, but unless I'm missing something terribly obvious, I'm not seeing that as one of the available fields--in any report type I've sifted through.

So, if I have an OfferId, along with the other fields available to the SHOPPING_PERFORMANCE_REPORT, is there a way to then retrieve the link that the Product is associated with?


Tyler Sidell (AdWords Scripts Team)

unread,
Sep 22, 2016, 9:56:59 AM9/22/16
to AdWords Scripts Forum
Hi Roy,

Taking a look at the fields from a Shopping Performance Report, there is no landing page url field available.  Depending on the use case, you might be able to cross reference the data from the Shopping Performance Report with a URL Performance Report, using Url and CampaignName fields.

Thanks,
Tyler Sidell
AdWords Scripts Team

Andy Parkerson

unread,
Sep 22, 2016, 10:11:52 AM9/22/16
to AdWords Scripts Forum
Roy,

To get the landing page URL of the items, you can use the Google Content API for Shopping. This is an advanced API you have to enable. Here is a link:


You should be able to build an object of {offerId : link} either in a single account or across accounts and then quickly access it whenever you need.

There may be better ways of doing this, but this is how I'd start to tackle it.

Thanks,
Andy

Roy Steves

unread,
Sep 22, 2016, 11:46:52 AM9/22/16
to AdWords Scripts Forum
Andy, that looks like a pretty good solution.  I have two questions, though.

First, the only time I've been able to get the Content API to work with AdWords Scripts (as in, from the AdWords interface, not the Apps Scripts interface) is when the MCC login and the Multi-Client Account login for Merchant Center are the same.  Have you found a way to connect while leveraging an existing Merchant Center account?  (I'll admit a bit of ignorance over how AdWords Scripts and Apps Scripts interact...)

Second, the only way I've found to get to a specific product is to download the entire catalog, and loop through it looking for the one I want--in fact, that's logic that I lifted from the resource you linked.  The good news is that if that's what I have to do, I already have a script that's doing the token juggling and pagination, but I'd be worried about timeouts.

Thanks!

Roy Steves

unread,
Sep 22, 2016, 11:51:29 AM9/22/16
to AdWords Scripts Forum
Tyler,

I'll play around with the URL report a bit more.  It looks like it can get down to the AdGroup level, at least, and I have the AdGroupID of the Shopping Campaign's main group, after all.  It looks like I'd be able to get the same click and conversion data from that as I could the Shopping Performance Report, but then I'd be missing the sku, price, etc.  I could try to match them based on some of their stats (clicks and impressions as a fingerprint... not ideal, but would probably work 99% of the time), perhaps.  Or, if the landing pages have microdata, I could parse it out of them...

The goal is to generate boilerplate Text Ads for top performing Shopping products--hence the need for basic product data and the URL.  :)

Thanks for the recommendation!

Andy Parkerson

unread,
Sep 22, 2016, 1:16:22 PM9/22/16
to AdWords Scripts Forum
Roy,

As for the first question about MCC & MCA logins, I have no idea. Tyler should be able to help with that one.

As for the second, here is some code I've used, that you should be able to adapt:

// ===============================================================================
//      Get item prices from shopping account
// ===============================================================================
function getItemPricesNames(merchants) {
  var pageToken;
  var pageNum = 1;
  var maxResults = 250;

// List all the products for a given merchant.
  var itemPricesNames = {};
  for (var account in merchants) {
    do {
      var products = ShoppingContent.Products.list(account, {
        pageToken: pageToken,
        maxResults: maxResults
      });
    //Logger.log('Page ' + pageNum);
      if (products.resources) {
        for (var i = 0; i < products.resources.length; i++) {
          itemPricesNames[products.resources[i].offerId] = {};
          itemPricesNames[products.resources[i].offerId]['price'] = products.resources[i].price.value;
          itemPricesNames[products.resources[i].offerId]['name'] = products.resources[i].title;
          itemPricesNames[products.resources[i].offerId]['account'] = merchants[account];
          //        Logger.log('Item [' + products.resources[i].offerId + '] ==> ' + itemPrices[products.resources[i].offerId].price);
        }
      } else {
        Logger.log('No more products in ' + merchants[account]);
      }
      pageToken = products.nextPageToken;
      pageNum++;
    } while (pageToken);
  }
  return itemPricesNames;
} // getItemPricesNames
// ==============================================================

This creates an object {offerId : { price : xxxxx, name : yyyyy, account : zzzzz}}. You should be able to modify it to grab name and url (look in products.resources[i].link).

I use this on an account with 10,000 items and it runs in around 1 minute. If you have considerably more, you can look at creating a Google Sheet with the offerIds and url, and then read that sheet and create the object you need. It should be faster that way.

Thanks,
Andy

Roy Steves

unread,
Sep 22, 2016, 1:23:25 PM9/22/16
to AdWords Scripts Forum
Thanks, Andy!  I'll wait to hear from Tyler on the account juggling.

So you are looping over them--but your point that I only need to do this once is a great one.  The last time I tackled this project, I had an account with 20 million products, so a Merchant Center API from a server-side app was the only solution, and so I never got around to it.  This time, though, I'm looking at catalogs between 10,000 and 80,000 products, which I can totally loop over to store the IDs and URLs.  With a sheet, you still have to loop over the rows to find a record, so you'd just be porting the problem from one environment to another.  Luckily, I can dump them into my database--I already have that connection for handling page tokens and the like anyway, so a new table or two is no problem.

Then, I could just run a nightly batch looking for new/changed values.  Yeah... that'll work.

Tyler Sidell (AdWords Scripts Team)

unread,
Sep 22, 2016, 4:54:12 PM9/22/16
to AdWords Scripts Forum
Hi Roy,

That is correct that the login that is authorizing the MCC level script has to be the login for the Content API for Shopping.  This is the case as you need to enable the Advanced API from the script itself in the UI.  You'd also need to enable it from the Google Developer's Console.  Both needs to be the same login in order for the script to run properly.

Thanks,
Tyler Sidell
AdWords Scripts Team

Roy Steves

unread,
Sep 22, 2016, 5:11:06 PM9/22/16
to AdWords Scripts Forum
I suppose the last time I tried this, Merchant Center MCAs were a very manual process--nothing at all like the AdWords MCCs.  I remember seeing something about Merchant Center revamping their account access, so this might be less of a quagmire than it had been in the past for agencies.

Thanks for the confirmation, Tyler--I'll start doing the research from there!
Reply all
Reply to author
Forward
0 new messages