View source: R/filter_management.R
ga_filter_add | R Documentation |
Take a filter object and add and/or apply it so its live.
ga_filter_add(
Filter,
accountId,
webPropertyId = NULL,
viewId = NULL,
linkFilter = FALSE
)
Filter |
The Filter object to be added to the account or view. See examples. |
accountId |
Account Id of the account to add the Filter to |
webPropertyId |
Property Id of the property to add the Filter to |
viewId |
View Id of the view to add the Filter to |
linkFilter |
If TRUE will apply the Filter to the view. Needs propetyId and viewId to be set. |
If you don't set linkFilter=TRUE
then the filter will only be created but not applied.
You will find it listed in the admin panel Account > All Filters. You can then use ga_filter_apply_to_view to apply later on.
The filterId created if linkFilter=FALSE
or a Filter object if linkFilter=TRUE
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/#Filters
Other managementAPI functions:
ga_experiment()
,
ga_experiment_list()
,
ga_filter_apply_to_view()
,
ga_filter_update()
,
ga_filter_update_filter_link()
,
ga_segment_list()
## Not run:
## Create a filter object for adding an IP exclusion:
Filter <- list(
name = 'Exclude Internal Traffic',
type = 'EXCLUDE',
excludeDetails = list(
field = 'GEO_IP_ADDRESS',
matchType = 'EQUAL',
expressionValue = '199.04.123.1',
caseSensitive = 'False'
)
)
# create and add the filter to the view specified
my_filter <- ga_filter_add(Filter,
accountId = 12345,
webPropertyId = "UA-12345-1",
viewId = 654321,
linkFilter = TRUE)
# only create the filter, don't apply it to any view - returns filterId for use later
my_filter <- ga_filter_add(Filter,
accountId = 12345,
linkFilter = FALSE)
## Other examples of filters you can create below:
## Create a filter object for making campaign medium lowercase
Filter <- list(
name = 'Lowercase Campaign Medium',
type = 'LOWERCASE',
lowercaseDetails = list(
field = 'CAMPAIGN_MEDIUM'
)
)
## Create a filter object to append hostname to URI
Filter <- list(
name = 'Append hostname to URI',
type = 'ADVANCED',
advancedDetails = list(
fieldA = 'PAGE_HOSTNAME',
extractA = '(.*)',
fieldARequired = 'True',
fieldB = 'PAGE_REQUEST_URI',
extractB = '(.*)',
fieldBRequired = 'False',
outputConstructor = '$A1$B1',
outputToField = 'PAGE_REQUEST_URI',
caseSensitive = 'False',
overrideOutputField = 'True'
)
)
## Create a filter object to add www hostname without it
Filter <- list(
name = 'Search and Replace www',
type = 'SEARCH_AND_REPLACE',
searchAndReplaceDetails = list(
field = 'PAGE_HOSTNAME',
searchString = '^exampleUSA\\.com$',
replaceString = 'www.exampleUSA.com',
caseSensitive = 'False'
)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.