PROGRESS REPORT:
Google Analytics API v3
Queries come as JSON, not XML (at least, as far as I can tell).
I managed to retrieve the profiles data, and to get it into an R list. However, downstream functions are coded for an XML object.
IMHO the simpler approach would be to recode the XML parsing functions, rather than to hammer the JSON result into an XML format to be reparsed.
I used the rjson library to transform the ga "feed" into a list, as follows:
response <- fromJSON(getURL("
https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles?key=<MY KEY>", .encoding = 'UTF-8', httpheader = c("Authorization" = google.auth, "GData-Version" = 2), headerfunction=header$update ))
I couldn't get the getURL result directly into the variable, so I transformed it previously.
It must also be noted that for the time being the OAuth 1 Token (key) is hard-coded. For either OAuth 2 or 1, these tokens should be saved into the working(?) directory, and called upon by the script, preferably as an function option (to allow for direct key input or change of location).
The output of the GetProfileData() function looks like this:
> ga$GetProfileData()
$kind
[1] "analytics#profiles"
$username
[1] "
your.log...@here.net"
$totalResults
[1] 1
$startIndex
[1] 1
$itemsPerPage
[1] 1000
$items
$items[[1]]
$items[[1]]$id
[1] "12345678"
$items[[1]]$kind
[1] "analytics#profile"
$items[[1]]$selfLink
[1] "
https://www.googleapis.com/analytics/v3/management/accounts/246810/webproperties/XX-000000-00/profiles/12345678"
$items[[1]]$accountId
[1] "1098765"
$items[[1]]$webPropertyId
[1] "XX-000000-00"
$items[[1]]$internalWebPropertyId
[1] "12341234"
$items[[1]]$name
[1] "
www.yourwebsite.org"
$items[[1]]$currency
[1] "USD"
$items[[1]]$timezone
[1] "America/Phoenix"
$items[[1]]$websiteUrl
[1] "
http://www.yourwebsite.org"
$items[[1]]$created
[1] "2001-01-01T00:00:00.000Z"
$items[[1]]$updated
[1] "2012-12-31T00:00:00.000Z"
$items[[1]]$parentLink
$items[[1]]$parentLink$type
[1] "analytics#webproperty"
$items[[1]]$parentLink$href
[1] "
https://www.googleapis.com/analytics/v3/management/accounts/246810/webproperties/XX-000000-00/"
$items[[1]]$childLink
$items[[1]]$childLink$type
[1] "analytics#goals"
$items[[1]]$childLink$href
[1] "
https://www.googleapis.com/analytics/v3/management/accounts/246810/webproperties/XX-000000-00/profiles/12345678/goals"
I do not manage multiple profiles with my account, so I do not know what exactly the output would look like. So, anyone? Ideas?
My 2¢ worth.