The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Access 'Piwik Pro' Website Statistics
Date: 2022-08-29
Version: 0.4.0
Author: Martin Stingl <martin.stingl@dfv.de>
Maintainer: Martin Stingl <martin.stingl@dfv.de>
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.
URL: https://piwikpror.rstats-tips.net
BugReports: https://github.com/dfv-ms/piwikproR/issues
License: GPL (≥ 3)
Encoding: UTF-8
Imports: httr, rjson, tibble, purrr, lubridate, magrittr, dplyr, rlang, stringr, readr (≥ 2.1.0), digest, fs, tidyr, glue
RoxygenNote: 7.2.1
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2022-08-31 18:47:13 UTC; stingl
Repository: CRAN
Date/Publication: 2022-09-01 09:10:38 UTC

Maximum number of lines requested in Analytics-API

Description

Maximum number of lines requested in Analytics-API

Usage

MAX_LINES_PER_REQUEST_ANALYTICS_API()

Value

int


Maximum number of lines requested in Users-API

Description

Maximum number of lines requested in Users-API

Usage

MAX_LINES_PER_REQUEST_USERS_API()

Value

int


Convert column-type according to column_name

Description

Convert column-type according to column_name

Usage

apply_types(data, timestamp_to_date = TRUE)

Arguments

data

tibble

timestamp_to_date

boolean convert timestamp to date

Value

tibble


Build filter from tribble

Description

Build filter from tribble

Usage

build_filter(filters, global_operator = "and")

Arguments

filters

tribble with columns

  • column

  • operator

  • value

Possible values for operator:

  • (not_)contains

  • (not_)icontains

  • start_with

  • ends_with

  • (not_)matches

  • eq

  • neq

  • (not_)empty

global_operator

"and" or "or"

Value

filter json encoded to feed to build_query

Examples

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

Description

Build the query

Usage

build_query(
  date_from,
  date_to,
  website_id,
  columns,
  filters = NULL,
  metric_filters = NULL,
  offset = 0,
  max_lines = 0
)

Arguments

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 build_filter

metric_filters

list containing filter, best built by build_filter

offset

offset

max_lines

limit

Value

query as list

Examples

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

Description

get_app_detail fetching details about an app

Usage

get_app_detail(token, app)

Arguments

token

login token generated by get_login_token

app

app id, see get_apps_list

Value

data.frame with details about the app


get_apps_list fetch all apps

Description

get_apps_list fetch all apps

Usage

get_apps_list(token)

Arguments

token

login token generated by get_login_token

Value

data.frame


Convert column-type according to column_name

Description

Convert column-type according to column_name

Usage

get_column_type(column_name, timestamp_to_date = TRUE)

Arguments

column_name

string

timestamp_to_date

boolean convert timestamp to date

Value

string suggested type of column


get_generic_list fetches all rows of a given api

Description

get_generic_list fetches all rows of a given api

Usage

get_generic_list(token, offset, api_endpoint, columns, datetime_columns)

Arguments

token

login token generated by get_login_token

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

Value

data.frame


Fetch login token

Description

Fetch login token

Usage

get_login_token(credentials)

Arguments

credentials

List with fields client_id, client_secret and url

Value

List with login_token


get_metasites_list

Description

get_metasites_list

Usage

get_metasites_list(token)

Arguments

token

login token generated by get_login_token

Value

data.frame


get_permissions_for_app

Description

get_permissions_for_app

Usage

get_permissions_for_app(token, app)

Arguments

token

login token generated by get_login_token

app

app id, see get_apps_list

Value

data.frame


get_permissions_for_metasite

Description

get_permissions_for_metasite

Usage

get_permissions_for_metasite(token, metasite)

Arguments

token

login token generated by get_login_token

metasite

app id, see get_metasites_list

Value

data.frame


get_test_credentials getting credentials for testing

Description

Fills credentials out of ENV into a list

Usage

get_test_credentials()

Value

list


get_usergroup_members

Description

get_usergroup_members

Usage

get_usergroup_members(token, usergroup_id)

Arguments

token

login token generated by get_login_token

usergroup_id

usergroup (see get_usergroups_list)

Value

data.frame


get_usergroups_list fetch all usergroups

Description

get_usergroups_list fetch all usergroups

Usage

get_usergroups_list(token)

Arguments

token

login token generated by get_login_token

Value

data.frame


get_users_list fetch all users

Description

get_users_list fetch all users

Usage

get_users_list(token)

Arguments

token

login token generated by get_login_token

Value

data.frame


is_column_a_metric Checks if column_name indicates numeric values Uses https://developers.piwik.pro/en/latest/custom_reports/columns.html

Description

is_column_a_metric Checks if column_name indicates numeric values Uses https://developers.piwik.pro/en/latest/custom_reports/columns.html

Usage

is_column_a_metric(column_name)

Arguments

column_name

string

Value

boolean


Ask package specific question during release-process

Description

Ask package specific question during release-process

Usage

release_questions()

Value

vector of strings


Send the query and receive the result

Description

Send the query and receive the result

Usage

send_query(
  query,
  token,
  use_csv = TRUE,
  fetch_by_day = FALSE,
  api = "query",
  caching = FALSE,
  caching_dir = "cache",
  convert_types = TRUE
)

Arguments

query

list generated by build_query

token

login token generated by get_login_token

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

Value

result as tibble


Send the query and receive the result

Description

Send the query and receive the result

Usage

send_query_single(query, token, use_csv, api, caching, caching_dir)

Arguments

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

Value

result as list with values data and meta

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.