Storing options and parameters

Site analytics are stored with the site and the analytics property to which they refer, and accessed through the cSiteStats library. You will need to take a copy of this so you can reference your own properties. Also referenced here are the parameters required to describe what kind of database to store this is using Database abstraction with google apps script.

For testing, my library reference is MKHWwn03HE7ktl0fffddC-iz3TLx7pV4j

Once you've taken a copy, you'll need to set up your properties. Mine look like this and you should modify the function below to represent yours.

function setKnownOptions() {

  var options = {
    domain:"mcpher.com",
    site:"share",
    propertyId: '34421202',
    base: 'Home/',
    root: 'excelquirks',
    dbid:'siteinstrumentation',
    siteCode:'ramblings',
    siteRoot: "https://sites.google.com/a/",
    alternateRoots:[
        "http://ramblings.mcpher.com",
        "http://www.mcpher.com"
      ]
  };
  options.siloid = options.siteCode + options.propertyId;
  options.siteUrl = options.siteRoot + options.domain + "/" + options.site;
  setOptions (options);

  

The code

By centralizing access to your site options, you can ensure that any apps you create will access the same database and parameters, even though you change them.


See more like this in Database abstraction with google apps script and Displaying analytics data on site pages

For help and more information join our forum,follow the blog or follow me on twitter .



Comments