start_test: Start a GTmetrix test (and get the result)

Description Usage Arguments Value Examples

View source: R/start_test.R

Description

start_test starts a GTmetrix test and returns either the test itself (incl. meta data) or the associated report.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
start_test(
  url,
  api_key,
  wait_for_completion = TRUE,
  location = 1,
  browser = 3,
  report = "lighthouse",
  retention = 1,
  httpauth_username = NULL,
  httpauth_password = NULL,
  adblock = 0,
  cookies = NULL,
  video = 0,
  stop_onload = 0,
  throttle = NULL,
  allow_url = NULL,
  block_url = NULL,
  dns = NULL,
  simulate_device = NULL,
  user_agent = NULL,
  browser_width = NULL,
  browser_height = NULL,
  browser_dppx = NULL,
  browser_rotate = NULL
)

Arguments

url

The URL of the page to test. (string)

api_key

An active GTmetrix API key (string)

wait_for_completion

Whether the function should wait for the completion of the test. If TRUE (default), the report associated with the test ID will be requested in roughly 3 second intervals and returned, when successful. If FALSE, the meta data of the test will be returned. (TRUE, FALSE)

location

Location ID. Default = "1"

browser

Location ID. Default = "3"

report

A string for the type of report. "lighthouse" (default) for 'Lighthouse', "legacy" for 'PageSpeed'/'YSlow', "lighthouse,legacy" for both, "none" for a metrics-only report.

retention

Choose how long (in months) the report will be retained and accessible. Valid values: 1 (default), 6, 12, 24.

httpauth_username

Username for the test page HTTP access authentication. (string)

httpauth_password

Password for the test page HTTP access authentication. (string)

adblock

Enable AdBlock. 0 (default) = no, 1 = yes.

cookies

Specify cookies to supply with test page requests.

video

Enable generation of video. 0 (default) = no, 1 = yes

stop_onload

Stop the test at 'window.onload' instead of after the page has fully loaded (i.e. 2 seconds of network inactivity). 0 (default) = no, 1 = yes

throttle

Throttle the connection. Speed measured in Kbps, latency in ms. Format: "up/down/latency"

allow_url

Only load resources that match one of the URLs on this list. This uses the same syntax as the web front end.

block_url

Prevent loading of resources that match one of the URLs on this list. This occurs after the Only Allow URLs are applied. This uses the same syntax as the web front end.

dns

Use a custom DNS host and IP to run the test with.

simulate_device

Simulate the display of your site on a variety of devices using a pre-selected combination of Screen Resolutions, User Agents, and Device Pixel Ratios. (Expected: Device ID)

user_agent

Use a custom User Agent string.

browser_width

Set the width of the viewport for the analysis. Also requires browser_height to be set.

browser_height

Set the height of the viewport for the analysis. Also requires browser_width to be set.

browser_dppx

Set the device pixel ratio for the analysis. Decimals are allowed.

browser_rotate

Swaps the width and height of the viewport for the analysis. simulate_device overrides this parameter with preset values.

Value

A data.frame object that contains either the test meta data or the GTmetrix report (if it's already completed).

Examples

1
2
3
4
5
6
## Not run: output_table <- start_test(
                           url = "google.com",
                           api_key = "API_KEY",
                           wait_for_completion = TRUE
                         )
## End(Not run)

rgtmx documentation built on Nov. 12, 2021, 1:08 a.m.