Learn R Programming

ganalytics (version 0.10.7)

Segments: Segments

Description

Get the list of segments from the object or coerce the supplied objects into a a named list of segments.

Set the segments of the query object.

Usage

Segments(object, ...)

Segments(object) <- value

# S4 method for gaSegmentList Segments(object)

# S4 method for gaQuery Segments(object)

# S4 method for ANY Segments(object)

# S4 method for gaQuery Segments(object) <- value

Arguments

object

A query object to get the segment list from or to set the segment list of.

...

Alternatively, provide one or more named arguments (segments or objects that can be coerced into segments) including dynamic segments, built-in and/or custom segments by their ID.

value

A named list of segments or a single segment.

Value

A gaSegmentList

Methods (by class)

  • gaSegmentList: Returns itself

  • gaQuery: Return the definition of the segment applied to the view.

  • ANY: Coerce an object into a segmentList of length 1.

  • gaQuery: Set the segments to be used within a query.

See Also

Other dynamic segment functions: DynSegment, Exclude, Include, IsNegated, PerHit, PerProduct, PerSession, PerUser, ScopeLevel, SegmentConditionFilter, Segment

Other dynamic segment functions: DynSegment, Exclude, Include, IsNegated, PerHit, PerProduct, PerSession, PerUser, ScopeLevel, SegmentConditionFilter, Segment

Examples

Run this code
# NOT RUN {
my_segments <- Segments(list(
  bounces = PerSession(Expr(~bounces != 0)),
  conversions = PerUser(Expr(~goalCompletionsAll > 0) | Expr(~transactions > 0)),
  mobile_or_tablet = Expr(~deviceCategory %in% c("mobile", "tablet")),
  multi_session_users = Include(PerUser(Expr(~sessions > 1)), scope = "users"),
  new_desktop_users = Expr(~deviceCategory == "desktop") & Expr(~userType == "new")
))

my_query <- GaQuery(view = "987654321")
my_segments_list <- list(
  bounces = PerSession(Expr(~bounces != 0)),
  conversions = PerUser(Expr(~goalCompletionsAll > 0) | Expr(~transactions > 0)),
  mobile_or_tablet = Expr(~deviceCategory %in% c("mobile", "tablet")),
  multi_session_users = Include(PerUser(Expr(~sessions > 1)), scope = "users"),
  new_desktop_users = Expr(~deviceCategory == "desktop") & Expr(~userType == "new")
)
Segments(my_query) <- my_segments_list

# }

Run the code above in your browser using DataLab