Version Description
Download this release
Release Info
Developer | yuvalo |
Plugin | WP Google Analytics Events |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.9
- css/style.css +54 -0
- ga-scroll-event.php +25 -22
- includes/admin.php +294 -256
- readme.txt +3 -1
css/style.css
CHANGED
@@ -180,3 +180,57 @@ a.btn_close_popup img {
|
|
180 |
right: 10px;
|
181 |
top: 11px;
|
182 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
right: 10px;
|
181 |
top: 11px;
|
182 |
}
|
183 |
+
|
184 |
+
@media only screen and (max-width: 1440px) {
|
185 |
+
|
186 |
+
/* Force table to not be like tables anymore */
|
187 |
+
#ga-events-inputs table,
|
188 |
+
#ga-events-inputs thead,
|
189 |
+
#ga-events-inputs tbody,
|
190 |
+
#ga-events-inputs th,
|
191 |
+
#ga-events-inputs td,
|
192 |
+
#ga-events-inputs tr {
|
193 |
+
display: block;
|
194 |
+
}
|
195 |
+
/* Hide table headers (but not display: none;, for accessibility) */
|
196 |
+
#ga-events-inputs thead tr {
|
197 |
+
position: absolute;
|
198 |
+
top: -9999px;
|
199 |
+
left: -9999px;
|
200 |
+
}
|
201 |
+
|
202 |
+
#ga-events-inputs tr { border: 1px solid #ccc; }
|
203 |
+
|
204 |
+
#ga-events-inputs td {
|
205 |
+
/* Behave like a "row" */
|
206 |
+
border: none;
|
207 |
+
border-bottom: 1px solid #eee;
|
208 |
+
position: relative;
|
209 |
+
padding-left: 50%;
|
210 |
+
white-space: normal;
|
211 |
+
text-align:left;
|
212 |
+
}
|
213 |
+
|
214 |
+
#ga-events-inputs td:before {
|
215 |
+
/* Now like a table header */
|
216 |
+
position: absolute;
|
217 |
+
/* Top/left values mimic padding */
|
218 |
+
top: 6px;
|
219 |
+
left: 6px;
|
220 |
+
width: 45%;
|
221 |
+
padding-right: 10px;
|
222 |
+
white-space: nowrap;
|
223 |
+
text-align:left;
|
224 |
+
font-weight: bold;
|
225 |
+
}
|
226 |
+
|
227 |
+
/*
|
228 |
+
Label the data
|
229 |
+
*/
|
230 |
+
#ga-events-inputs td:before { content: attr(data-title); }
|
231 |
+
}
|
232 |
+
|
233 |
+
.ga-events-help {
|
234 |
+
margin-right: 2px;
|
235 |
+
color: #0085ba;
|
236 |
+
}
|
ga-scroll-event.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Google Analytics Events
|
4 |
Plugin URI: http://wpflow.com
|
5 |
Description: Adds the Google Analytics code to your website and enables you to send events on scroll or click.
|
6 |
-
Version: 1.
|
7 |
Author: Yuval Oren
|
8 |
Author URI: http://wpflow.com
|
9 |
License: GPLv2
|
@@ -45,9 +45,9 @@ function ga_events_install() {
|
|
45 |
'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
|
46 |
'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
|
47 |
);
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
}
|
53 |
|
@@ -88,28 +88,28 @@ function ga_events_header() {
|
|
88 |
|
89 |
ga('create','$id', '$domain');
|
90 |
ga('send', 'pageview');
|
91 |
-
|
92 |
</script>";
|
93 |
} else {
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
|
110 |
</script>";
|
111 |
}
|
112 |
-
|
113 |
}
|
114 |
|
115 |
add_action( 'wp_footer', 'ga_events_footer', 100 );
|
@@ -123,6 +123,7 @@ function ga_events_footer() {
|
|
123 |
$universal = 0;
|
124 |
}
|
125 |
echo "
|
|
|
126 |
<script>
|
127 |
|
128 |
jQuery(document).ready(function() {
|
@@ -158,7 +159,8 @@ function ga_events_footer() {
|
|
158 |
});
|
159 |
});
|
160 |
|
161 |
-
</script>
|
|
|
162 |
|
163 |
|
164 |
}
|
@@ -170,7 +172,8 @@ function ga_events_get_selector($element) {
|
|
170 |
$selector .= str_replace(' ','',$element[0])."',";
|
171 |
$selector .= "'category':'".$element[2]."',";
|
172 |
$selector .= "'action':'".$element[3]."',";
|
173 |
-
$selector .= "'label':'".$element[4]."'";
|
|
|
174 |
$selector .= '}';
|
175 |
return $selector;
|
176 |
}else{
|
3 |
Plugin Name: WP Google Analytics Events
|
4 |
Plugin URI: http://wpflow.com
|
5 |
Description: Adds the Google Analytics code to your website and enables you to send events on scroll or click.
|
6 |
+
Version: 1.9
|
7 |
Author: Yuval Oren
|
8 |
Author URI: http://wpflow.com
|
9 |
License: GPLv2
|
45 |
'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
|
46 |
'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
|
47 |
);
|
48 |
+
if (!get_option('ga_events_options')) {
|
49 |
+
update_option( 'ga_events_options', $ga_events_options );
|
50 |
+
}
|
51 |
|
52 |
}
|
53 |
|
88 |
|
89 |
ga('create','$id', '$domain');
|
90 |
ga('send', 'pageview');
|
91 |
+
}
|
92 |
</script>";
|
93 |
} else {
|
94 |
+
echo "<script type='text/javascript'>
|
95 |
+
if (typeof _gaq === 'undefined') {
|
96 |
+
var _gaq = _gaq || [];
|
97 |
+
_gaq.push(['_setAccount', '$id']);
|
98 |
+
_gaq.push(['_setDomainName', '$domain']);
|
99 |
+
_gaq.push(['_setAllowLinker', true]);
|
100 |
+
_gaq.push(['_trackPageview']);
|
101 |
+
|
102 |
+
(function() {
|
103 |
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
104 |
+
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
|
105 |
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
106 |
+
})();
|
107 |
+
}
|
108 |
|
109 |
|
110 |
</script>";
|
111 |
}
|
112 |
+
}
|
113 |
}
|
114 |
|
115 |
add_action( 'wp_footer', 'ga_events_footer', 100 );
|
123 |
$universal = 0;
|
124 |
}
|
125 |
echo "
|
126 |
+
<!-- BEGIN: wpflow ga events array -->
|
127 |
<script>
|
128 |
|
129 |
jQuery(document).ready(function() {
|
159 |
});
|
160 |
});
|
161 |
|
162 |
+
</script>
|
163 |
+
<!-- END: wpflow ga events array -->";
|
164 |
|
165 |
|
166 |
}
|
172 |
$selector .= str_replace(' ','',$element[0])."',";
|
173 |
$selector .= "'category':'".$element[2]."',";
|
174 |
$selector .= "'action':'".$element[3]."',";
|
175 |
+
$selector .= "'label':'".$element[4]."',";
|
176 |
+
$selector .= "'bounce':'".$element[5]."'";
|
177 |
$selector .= '}';
|
178 |
return $selector;
|
179 |
}else{
|
includes/admin.php
CHANGED
@@ -8,122 +8,119 @@
|
|
8 |
add_action( 'admin_menu', 'ga_events_menu');
|
9 |
|
10 |
function ga_events_menu() {
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
}
|
18 |
|
19 |
function ga_events_settings_page() {
|
20 |
|
21 |
?>
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
<?php
|
28 |
-
|
29 |
-
|
30 |
<h2 class="nav-tab-wrapper">
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
$show_sidebar = true;
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
</div>
|
67 |
<?php
|
68 |
-
|
69 |
?>
|
70 |
<div class="wrap ga_events_sidebar">
|
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 |
-
</div>
|
107 |
<?php }} ?>
|
108 |
|
109 |
|
110 |
<?php
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
}
|
123 |
|
124 |
function load_custom_wp_admin_style() {
|
125 |
-
|
126 |
-
|
127 |
wp_enqueue_script( 'admin-init', plugins_url('js/admin.js', dirname(__FILE__)) , array('jquery'), null, true );
|
128 |
|
129 |
}
|
@@ -146,154 +143,190 @@ function ga_events_admin_init() {
|
|
146 |
}
|
147 |
|
148 |
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
|
164 |
|
165 |
}
|
166 |
|
167 |
function ga_events_section_text() {
|
168 |
-
|
169 |
}
|
170 |
|
171 |
function ga_events_setting_started() {
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
font-size: 15px; max-width:400px;">
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
}
|
191 |
|
192 |
function ga_events_setting_input() {
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
|
198 |
}
|
199 |
|
200 |
|
201 |
function ga_events_setting_snippet_input() {
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
|
207 |
}
|
208 |
|
209 |
function ga_events_setting_uni_input() {
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
}
|
215 |
|
216 |
function ga_events_settings_download(){
|
217 |
-
|
218 |
}
|
219 |
|
220 |
function ga_events_settings_upload(){
|
221 |
-
|
222 |
}
|
223 |
|
224 |
function ga_events_setting_divs_input() {
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
}
|
260 |
|
261 |
|
262 |
function ga_events_setting_click_input() {
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
|
298 |
|
299 |
}
|
@@ -302,31 +335,36 @@ function ga_events_setting_sidebar(){
|
|
302 |
}
|
303 |
|
304 |
function ga_events_validate($form){
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$updated['click'] = array();
|
317 |
-
for ($i = 0, $j = 0; $i< sizeof($form['click']); $i++){
|
318 |
-
if ($form['click'][$i][0]){
|
319 |
-
$updated['click'][$j] = $form['click'][$i];
|
320 |
-
$j++;
|
321 |
-
}
|
322 |
}
|
323 |
-
} else {
|
324 |
-
$updated['id'] = $form['id'];
|
325 |
-
$updated['exclude_snippet'] = $form['exclude_snippet'];
|
326 |
-
$updated['universal'] = $form['universal'];
|
327 |
}
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
}
|
331 |
|
332 |
|
@@ -337,7 +375,7 @@ function ga_events_admin_footer() {
|
|
337 |
<script>
|
338 |
jQuery('body').on('click','a[href="admin.php?page=wp-google-analytics-events-upgrade"]', function (e) {
|
339 |
e.preventDefault();
|
340 |
-
window.open('
|
341 |
});
|
342 |
</script>
|
343 |
<?php
|
@@ -345,45 +383,45 @@ function ga_events_admin_footer() {
|
|
345 |
|
346 |
|
347 |
function ga_events_get_settings(){
|
348 |
-
|
349 |
-
|
350 |
|
351 |
-
|
352 |
}
|
353 |
|
354 |
function ga_events_upload_settings($file){
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
}
|
364 |
|
365 |
function ga_event_get_content($content){
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
|
376 |
}
|
377 |
function ga_event_popup(){
|
378 |
-
|
379 |
echo '<h1>Wrong file format <a href="#" class="btn_close_popup"><img src="'.plugins_url( 'images/close.png', dirname(__FILE__)).'"></a></h1>';
|
380 |
echo "</dev>";
|
381 |
}
|
382 |
function ga_events_file(){
|
383 |
-
|
384 |
header("Content-Disposition: attachment; filename='settings.ini'");
|
385 |
echo ga_events_get_settings();
|
386 |
-
|
387 |
}
|
388 |
|
389 |
?>
|
8 |
add_action( 'admin_menu', 'ga_events_menu');
|
9 |
|
10 |
function ga_events_menu() {
|
11 |
+
add_menu_page('WP Google Analytics Settings','WP GA Events','manage_options', 'wp-google-analytics-events', 'ga_events_settings_page', plugins_url( 'images/icon.png', dirname(__FILE__)));
|
12 |
+
add_submenu_page('wp-google-analytics-events','General Settings','General Settings', 'manage_options', 'wp-google-analytics-events' , 'ga_events_settings_page' );
|
13 |
+
add_submenu_page('wp-google-analytics-events','Click Tracking','Click Tracking', 'manage_options', 'wp-google-analytics-events-click' , 'ga_events_settings_page' );
|
14 |
+
add_submenu_page('wp-google-analytics-events','Scroll Tracking','Scroll Tracking', 'manage_options', 'wp-google-analytics-events-scroll' , 'ga_events_settings_page' );
|
15 |
+
add_submenu_page('wp-google-analytics-events','Getting Started Guide','Getting Started Guide', 'manage_options', 'wp-google-analytics-events-started' , 'ga_events_settings_page' );
|
16 |
+
add_submenu_page('wp-google-analytics-events','Upgrade','Upgrade Now', 'manage_options', 'wp-google-analytics-events-upgrade', 'ga_events_settings_page' );
|
17 |
}
|
18 |
|
19 |
function ga_events_settings_page() {
|
20 |
|
21 |
?>
|
22 |
+
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
23 |
+
<div id="ga_main" class="wrap">
|
24 |
+
<?php screen_icon( 'plugins' ); ?>
|
25 |
+
<h2>GA Scroll Events Plugin</h2>
|
26 |
|
27 |
<?php
|
28 |
+
$active_page = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : 'wp-google-analytics-events';
|
29 |
+
?>
|
30 |
<h2 class="nav-tab-wrapper">
|
31 |
+
<a href="?page=wp-google-analytics-events" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events' ? 'nav-tab-active' : ''; ?>">General Settings</a>
|
32 |
+
<a href="?page=wp-google-analytics-events-click" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events-click' ? 'nav-tab-active' : ''; ?>">Click Tracking</a>
|
33 |
+
<a href="?page=wp-google-analytics-events-scroll" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events-scroll' ? 'nav-tab-active' : ''; ?>">Scroll Tracking</a>
|
34 |
+
<a href="?page=wp-google-analytics-events-started" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events-started' ? 'nav-tab-active' : ''; ?>"><i class="fa fa-question-circle ga-events-help"></i> Getting Started Guide</a>
|
35 |
+
</h2>
|
36 |
+
<?php
|
37 |
+
if ($active_page == 'wp-google-analytics-events-started') {
|
38 |
+
ga_events_setting_started();
|
39 |
+
} else {
|
40 |
+
?>
|
41 |
+
|
42 |
+
<form method="post" action='options.php'>
|
43 |
+
<?php settings_fields('ga_events_options'); ?>
|
44 |
+
<?php
|
45 |
$show_sidebar = true;
|
46 |
+
if ($active_page == 'wp-google-analytics-events-click') {
|
47 |
+
do_settings_sections('ga_events_click');
|
48 |
+
} else if ($active_page == 'wp-google-analytics-events-scroll') {
|
49 |
+
do_settings_sections('ga_events_scroll');
|
50 |
+
}else {
|
51 |
+
do_settings_sections('ga_events');
|
52 |
+
}
|
53 |
+
?>
|
54 |
+
|
55 |
+
<input class="button-primary" type="submit" name="submit" value="Save Changes" />
|
56 |
+
|
57 |
+
</form>
|
58 |
+
<div class="settings_content">
|
59 |
+
<form action="" method="post" enctype="multipart/form-data">
|
60 |
+
<a href="#" class="btn_close"><img src="<?=plugins_url( 'images/close.png', dirname(__FILE__))?>"></a>
|
61 |
+
<input type="file" name="settings">
|
62 |
+
<input type="submit" name="set_settings">
|
63 |
+
</form>
|
64 |
+
</div>
|
65 |
+
</div>
|
|
|
66 |
<?php
|
67 |
+
if ($show_sidebar) {
|
68 |
?>
|
69 |
<div class="wrap ga_events_sidebar">
|
70 |
+
<table class="form-table widefat" >
|
71 |
+
<thead>
|
72 |
+
<th>Upgrade to Pro</th>
|
73 |
+
</thead>
|
74 |
+
<tbody>
|
75 |
+
<tr class="features">
|
76 |
+
<td>
|
77 |
+
<ul>
|
78 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>One Checkbox Link Tracking</strong></li>
|
79 |
+
<li title="Dynamic Event Data"><i class="fa fa-check-square-o fa-lg"></i><strong>Placeholders</strong></li>
|
80 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>YouTube Video Tracking</strong></li>
|
81 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Shortcode support</strong></li>
|
82 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Set Value for Events</strong></li>
|
83 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>HTML Tag support</strong></li>
|
84 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Pro Support</strong></li>
|
85 |
+
</ul>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
<tr class="tfoot">
|
89 |
+
<td>
|
90 |
+
<div class="wpcta">
|
91 |
+
<a class="btn btn-subscribe" target="_blank" href="https://wpflow.com/upgrade?utm_source=wpadm&utm_medium=banner&utm_content=side&utm_campaign=wpadmin
|
92 |
+
">
|
93 |
+
<span class="btn-title ">
|
94 |
+
Upgrade Now
|
95 |
+
</span>
|
96 |
+
</a>
|
97 |
+
</div>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
</tbody>
|
101 |
+
</table>
|
102 |
+
|
103 |
+
</div>
|
|
|
|
|
104 |
<?php }} ?>
|
105 |
|
106 |
|
107 |
<?php
|
108 |
|
109 |
+
echo "<script>
|
110 |
+
jQuery('.remove').click(function (event) {
|
111 |
+
event.preventDefault();
|
112 |
+
jQuery(this).closest('tr').remove();
|
113 |
+
});
|
114 |
+
jQuery('.add').click(function (event) {
|
115 |
+
event.preventDefault();
|
116 |
+
});
|
117 |
+
</script>
|
118 |
+
";
|
119 |
}
|
120 |
|
121 |
function load_custom_wp_admin_style() {
|
122 |
+
wp_register_style( 'custom_wp_admin_css', plugins_url('css/style.css', dirname(__FILE__)));
|
123 |
+
wp_enqueue_style( 'custom_wp_admin_css' );
|
124 |
wp_enqueue_script( 'admin-init', plugins_url('js/admin.js', dirname(__FILE__)) , array('jquery'), null, true );
|
125 |
|
126 |
}
|
143 |
}
|
144 |
|
145 |
|
146 |
+
register_setting('ga_events_options','ga_events_options','ga_events_validate');
|
147 |
+
add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
|
148 |
+
add_settings_section('ga_events_click_section','', 'ga_events_section_text','ga_events_click');
|
149 |
+
add_settings_section('ga_events_scroll_section','', 'ga_events_section_text','ga_events_scroll');
|
150 |
+
add_settings_section('ga_events_started_section','Getting Started Guide', 'ga_events_section_text','ga_events_started');
|
151 |
+
add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
|
152 |
+
add_settings_field('ga_events_exclude_snippet', '','ga_events_setting_snippet_input','ga_events','ga_events_main');
|
153 |
+
add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
|
154 |
+
add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events_scroll','ga_events_scroll_section');
|
155 |
+
add_settings_field('ga_events_started', '','ga_events_setting_started','ga_events_started','ga_events_started_section');
|
156 |
+
add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events_click','ga_events_click_section');
|
157 |
+
add_settings_field('ga_events_sidebar', '','ga_events_setting_sidebar','ga_events','ga_events_main');
|
158 |
+
add_settings_field('ga_events_download_settings', '','ga_events_settings_download','ga_events','ga_events_main');
|
159 |
+
add_settings_field('ga_events_upload_settings', '','ga_events_settings_upload','ga_events','ga_events_main');
|
160 |
|
161 |
|
162 |
}
|
163 |
|
164 |
function ga_events_section_text() {
|
165 |
+
echo "<br><a style='margin-left:8px;' href='http://wpflow.com/documentation'>Plugin Documentation</a>";
|
166 |
}
|
167 |
|
168 |
function ga_events_setting_started() {
|
169 |
+
echo '
|
170 |
+
<h2>Getting Started Guide</h2>
|
171 |
+
<form action="https://www.getdrip.com/forms/4588171/submissions" method="post" data-drip-embedded-form="4588171">
|
172 |
+
<div style="background:white; line-height:20px; padding: 5px 15px 15px 15px;
|
173 |
font-size: 15px; max-width:400px;">
|
174 |
|
175 |
+
<h3 style="margin-top: 10px;" data-drip-attribute="headline">Want to learn more about event tracking?</h3>
|
176 |
+
<div data-drip-attribute="description">Now that you installed the plugin, we want to help you get everything up and running. <br />
|
177 |
+
Join our short email course and get started with event tracking.</div>
|
178 |
+
<div>
|
179 |
+
<label style="margin-top:10px;"for="fields[email]">Email Address:</label><br />
|
180 |
+
<input type="email" name="fields[email]" value="" />
|
181 |
+
</div>
|
182 |
+
<div>
|
183 |
+
<input style="margin-top:15px;" class="button-primary" type="submit" name="submit" value="Get Started" data-drip-attribute="sign-up-button" />
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
</form>';
|
187 |
}
|
188 |
|
189 |
function ga_events_setting_input() {
|
190 |
+
$options = get_option('ga_events_options');
|
191 |
+
$id = $options['id'];
|
192 |
+
echo "<label>Google Analytics Identifier</label>";
|
193 |
+
echo "<span class='ga_intable'><input class='inputs' id='id' name='ga_events_options[id]' type='text' value='$id' /></span>";
|
194 |
|
195 |
}
|
196 |
|
197 |
|
198 |
function ga_events_setting_snippet_input() {
|
199 |
+
$options = get_option('ga_events_options');
|
200 |
+
$id = $options['exclude_snippet'];
|
201 |
+
echo "<label>Don't add the GA tracking code</label>";
|
202 |
+
echo "<span class='ga_intable'><input id='snippet' name='ga_events_options[exclude_snippet]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
|
203 |
|
204 |
}
|
205 |
|
206 |
function ga_events_setting_uni_input() {
|
207 |
+
$options = get_option('ga_events_options');
|
208 |
+
$id = $options['universal'];
|
209 |
+
echo "<label>Universal Tracking Code</label>";
|
210 |
+
echo "<span class='ga_intable'><input id='universal' name='ga_events_options[universal]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
|
211 |
}
|
212 |
|
213 |
function ga_events_settings_download(){
|
214 |
+
echo '<a class="button" href="http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] .'&download=1">Export settings</a>';
|
215 |
}
|
216 |
|
217 |
function ga_events_settings_upload(){
|
218 |
+
echo '<a href="#" class="button btn_upload">Import settings</a>';
|
219 |
}
|
220 |
|
221 |
function ga_events_setting_divs_input() {
|
222 |
+
$options = get_option('ga_events_options');
|
223 |
+
$divs= $options['divs'];
|
224 |
+
$type='divs';
|
225 |
+
echo "<table id='ga-events-inputs' class='widefat inputs inner_table'><thead><th>Element Name</th><th>Type</th><th>Event Category</th><th>Event Action</th><th>Event Label</th><th>Non-Interaction</th><th></th></thead><tbody>";
|
226 |
+
if (!($divs[0][0])){
|
227 |
+
echo "<tr>";
|
228 |
+
echo "<td data-title='Element Name'><input id='divs' name='ga_events_options[divs][0][0]' type='text' value='".$divs[0][0]."' /></td>";
|
229 |
+
echo "<td data-title='Type'><select id='divs' name='ga_events_options[divs][0][1]'><option selected value='id' >id</option><option value='class'>class</option></select></td>";
|
230 |
+
echo "<td data-title='Event Category'><input id='divs' name='ga_events_options[divs][0][2]' type='text' value='".$divs[0][2]."' /></td>";
|
231 |
+
echo "<td data-title='Event Action'><input id='divs' name='ga_events_options[divs][0][3]' type='text' value='".$divs[0][3]."' /></td>";
|
232 |
+
echo "<td data-title='Event Label'><input id='divs' name='ga_events_options[divs][0][4]' type='text' value='".$divs[0][4]."' /></td>";
|
233 |
+
|
234 |
+
echo "<td data-title='Non-Interaction'><select id='".$type."' name='ga_events_options[".$type."][$i][5]'>";
|
235 |
+
if ($divs[$i][5] == 'true') {
|
236 |
+
echo "<option selected value='true' >true</option><option value='false'>false</option></select></td>";
|
237 |
+
} else {
|
238 |
+
echo "<option value='true' >true</option><option selected value='false'>false</option></select></td>";
|
239 |
+
}
|
240 |
+
|
241 |
+
echo "</tr>";
|
242 |
+
|
243 |
+
}else{
|
244 |
+
for ($i = 0; $i < sizeof($divs)+1; $i++){
|
245 |
+
|
246 |
+
echo "<tr>";
|
247 |
+
echo "<td data-title='Element Name'><input id='divs' name='ga_events_options[divs][$i][0] type='text' value='".$divs[$i][0]."' /></td>";
|
248 |
+
echo "<td data-title='Type'><select id='divs' name='ga_events_options[divs][$i][1]'>";
|
249 |
+
if ($divs[$i][1] == 'id'){
|
250 |
+
echo "<option selected value='id' >id</option><option value='class'>class</option></select></td>";
|
251 |
+
}else {
|
252 |
+
echo "<option value='id' >id</option><option selected value='class'>class</option></select></td>";
|
253 |
+
}
|
254 |
+
echo "<td data-title='Event Category'><input id='divs' name='ga_events_options[divs][$i][2]' type='text' value='".$divs[$i][2]."' /></td>";
|
255 |
+
echo "<td data-title='Event Action'><input id='divs' name='ga_events_options[divs][$i][3]' type='text' value='".$divs[$i][3]."' /></td>";
|
256 |
+
echo "<td data-title='Event Label'><input id='divs' name='ga_events_options[divs][$i][4]' type='text' value='".$divs[$i][4]."' /></td>";
|
257 |
+
|
258 |
+
echo "<td data-title='Non-Interaction'><select id='".$type."' name='ga_events_options[".$type."][$i][5]'>";
|
259 |
+
if ($divs[$i][5] == 'true') {
|
260 |
+
echo "<option selected value='true' >true</option><option value='false'>false</option></select></td>";
|
261 |
+
} else {
|
262 |
+
echo "<option value='true' >true</option><option selected value='false'>false</option></select></td>";
|
263 |
+
}
|
264 |
+
|
265 |
+
echo "<td><a class='remove' href=''>Remove</a></td>";
|
266 |
+
echo "</tr>";
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
echo "</tbody></table>";
|
272 |
}
|
273 |
|
274 |
|
275 |
function ga_events_setting_click_input() {
|
276 |
+
$options = get_option('ga_events_options');
|
277 |
+
$click = $options['click'];
|
278 |
+
$divs= $options['click'];
|
279 |
+
$type='click';
|
280 |
+
echo "<table id='ga-events-inputs' class='widefat inputs inner_table '><thead><th>Element Name</th><th>Type</th><th>Event Category</th><th>Event Action</th><th>Event Label</th><th>Non-Interaction</th><th></th></thead><tbody>";
|
281 |
+
if (!($click[0][0])){
|
282 |
+
echo "<tr>";
|
283 |
+
echo "<td data-title='Element Name'><input id='click' name='ga_events_options[click][0][0]' type='text' value='".$click[0][0]."' /></td>";
|
284 |
+
echo "<td data-title='Type'><select id='click' name='ga_events_options[click][0][1]'><option selected value='id'>id</option><option value='class'>class</option></select></td>";
|
285 |
+
echo "<td data-title='Event Category'><input id='click' name='ga_events_options[click][0][2]' type='text' value='".$click[0][2]."' /></td>";
|
286 |
+
echo "<td data-title='Event Action'><input id='click' name='ga_events_options[click][0][3]' type='text' value='".$click[0][3]."' /></td>";
|
287 |
+
echo "<td data-title='Event Label'><input id='click' name='ga_events_options[click][0][4]' type='text' value='".$click[0][4]."' /></td>";
|
288 |
+
|
289 |
+
echo "<td data-title='Non-Interaction'><select id='".$type."' name='ga_events_options[".$type."][$i][5]'>";
|
290 |
+
if ($divs[$i][5] == 'true') {
|
291 |
+
echo "<option selected value='true' >true</option><option value='false'>false</option></select></td>";
|
292 |
+
} else {
|
293 |
+
echo "<option value='true' >true</option><option selected value='false'>false</option></select></td>";
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
|
298 |
+
echo "</tr>";
|
299 |
+
|
300 |
+
}else{
|
301 |
+
for ($i = 0; $i < sizeof($click)+1; $i++){
|
302 |
+
|
303 |
+
echo "<tr>";
|
304 |
+
echo "<td data-title='Element Name'><input id='divs' name='ga_events_options[click][$i][0] type='text' value='".$click[$i][0]."' /></td>";
|
305 |
+
echo "<td data-title='Type'><select id='click' name='ga_events_options[click][$i][1]'>";
|
306 |
+
if ($click[$i][1] == 'id'){
|
307 |
+
echo "<option selected value='id' >id</option><option value='class'>class</option></select></td>";
|
308 |
+
}else {
|
309 |
+
echo "<option value='id' >id</option><option selected value='class'>class</option></select></td>";
|
310 |
+
}
|
311 |
+
echo "<td data-title='Event Category'><input id='click' name='ga_events_options[click][$i][2] type='text' value='".$click[$i][2]."' /></td>";
|
312 |
+
echo "<td data-title='Event Action'><input id='click' name='ga_events_options[click][$i][3] type='text' value='".$click[$i][3]."' /></td>";
|
313 |
+
echo "<td data-title='Event Label'><input id='click' name='ga_events_options[click][$i][4] type='text' value='".$click[$i][4]."' /></td>";
|
314 |
+
|
315 |
+
echo "<td data-title='Non-Interaction'><select id='".$type."' name='ga_events_options[".$type."][$i][5]'>";
|
316 |
+
if ($divs[$i][5] == 'true') {
|
317 |
+
echo "<option selected value='true' >true</option><option value='false'>false</option></select></td>";
|
318 |
+
}
|
319 |
+
else {
|
320 |
+
echo "<option value='true' >true</option><option selected value='false'>false</option></select></td>";
|
321 |
+
}
|
322 |
+
|
323 |
+
echo "<td><a class='remove' href=''>Remove</a></td>";
|
324 |
+
echo "</tr>";
|
325 |
+
|
326 |
+
}
|
327 |
+
|
328 |
+
}
|
329 |
+
echo "</tbody></table>";
|
330 |
|
331 |
|
332 |
}
|
335 |
}
|
336 |
|
337 |
function ga_events_validate($form){
|
338 |
+
|
339 |
+
$options = get_option('ga_events_options');
|
340 |
+
$updated = $options;
|
341 |
+
|
342 |
+
if( array_key_exists('divs', $form)) {
|
343 |
+
|
344 |
+
$updated['divs'] = array();
|
345 |
+
for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
|
346 |
+
if ($form['divs'][$i][0]){
|
347 |
+
$updated['divs'][$j] = $form['divs'][$i];
|
348 |
+
$j++;
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
}
|
|
|
|
|
|
|
|
|
350 |
}
|
351 |
+
}
|
352 |
+
else if(array_key_exists('click', $form)) {
|
353 |
+
$updated['click'] = array();
|
354 |
+
for ($i = 0, $j = 0; $i< sizeof($form['click']); $i++){
|
355 |
+
if ($form['click'][$i][0]){
|
356 |
+
$updated['click'][$j] = $form['click'][$i];
|
357 |
+
$j++;
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|
361 |
+
else {
|
362 |
+
$updated['id'] = $form['id'];
|
363 |
+
$updated['exclude_snippet'] = $form['exclude_snippet'];
|
364 |
+
$updated['universal'] = $form['universal'];
|
365 |
+
}
|
366 |
+
|
367 |
+
return $updated;
|
368 |
}
|
369 |
|
370 |
|
375 |
<script>
|
376 |
jQuery('body').on('click','a[href="admin.php?page=wp-google-analytics-events-upgrade"]', function (e) {
|
377 |
e.preventDefault();
|
378 |
+
window.open('https://wpflow.com/upgrade?utm_source=wpadm&utm_medium=banner&utm_content=menu&utm_campaign=wpadmin', '_blank');
|
379 |
});
|
380 |
</script>
|
381 |
<?php
|
383 |
|
384 |
|
385 |
function ga_events_get_settings(){
|
386 |
+
$options = get_option('ga_events_options');
|
387 |
+
$current = json_encode($options);
|
388 |
|
389 |
+
return $current;
|
390 |
}
|
391 |
|
392 |
function ga_events_upload_settings($file){
|
393 |
+
$uploadedfile = $file['settings'];
|
394 |
+
if($uploadedfile['type'] != 'application/octet-stream'){
|
395 |
+
ga_event_popup();
|
396 |
+
return;
|
397 |
+
}
|
398 |
+
$content = file_get_contents($uploadedfile["tmp_name"]);
|
399 |
+
|
400 |
+
ga_event_get_content($content);
|
401 |
}
|
402 |
|
403 |
function ga_event_get_content($content){
|
404 |
+
if(!$current = json_decode($content,true)){
|
405 |
+
ga_event_popup();
|
406 |
+
return;
|
407 |
+
}
|
408 |
+
if (!array_key_exists('id', $current) && !array_key_exists('domain', $current)) {
|
409 |
+
ga_event_popup();
|
410 |
+
return;
|
411 |
+
}
|
412 |
+
update_option( 'ga_events_options', $current );
|
413 |
|
414 |
}
|
415 |
function ga_event_popup(){
|
416 |
+
echo "<dev class='popup'>";
|
417 |
echo '<h1>Wrong file format <a href="#" class="btn_close_popup"><img src="'.plugins_url( 'images/close.png', dirname(__FILE__)).'"></a></h1>';
|
418 |
echo "</dev>";
|
419 |
}
|
420 |
function ga_events_file(){
|
421 |
+
header("Content-type: text/plain");
|
422 |
header("Content-Disposition: attachment; filename='settings.ini'");
|
423 |
echo ga_events_get_settings();
|
424 |
+
exit();
|
425 |
}
|
426 |
|
427 |
?>
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: yuvalo
|
3 |
Tags: analytics, google, events, ga
|
4 |
Tested up to: 4.4
|
5 |
-
Stable tag: 1.
|
6 |
License: GPLv2
|
7 |
Requires at least: 3.0
|
8 |
|
@@ -38,6 +38,8 @@ http://www.youtube.com/watch?v=UP8mfuV9huI
|
|
38 |
3. Plugin Scroll Settings screenshot-5.png
|
39 |
2. Google Analytics real time events screenshot-2.png
|
40 |
== Changelog ==
|
|
|
|
|
41 |
= Version 1.7 =
|
42 |
1. Import / Export ferature added
|
43 |
= Version 1.6 =
|
2 |
Contributors: yuvalo
|
3 |
Tags: analytics, google, events, ga
|
4 |
Tested up to: 4.4
|
5 |
+
Stable tag: 1.9
|
6 |
License: GPLv2
|
7 |
Requires at least: 3.0
|
8 |
|
38 |
3. Plugin Scroll Settings screenshot-5.png
|
39 |
2. Google Analytics real time events screenshot-2.png
|
40 |
== Changelog ==
|
41 |
+
= Version 1.9 =
|
42 |
+
1. Added the Non-Interaction Field
|
43 |
= Version 1.7 =
|
44 |
1. Import / Export ferature added
|
45 |
= Version 1.6 =
|