This is also part of each evenings scheduled run. The site is serialized and each analytics entry is matched up to a page on the site. This whole project is heavily recursive, right from the site organization, right through to the final output where rankings are shown both for the page and the topic to which the page belongs.
Here's how the pages are fetched
// this is the site i'm working with
var site = SitesApp.getSite(options.domain, options.site);
// get all the pages on the site
var root = getPages(site);
Again I'm using exponential backoff to avoid those tiresome rate limit errors.
Now I have a a nice tree of all pages on my site, ready to be matched
See more like this in Displaying analytics data on site pages
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Fancy gadgets on Sites >