ga_goal_add: Create a new goal.

Description Usage Arguments Value See Also Examples

View source: R/goal_management.R

Description

Create a new goal.

Usage

1
ga_goal_add(Goal, accountId, webPropertyId, viewId)

Arguments

Goal

The Goal object to be added to the view. See examples.

accountId

Account Id of the account to add the Goal to

webPropertyId

Property Id of the property to add the Goal to

viewId

View Id of the view to add the Goal to

Value

The Goal object

See Also

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/#Goals

Other goal management functions: ga_goal_list(), ga_goal_update(), ga_goal()

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
## Not run: 

## Create a Goal object based on destination:
Goal <- list(
  id = '17',
  active = TRUE,
  name = 'Checkout',
  type = 'URL_DESTINATION',
  urlDestinationDetails = list(
    url = '\\/checkout\\/thank_you',
    matchType = 'REGEX',
    caseSensitive = FALSE,
    firstStepRequired = FALSE,
    steps = list(
      list(
        number = 1,
        name = 'Product',
        url = '\\/products\\/'
      ),
      list(
        number = 2,
        name = 'Cart',
        url = '\\/cart'
      ),
      list(
        number = 3,
        name = 'Contact',
        url = '\\/checkout\\/contact_information'
      ),
      list(
        number = 4,
        name = 'Shipping',
        url = '\\/checkout\\/shipping'
      ),
      list(
        number = 5,
        name = 'Payment',
        url = '\\/checkout\\/payment'
      ),
      list(
        number = 6,
        name = 'Processing',
        url = '\\/checkout\\/processing'
      )
    )
  )
)

## Create a Goal object based on an event:
Goal <- list(
  id = '9',
  active = TRUE,
  name = 'PDF Download',
  type = 'EVENT',
  eventDetails = list(
    useEventValue = TRUE,
    eventConditions = list(
      list(
        type = 'CATEGORY',
        matchType = 'EXACT',
        expression = 'PDF Download'
        ),
      list(
        type = 'LABEL',
        matchType = 'EXACT',
        expression = 'January brochure'
        )
      )
    )
  )
  
## Create a Goal object based on a number of pages visitied in a session:  
Goal <- list(
  id = '10',
  active = TRUE,
  name = 'Visited more than 3 pages',
  type = 'VISIT_NUM_PAGES',
  visitNumPagesDetails = list(
    comparisonType = 'GREATER_THAN',
    comparisonValue = 3
  )
)
  
## Create a Goal object based on the number of seconds spent on the site  
Goal <- list(
  id = '11',
  active = TRUE,
  name = 'Stayed for more than 2 minutes',
  type = 'VISIT_TIME_ON_SITE',
  visitTimeOnSiteDetails = list(
    comparisonType = 'GREATER_THAN',
    comparisonValue = 120
  )
)

## End(Not run)
  

googleAnalyticsR documentation built on April 17, 2021, 5:06 p.m.