gtm_variables_create | R Documentation |
This takes a variable resource and creates a new variable in GTM.
gtm_variables_create(account_id, container_id, workspace_id, variable_object)
account_id |
Account Id |
container_id |
Container Id |
workspace_id |
Workspace Id |
variable_object |
Variable Object |
Other variable functions:
gtm_variables_delete()
,
gtm_variables_get()
,
gtm_variables_list()
,
gtm_variables_revert()
,
gtm_variables_update()
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.