This one is deprecated since the demise of Gadgets on sites.
I used to abstract all database matters away from Google Apps Script with Database abstraction with google apps script. The scheduled analytics update wrote the matched site page and analytic data to an abstracted database. At the time of writing, I happened to be using Driver MongoLab.
Once the Matching the site tree to the analytics data was complete, the data needed to be flattened from a tree object so we could create a row per site page. This page was later retrieved by the gadget which created the visual representation of that page’s analytics.
That was achieved in this step
The database parameters are defined in Storing options and parameters and accessed from that library. This means that multiple projects can use synchronised parameters for the same data.
The data stored for each page will look something like this, and will be indexed in the client gadget using page.url.
See more like this in  Displaying analytics data on site pages