-
Notifications
You must be signed in to change notification settings - Fork 2
/
ga-customdimensions.php
143 lines (126 loc) · 5.83 KB
/
ga-customdimensions.php
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!--
This Original Work is copyright of 51 Degrees Mobile Experts Limited.
Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
This Original Work is licensed under the European Union Public Licence (EUPL)
v.1.2 and is subject to its terms as set out below.
If a copy of the EUPL was not distributed with this file, You can obtain
one at https://opensource.org/licenses/EUPL-1.2.
The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
amended by the European Commission) shall be deemed incompatible for
the purposes of the Work and the provisions of the compatibility
clause in Article 5 of the EUPL shall not apply.
-->
<!-- Following enabledButton variable and 51D.js needs to be populated at the load of this page only. -->
<script type="text/javascript">var enabledButton = "<?php echo esc_html( get_option("fiftyonedegrees_ga_enable_tracking") ); ?>";</script>
<?php
if (!get_option(Options::GA_TOKEN) &&
empty(get_option(Options::GA_TOKEN))) {
echo '<span class="fod-pipeline-status error">' .
'Please Authenticate with Google Analytics first.</span>';
}
else {
if (get_option(Options::PIPELINE)['error']) {
echo '<p></p><span class="fod-pipeline-status error">' .
'Provided Resource Key does not contain any Custom Dimensions.' .
' Please enter a valid Resource Key. </span>';
}
else if (get_option(Options::GA_ERROR)) {
echo '<p></p><span class="fod-pipeline-status warn">' .
esc_html(get_option(Options::GA_ERROR)) . '</span>';
delete_option(Options::GA_ERROR);
}
else if (get_option(Options::ENABLE_GA)) {
if (get_option(Options::RESOURCE_KEY_UPDATED) ||
get_option(Options::GA_ID_UPDATED) ||
get_option(Options::GA_SEND_PAGE_VIEW_UPDATED) ||
get_option(Options::GA_DIMENSIONS)) {
// Include Fiftyonedegrees class
if (!class_exists('Fiftyonedegrees')) {
require_once('fiftyonedegrees.php');
}
$instance = Fiftyonedegrees::get_instance();
$instance->execute_ga_tracking_steps();
if (get_option(Options::RESOURCE_KEY_UPDATED)) {
echo '<p></p><span class="fod-pipeline-status good">' .
'Google Analytics Tracking is enabled for the Properties' .
' available in the new Resource Key. </span>';
delete_option(Options::RESOURCE_KEY_UPDATED);
}
else if (get_option(Options::GA_DIMENSIONS_UPDATED)) {
echo '<p></p><span class="fod-pipeline-status good">' .
'Google Analytics Custom Dimensions mapping has been updated.</span>';
delete_option(Options::GA_DIMENSIONS_UPDATED);
}
else {
echo '<p></p><span class="fod-pipeline-status good">' .
'Google Analytics Tracking is enabled for new Google ' .
'Analytics Property Settings.</span>';
delete_option(Options::GA_ID_UPDATED);
delete_option(Options::GA_SEND_PAGE_VIEW_UPDATED);
}
}
else {
echo '<p></p><span class="fod-pipeline-status good">' .
'Google Analytics Custom Dimensions data collection is ' .
'now enabled for you. </span>';
}
}
if (!get_option(Options::PIPELINE)['error']) {
?>
<form method="post" action="options.php">
<table style="height: 50%">
<tbody>
<tr>
<td>
<p>
The following properties are available with the provided
Resource Key. Please Click
<b>Enable Google Analytics Tracking</b> to send them as
Custom Dimensions to
<b>
<?php echo esc_html(get_option(Options::GA_TRACKING_ID));?>
</b>
Google Analytics Property or <b>Go Back</b> to change.
</p>
</td>
<td>
<button type="submit" class="button-primary" name="fiftyonedegrees_ga_change_settings">
<span style="font-size:16px;">«</span> Go Back</i>
</button>
</td>
</tr>
</tbody>
</table>
</form>
<?php
// Include Custom_Dimensions class
if (!class_exists('Fiftyonedegrees_Custom_Dimensions')) {
require_once('includes/ga-custom-dimension-class.php');
}
//Prepare Custom Dimensions Table
$customDimensionsTable = new Fiftyonedegrees_Custom_Dimensions();
$customDimensionsTable->prepare_items();
?>
<form method="post" action="options.php">
<?php $customDimensionsTable->display();?>
<table style="width: 100%">
<tbody>
<tr>
<?php if ("enabled" !== get_option(Options::ENABLE_GA)) { ?>
<td style="width: 90%">
<input type="submit" class="button-primary" value="Enable Google Analytics Tracking" name="<?php echo Options::ENABLE_GA; ?>" />
</td>
<?php } else { ?>
<td style="width: 90%">
<input type="submit" class="button-primary" value="Disable Google Analytics Tracking" name="<?php echo Options::ENABLE_GA; ?>" />
</td>
<?php } ?>
<td>
<input type="submit" class="button-primary" value="Update Custom Dimension Mappings" name="<?php echo "fiftyonedegrees_ga_update_cd_indices"; ?>" />
</td>
</tr>
</tbody>
</table>
</form>
<?php } } ?>