View source: R/user-activity.R
ga_clientid_activity | R Documentation |
Get activity on an individual user
ga_clientid_activity(
ids,
viewId,
id_type = c("CLIENT_ID", "USER_ID"),
activity_type = NULL,
date_range = NULL
)
ids |
The userId or clientId. You can send in a vector of them |
viewId |
The viewId |
id_type |
Whether its userId or clientId |
activity_type |
If specified, filters down response to the activity type. Choice between |
date_range |
A vector of start and end dates. If not used will default to a week. |
The User Activity API lets you query an individual user's movement through your website, by sending in the individual clientId
or userId
.
Bear in mind each call will count against your API quota, so fetching a large amount of client ids will be limited by that.
Use ga_clientid_activity_unnest to unnest deeply nested data in the hits data.
The timestamps are available to millisecond level but you will need to set your R options to see them e.g. options(digits.secs=3)
A list of data.frames: $sessions
contains session level data. $hits
contains individual activity data
https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/userActivity/search
Other clientid functions:
ga_clientid_activity_unnest()
,
ga_clientid_deletion()
,
ga_clientid_hash()
## Not run:
# access data for individual users
uar <- ga_clientid_activity(c("1106980347.1461227730", "476443645.1541099566"),
viewId = 81416156,
date_range = c("2019-01-01","2019-02-01"))
# access clientIds for users who have transacted
viewId <- 106249469
date_range <- c("2019-01-01","2019-02-01")
cids <- google_analytics(viewId,
date_range = date_range,
metrics = "sessions",
dimensions = "clientId",
met_filters = filter_clause_ga4(
list(met_filter("transactions",
"GREATER_THAN",
0)
)))
transactors <- ga_clientid_activity(cids$clientId,
viewId = viewId,
date_range = date_range)
# access the data.frames returned:
# the session level data for the users passed in
uar$sessions
# the hit level activity for the users passed in
uar$hits
# filter the response to only include certain activity types, such as goals:
only_goals <- ga_clientid_activity(c("1106980347.1461227730",
"476443645.1541099566"),
viewId = 81416156,
date_range = c("2019-01-01","2019-02-01"),
activity_types = "GOAL")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.