tomdyson/wagalytics

Provide per-page results

tomdyson opened this issue · 1 comments

e.g. in the settings tab. "This page has been viewed x times in the last 24 hours". Something like:

// https://developers.google.com/analytics/devguides/reporting/core/v3/coreDevguide

function makeApiCall() {
    params = {
        'ids': 'ga:81871816',
        'start-date': 'yesterday',
        'end-date': 'today',
        'metrics': 'ga:pageviews',
        'filters': 'ga:pagePath==/features/'
    }
    apiQuery = gapi.client.analytics.data.ga.get(params)
    apiQuery.execute(handleCoreReportingResults);
}

function handleCoreReportingResults(results) {
    if (!results.error) {
        if (results.rows && results.rows.length)
            console.log(results.rows[0][0]);
    } else {
        alert('Something broke: ' + results.message);
    }
}

Add to settings tab with something like

$('#settings ul[class="objects"]').append(
  '<li class="object"><h2><label>Analytics</label></h2><fieldset></fieldset></li>'
)

Access the path of the page currently being edited with

$('a[class="status-tag primary"]').attr('href')

Is there a setting for config files or some like it?