-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating google analytics metrics getter #73
Conversation
I also ran I can separate out these changes if it makes it to hard to review, but I tried to highlight the actual changes. |
@@ -127,6 +127,41 @@ get_ga_properties <- function(account_id, token = NULL) { | |||
return(results$properties) | |||
} | |||
|
|||
#' Get all property information for a particular property id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@howardbaek This is a new function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't working for me. As documented, I made sure to check the box See and download your Google Analytics data.
on the OAuth screen:
When I run the example, I get
> property_info <- get_ga_property_info(property_id = "422558989")
Using user-supplied cached tokens stored using authorize("google")
Error in request_ga(token = token, url = paste0("https://analyticsadmin.googleapis.com/v1alpha/properties/", :
API request failed:{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@howardbaek Did you login with ITCR Gmail or your own personal gmail? If you logged in with your own gmail, you don't have access to this property id so it wouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should make that more clear in the example
#' } | ||
get_all_ga_metrics <- function(account_id = NULL, token = NULL, dataformat = "dataframe") { | ||
get_multiple_ga_metrics <- function(account_id = NULL, property_ids = NULL, token = NULL, dataformat = "dataframe", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this function got reworked. Can you take a look and see what you think of the changes and if you have recommendations? @howardbaek
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
> some_properties <- get_multiple_ga_metrics(property_ids = c("422671031", "422558989"))
Using user-supplied cached tokens stored using authorize("google")
Error in request_ga(token = token, url = paste0("https://analyticsadmin.googleapis.com/v1alpha/properties/", :
API request failed:{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may have to address the Google scopes as the functions here are denying permission.
We tested this in a pair programming session and found out it was because Howard was trying to access a property id with the hutchgmail account that it does not have access to. Tried to fix the docs appropriately. |
Purpose/implementation Section
What changes are being implemented in this Pull Request?
Fixing up some things for usability and DRYness purposes.
The google analytics
all_ga_metrics()
is being deprecated changed so it can take property ids instead of just taking all properties from an account.In order to do this, we needed to make a new function
get_ga_property_info()
that will allow a display name (and other info) for a property to be retrieved.