fetch_traffic_for_ms: Download traffic data for a page with the given URL on the...

Description Usage Arguments Value

View source: R/microsite-traffic.R

Description

fetch_traffic_for_ms downloads data on traffic metrics for a given url on the Commons Library microsite during the given dates and returns the data as a tibble.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fetch_traffic_for_ms(
  url,
  start_date,
  end_date,
  match_exact = FALSE,
  internal = FALSE,
  by_date = FALSE,
  anti_sample = FALSE,
  use_resource_quotas = FALSE
)

Arguments

url

The URL of a page for which traffic data is requested.

start_date

The start date as an ISO 8601 string.

end_date

The end date as an ISO 8601 string.

match_exact

A boolean indicating whether to match only pages with the exact URL or pages which start with the URL. In general, if you need traffic data for individual insights and research briefings you don't want to use an exact match, as it will exclude requests for the page that contained query strings, which are sometimes used for tracking marketing campaigns. However, when fetching traffic data for category pages an exact match is necessary to exclude other pages with same URL stem. The default is FALSE.

internal

A boolean indicating whether to return only the results for traffic from internal parliamentary networks. The default is FALSE.

by_date

A boolean indicating whether to return the results broken down by date. The default is FALSE.

anti_sample

A boolean indicating whether to use googleAnalyticsR's anti-sample feature, which chunks API calls to keep the number of records requested under the API limits that trigger sampling. This makes the download process slower but ensures that all records are returned. Only use this feature if you see that an API request triggers sampling without it. The default is FALSE.

use_resource_quotas

A boolean indicating whether to use the resource quotas in Parliament's Google Analytics account to prevent sampling. This is a faster and more effective way to disable sampling than using anti_sample, but using resource quotas consumes tokens from a limited daily quota. Use this when anti_sample still fails to prevent sampling or is taking too long. Note that using resource quotas takes precendence over anti-samping: if use_resource_quotas is TRUE anti_sample is automatically set to FALSE. The default is FALSE.

Value

A tibble of traffic metrics.


olihawkins/clga documentation built on Sept. 17, 2020, 7:19 a.m.