ga_collect_pageview: Send pageviews to Google Analytics

Description Usage Arguments Value Examples

Description

Send pageviews to Google Analytics. If someone visits a page, use this function to send the page and title of the page which is visited so that you can easily see how users are using your application.

Pageviews can be viewed in the Google Analytics > Behaviour tab or in the Real-Time part of Google Analytics.

Usage

1
2
ga_collect_pageview(page = "/home", title = page,
  hostname = galog$hostname)

Arguments

page

a character string with the page which was visited

title

a character string with the title of the page which was visited

hostname

a character string with the hostname. Defaults to the environment variable GALOG_HOSTNAME and if not set uses 'GAlogger'.

Value

invisibly the result of a call to curl_fetch_memory which sends the data to Google Analytics or an object of try-error if the internet is not working

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ga_set_tracking_id("UA-25938715-4")
ga_set_approval(consent = TRUE)

ga_collect_pageview(page = "/home")
ga_collect_pageview(page = "/simulation", title = "Mixture process")
ga_collect_pageview(page = "/simulation/bayesian")
ga_collect_pageview(page = "/textmining-exploratory")
ga_collect_pageview(page = "/my/killer/app")

x <- ga_collect_pageview(page = "/home", title = "Homepage", hostname = "www.xyz.com")
x$status_code

bnosac/GAlogger documentation built on May 23, 2019, 6:05 a.m.