filter_clause_ga4: Make a dimension or metric filter clause object

Description Usage Arguments Details Value See Also Examples

View source: R/filters.R

Description

Make a dimension or metric filter clause object

Usage

1
filter_clause_ga4(filters, operator = c("OR", "AND"))

Arguments

filters

a list of dim_filter or met_filter. Only one type allowed.

operator

combination of filter.

Details

If you have dimension and metric filters, make the clauses in two separate calls, then pass the objects to make_ga_4_req

Value

An object of class dim_fil_ga4 or met_fil_ga4 for use in make_ga_4_req

See Also

Other filter functions: dim_filter(), met_filter()

Examples

 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
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 
library(googleAnalyticsR)

## authenticate,
## or use the RStudio Addin "Google API Auth" with analytics scopes set
ga_auth()

## get your accounts
account_list <- google_analytics_account_list()

## pick a profile with data to query

ga_id <- account_list[23,'viewId']

## create filters on metrics
mf <- met_filter("bounces", "GREATER_THAN", 0)
mf2 <- met_filter("sessions", "GREATER", 2)

## create filters on dimensions
df <- dim_filter("source","BEGINS_WITH","1",not = TRUE)
df2 <- dim_filter("source","BEGINS_WITH","a",not = TRUE)

## construct filter objects
fc2 <- filter_clause_ga4(list(df, df2), operator = "AND")
fc <- filter_clause_ga4(list(mf, mf2), operator = "AND")

## make v4 request
ga_data1 <- google_analytics(ga_id,
                             date_range = c("2015-07-30","2015-10-01"),
                             dimensions=c('source','medium'),
                             metrics = c('sessions','bounces'),
                             met_filters = fc,
                             dim_filters = fc2,
                             filtersExpression = "ga:source!=(direct)")


## End(Not run)

MarkEdmondson1234/googleAnalyticsR_public documentation built on Oct. 22, 2020, 4:04 a.m.