Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
function formatDate(s) {
    return s.substr(0,4)+'-'+s.substr(4,2)+'-'+s.substr(6,2);
    }
     
    return _.map(doc.rows, function(row) {
    var rowdoc = {};
    for (var i = 0; i < doc.dimensionHeaders.length; i++) {
    var name = doc.dimensionHeaders[i].name;
    rowdoc[name] = name == 'date' ? formatDate(row.dimensionValues[i].value) : row.dimensionValues[i].value;
    }
    
    for (var i = 0; i < doc.metricHeaders.length; i++) {
        var metric_name = doc.metricHeaders[i].name;
        rowdoc[metric_name] =  row.metricValues[i].value;
        }
    
    return rowdoc;
    });

To find the Property ID that is required in the URL go to https://analytics.google.com/ → Admin section, select Property → Property Details and there should be PROPERTY ID displayed

...