Title: | Access 'Piwik Pro' Website Statistics |
---|---|
Description: | Run Queries against the API of 'Piwik Pro' <https://developers.piwik.pro/en/latest/custom_reports/http_api/http_api.html>. The result is a tibble. |
Authors: | Martin Stingl <[email protected]> |
Maintainer: | Martin Stingl <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.4.1 |
Built: | 2024-11-22 04:37:19 UTC |
Source: | https://github.com/dfv-ms/piwikpror |
Convert column-type according to column_name
apply_types(data, timestamp_to_date = TRUE)
apply_types(data, timestamp_to_date = TRUE)
data |
tibble |
timestamp_to_date |
boolean convert timestamp to date |
tibble
Build filter from tribble
build_filter(filters, global_operator = "and")
build_filter(filters, global_operator = "and")
filters |
tribble with columns
Possible values for operator:
|
global_operator |
"and" or "or" |
filter json encoded to feed to build_query
filters <- tibble::tribble( ~column, ~operator, ~value, "event_url", "matches", "Zamperoni", "event_url", "matches", "-1[34]" ) # With optional transformation filters <- tibble::tribble( ~column, ~operator, ~value, ~transformation, "event_url", "starts_with", "/medien", "to_path", "event_url", "matches", "-1[34]", NULL ) filters <- build_filter(filters, "and") # If values of two or more different types are used use lists filters <- tibble::tribble( ~column, ~operator, ~value, "device_type", "eq", list(0), "location_country_name", "eq", list("DE") ) # This also works for transformation
filters <- tibble::tribble( ~column, ~operator, ~value, "event_url", "matches", "Zamperoni", "event_url", "matches", "-1[34]" ) # With optional transformation filters <- tibble::tribble( ~column, ~operator, ~value, ~transformation, "event_url", "starts_with", "/medien", "to_path", "event_url", "matches", "-1[34]", NULL ) filters <- build_filter(filters, "and") # If values of two or more different types are used use lists filters <- tibble::tribble( ~column, ~operator, ~value, "device_type", "eq", list(0), "location_country_name", "eq", list("DE") ) # This also works for transformation
Build the query
build_query( date_from, date_to, website_id, columns, filters = NULL, metric_filters = NULL, offset = 0, max_lines = 0 )
build_query( date_from, date_to, website_id, columns, filters = NULL, metric_filters = NULL, offset = 0, max_lines = 0 )
date_from |
Start date of query |
date_to |
End date of query |
website_id |
website_id from piwik |
columns |
tibble containing columns and transformations (metrics and dimensions) |
filters |
list containing filter, best built by
|
metric_filters |
list containing filter, best built by
|
offset |
offset |
max_lines |
limit |
query as list
columns <- tibble::tribble( ~column, ~transformation, "event_url", "to_path", "event_url", "to_domain", "website_name", "", "timestamp", "", "timestamp", "to_hour_of_day", "page_views", "" ) build_query(lubridate::ymd("2021-01-01"), lubridate::ymd("2021-01-19"), "xxx", columns)
columns <- tibble::tribble( ~column, ~transformation, "event_url", "to_path", "event_url", "to_domain", "website_name", "", "timestamp", "", "timestamp", "to_hour_of_day", "page_views", "" ) build_query(lubridate::ymd("2021-01-01"), lubridate::ymd("2021-01-19"), "xxx", columns)
get_app_detail fetching details about an app
get_app_detail(token, app)
get_app_detail(token, app)
token |
login token generated by |
app |
app id, see |
data.frame with details about the app
get_apps_list fetch all apps
get_apps_list(token)
get_apps_list(token)
token |
login token generated by |
data.frame
Convert column-type according to column_name
get_column_type(column_name, timestamp_to_date = TRUE)
get_column_type(column_name, timestamp_to_date = TRUE)
column_name |
string |
timestamp_to_date |
boolean convert timestamp to date |
string suggested type of column
get_generic_list fetches all rows of a given api
get_generic_list(token, offset, api_endpoint, columns, datetime_columns)
get_generic_list(token, offset, api_endpoint, columns, datetime_columns)
token |
login token generated by |
offset |
defailt 0, integer, where to start fetching usergroups |
api_endpoint |
string with api endpoint |
columns |
vector of strings containing columnnames |
datetime_columns |
vector of strings containing columnnames which are converted to datetime |
data.frame
Fetch login token
get_login_token(credentials)
get_login_token(credentials)
credentials |
List with fields client_id, client_secret and url |
List with login_token
get_metasites_list
get_metasites_list(token)
get_metasites_list(token)
token |
login token generated by |
data.frame
get_permissions_for_app
get_permissions_for_app(token, app)
get_permissions_for_app(token, app)
token |
login token generated by |
app |
app id, see |
data.frame
get_permissions_for_metasite
get_permissions_for_metasite(token, metasite)
get_permissions_for_metasite(token, metasite)
token |
login token generated by |
metasite |
app id, see |
data.frame
Fills credentials out of ENV into a list
get_test_credentials()
get_test_credentials()
list
get_usergroup_members
get_usergroup_members(token, usergroup_id)
get_usergroup_members(token, usergroup_id)
token |
login token generated by |
usergroup_id |
usergroup (see |
data.frame
get_usergroups_list fetch all usergroups
get_usergroups_list(token)
get_usergroups_list(token)
token |
login token generated by |
data.frame
get_users_list fetch all users
get_users_list(token)
get_users_list(token)
token |
login token generated by |
data.frame
is_column_a_metric Checks if column_name indicates numeric values Uses https://developers.piwik.pro/en/latest/custom_reports/columns.html
is_column_a_metric(column_name)
is_column_a_metric(column_name)
column_name |
string |
boolean
Maximum number of lines requested in Analytics-API
MAX_LINES_PER_REQUEST_ANALYTICS_API()
MAX_LINES_PER_REQUEST_ANALYTICS_API()
int
Maximum number of lines requested in Users-API
MAX_LINES_PER_REQUEST_USERS_API()
MAX_LINES_PER_REQUEST_USERS_API()
int
Ask package specific question during release-process
release_questions()
release_questions()
vector of strings
Send the query and receive the result
send_query( query, token, use_csv = TRUE, fetch_by_day = FALSE, api = "query", caching = FALSE, caching_dir = "cache", convert_types = TRUE )
send_query( query, token, use_csv = TRUE, fetch_by_day = FALSE, api = "query", caching = FALSE, caching_dir = "cache", convert_types = TRUE )
query |
list generated by |
token |
login token generated by |
use_csv |
logical to choose whether to fetch data via extra csv-request |
fetch_by_day |
logical fetch data day by day |
api |
API endpoint ("query", "sessions", "events") |
caching |
logical Set TRUE to enable caching |
caching_dir |
character Set directory for saving caching data, default cache |
convert_types |
logical guess type of columns and set them |
result as tibble
Send the query and receive the result
send_query_single(query, token, use_csv, api, caching, caching_dir)
send_query_single(query, token, use_csv, api, caching, caching_dir)
query |
list generated by build_query() |
token |
login token |
use_csv |
logical to choose whether to fetch data via extra csv-request |
api |
API endpoint (query, sessions, events) |
caching |
logical Set TRUE to enable caching |
caching_dir |
character Set directory for saving caching data |
result as list with values data and meta