if (FALSE) {
## 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'
)
)
}
Run the code above in your browser using DataLab