gtm_variables_create {googleTagManageR} | R Documentation |
Create a new variable
Description
This takes a variable resource and creates a new variable in GTM.
Usage
gtm_variables_create(account_id, container_id, workspace_id, variable_object)
Arguments
account_id |
Account Id |
container_id |
Container Id |
workspace_id |
Workspace Id |
variable_object |
Variable Object |
See Also
Other variable functions:
gtm_variables_delete()
,
gtm_variables_get()
,
gtm_variables_list()
,
gtm_variables_revert()
,
gtm_variables_update()
Examples
## Not run:
accountId <- 1234567
containerId <- 7654321
workspaceId <- 3
variable <- list(
name = 'Custom JS Variable',
type = 'jsm',
parameter = list(
list(
type = 'template',
key = 'javascript',
value = 'function(){\n return document.querySelector(\"form\").id;\n}'
)
)
)
cjsVariable <- gtm_variables_create(accountId, containerId, workspaceId, variable)
variable2 <- list(
name = 'Lookup Table',
type = 'smm',
parameter = list(
list(
type = 'boolean',
key = 'setDefaultValue',
value = 'false'
),
list(
type = 'template',
key = 'input',
value = '{{Page Hostname}}'
),
list(
type = 'list',
key = 'map',
list = list(
list(
type = 'map',
map = list(list(
type = 'template',
key = 'key',
value = 'google.co.uk'
),
list(
type = 'template',
key = 'value',
value = 'UA-123456-1'
)
)
),
list(
type = 'map',
map = list(list(
type = 'template',
key = 'key',
value = 'bing.com'
),
list(
type = 'template',
key = 'value',
value = 'UA-123456-2'
)
)
)
)
)
)
)
lookupTable <- gtm_variables_create(accountId, containerId, workspaceId, variable2)
## End(Not run)
[Package googleTagManageR version 0.2.0 Index]