-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgtm.admin.inc
64 lines (60 loc) · 1.72 KB
/
gtm.admin.inc
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
<?php
/**
* @file
* Admin callbacks for the Google Tag Manager module.
*/
/**
* Admin settings form.
*/
function gtm_admin_settings_form($form) {
$user_roles = user_roles();
$form = array();
$form['gtm'] = array(
'#type' => 'textfield',
'#title' => t('Google Tag Manager ID'),
'#default_value' => variable_get('gtm', ''),
'#attributes' => array(
'placeholder' => 'GTM-XXXX'
),
'#size' => 10,
'#required' => TRUE,
'#suffix' => t(
'<small>If you do not already have a Google Tag Manager Account, create here one: !link</small>',
array(
'!link' => l(
t('Google Tag Manager'),
'https://www.google.com/tagmanager',
array(
'attributes' => array(
'target' => '_blank',
),
)
),
)
),
);
$form['datalayer'] = array(
'#prefix' => '<br /><br />',
'#type' => 'textfield',
'#title' => t('dataLayer Variable Name'),
'#default_value' => variable_get('datalayer', 'dataLayer'),
'#description' => t('The variable name which should be used to instantiate the GTM dataLayer'),
'#required' => TRUE,
'#size' => 20,
);
$form['roles'] = array(
'#type' => 'fieldset',
'#title' => t('User Role Tracking'),
'#collapsible' => TRUE,
'#description' => t('Define what user roles should be tracked by Google.'),
);
foreach ($user_roles as $user_role) {
$role = str_replace(' ', '_', $user_role);
$form['roles']['gtm_track_' . $role] = array(
'#type' => 'checkbox',
'#title' => t('@user_role', array('@user_role' => $user_role)),
'#default_value' => variable_get('gtm_track_' . $role, FALSE),
);
}
return system_settings_form($form);
}