Version Description
Download this release
Release Info
Developer | yuvalo |
Plugin | WP Google Analytics Events |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.2
- css/style.css +122 -0
- ga-scroll-event.php +128 -35
- js/ga-scroll-events.js +19 -4
- readme.txt +23 -7
- wp-ga-events1.png +0 -0
- wp-ga-events2.png +0 -0
css/style.css
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#ga_main {
|
2 |
+
float:left;
|
3 |
+
width:80%;
|
4 |
+
display: block;
|
5 |
+
}
|
6 |
+
#ga_main th {
|
7 |
+
/*min-width:100px;*/
|
8 |
+
}
|
9 |
+
#ga_main td {
|
10 |
+
max-width: 400px;
|
11 |
+
}
|
12 |
+
|
13 |
+
.ga_events_sidebar {
|
14 |
+
float:right;
|
15 |
+
width: 195px;
|
16 |
+
margin-top:52px;
|
17 |
+
margin-right: 10px;
|
18 |
+
}
|
19 |
+
.ga_intable {
|
20 |
+
margin-left:10px;
|
21 |
+
}
|
22 |
+
|
23 |
+
#ga_main form th {
|
24 |
+
width: 0px !important;
|
25 |
+
padding: 0px !important;
|
26 |
+
}
|
27 |
+
|
28 |
+
#ga_main form label {
|
29 |
+
font-size: 1.2em;
|
30 |
+
margin-bottom: 3px;
|
31 |
+
}
|
32 |
+
|
33 |
+
#ga_main .inner_table {
|
34 |
+
margin-top: 10px;
|
35 |
+
}
|
36 |
+
#ga_main label {
|
37 |
+
min-width: 170px;
|
38 |
+
display: inline-block;
|
39 |
+
}
|
40 |
+
|
41 |
+
.btn-subscribe {
|
42 |
+
|
43 |
+
z-index: 10000;
|
44 |
+
padding: 8px 12px;
|
45 |
+
font-size: 18px;
|
46 |
+
line-height: 1.33;
|
47 |
+
border-radius: 6px;
|
48 |
+
display: inline-block;
|
49 |
+
margin-bottom: 0;
|
50 |
+
font-weight: normal;
|
51 |
+
text-align: center;
|
52 |
+
white-space: nowrap;
|
53 |
+
vertical-align: middle;
|
54 |
+
cursor: pointer;
|
55 |
+
background-image: none;
|
56 |
+
border: 1px solid rgba(0, 0, 0, 0);
|
57 |
+
-webkit-user-select: none;
|
58 |
+
-moz-user-select: none;
|
59 |
+
-ms-user-select: none;
|
60 |
+
-o-user-select: none;
|
61 |
+
user-select: none;
|
62 |
+
color: #FFF;
|
63 |
+
background-color: #7ACBA6;
|
64 |
+
box-shadow: 0 3px 2px #06121E;
|
65 |
+
border-radius: 7px;
|
66 |
+
position: relative;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
.wpcta {
|
71 |
+
text-align: center;
|
72 |
+
}
|
73 |
+
|
74 |
+
.ga_events_sidebar li {
|
75 |
+
list-style-type: square !important;
|
76 |
+
color: #FFF;
|
77 |
+
font-size: 14px;
|
78 |
+
}
|
79 |
+
|
80 |
+
.ga_events_sidebar li i {
|
81 |
+
margin-right: 5px;
|
82 |
+
}
|
83 |
+
|
84 |
+
.ga_events_sidebar th {
|
85 |
+
text-align: center;
|
86 |
+
font-size: 19px;
|
87 |
+
background-color: #22636A;
|
88 |
+
color: white !important;
|
89 |
+
}
|
90 |
+
.ga_events_sidebar .tfoot {
|
91 |
+
background-color: #22636A;
|
92 |
+
}
|
93 |
+
|
94 |
+
.ga_events_sidebar .features {
|
95 |
+
background-color: #7ACBA6;
|
96 |
+
}
|
97 |
+
|
98 |
+
.ga_events_sidebar form {
|
99 |
+
background-color: #96D0B5;
|
100 |
+
padding: 0px !important;
|
101 |
+
}
|
102 |
+
|
103 |
+
.ga_events_sidebar form .form-content {
|
104 |
+
padding: 10px 0 10px 3%;
|
105 |
+
}
|
106 |
+
|
107 |
+
.ga_events_sidebar form .clear {
|
108 |
+
display: block !important;
|
109 |
+
width: 100% !important;
|
110 |
+
background-color: #22636A;
|
111 |
+
padding: 10px 0 10px;
|
112 |
+
}
|
113 |
+
|
114 |
+
.ga_events_sidebar form .btn-subscribe {
|
115 |
+
display: block;
|
116 |
+
margin: auto;
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
#mc_embed_signup input.email {
|
121 |
+
width: 96% !important;
|
122 |
+
}
|
ga-scroll-event.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP Google Analytics Events
|
4 |
-
Plugin URI: http://
|
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://
|
9 |
License: GPLv2
|
10 |
*/
|
11 |
|
@@ -29,6 +29,7 @@ register_activation_hook( __FILE__, 'ga_events_install' );
|
|
29 |
function ga_events_install() {
|
30 |
$ga_events_options = array(
|
31 |
'id' => '',
|
|
|
32 |
'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
|
33 |
'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
|
34 |
);
|
@@ -48,7 +49,8 @@ function ga_events_menu() {
|
|
48 |
|
49 |
function ga_events_settings_page() {
|
50 |
?>
|
51 |
-
<
|
|
|
52 |
<?php screen_icon( 'plugins' ); ?>
|
53 |
<h2>GA Scroll Events Plugin</h2>
|
54 |
|
@@ -59,37 +61,113 @@ function ga_events_settings_page() {
|
|
59 |
</form>
|
60 |
|
61 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
<?php
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
add_action('admin_init', 'ga_events_admin_init');
|
67 |
|
68 |
function ga_events_admin_init() {
|
69 |
register_setting('ga_events_options','ga_events_options','ga_events_validate');
|
70 |
add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
|
71 |
-
add_settings_field('ga_events_id', '
|
72 |
-
add_settings_field('
|
73 |
-
add_settings_field('
|
|
|
|
|
74 |
|
75 |
|
76 |
}
|
77 |
|
78 |
function ga_events_section_text() {
|
79 |
-
echo "<
|
80 |
}
|
81 |
|
82 |
function ga_events_setting_input() {
|
83 |
$options = get_option('ga_events_options');
|
84 |
$id = $options['id'];
|
85 |
-
echo "<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
}
|
88 |
|
89 |
function ga_events_setting_divs_input() {
|
90 |
$options = get_option('ga_events_options');
|
91 |
$divs = $options['divs'];
|
92 |
-
echo "<
|
|
|
93 |
if (!($divs[0][0])){
|
94 |
echo "<tr>";
|
95 |
echo "<td><input id='divs' name='ga_events_options[divs][0][0]' type='text' value='".$divs[0][0]."' /></td>";
|
@@ -126,7 +204,8 @@ function ga_events_setting_divs_input() {
|
|
126 |
function ga_events_setting_click_input() {
|
127 |
$options = get_option('ga_events_options');
|
128 |
$click = $options['click'];
|
129 |
-
echo "<
|
|
|
130 |
if (!($click[0][0])){
|
131 |
echo "<tr>";
|
132 |
echo "<td><input id='click' name='ga_events_options[click][0][0]' type='text' value='".$click[0][0]."' /></td>";
|
@@ -170,10 +249,13 @@ function ga_events_setting_click_input() {
|
|
170 |
|
171 |
}
|
172 |
|
|
|
|
|
173 |
|
174 |
function ga_events_validate($form){
|
175 |
$updated = array();
|
176 |
$updated['id'] = $form['id'];
|
|
|
177 |
|
178 |
for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
|
179 |
if ($form['divs'][$i][0]){
|
@@ -217,31 +299,37 @@ function ga_events_header() {
|
|
217 |
$id = $options['id'];
|
218 |
$domain = $_SERVER['SERVER_NAME'];
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
ga('send', 'pageview');
|
228 |
-
|
229 |
-
</script>
|
230 |
-
|
231 |
-
<script type='text/javascript'>
|
232 |
-
|
233 |
-
var _gaq = _gaq || [];
|
234 |
-
_gaq.push(['_setAccount', '$id']);
|
235 |
-
_gaq.push(['_trackPageview']);
|
236 |
-
|
237 |
-
(function() {
|
238 |
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
239 |
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
240 |
-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
241 |
-
})();
|
242 |
-
|
243 |
-
</script>";
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
|
247 |
add_action( 'wp_footer', 'ga_events_footer', 100 );
|
@@ -250,11 +338,16 @@ function ga_events_footer() {
|
|
250 |
$options = get_option('ga_events_options');
|
251 |
$divs = $options['divs'];
|
252 |
$click = $options['click'];
|
|
|
|
|
|
|
|
|
253 |
echo "
|
254 |
<script>
|
255 |
|
256 |
jQuery(document).ready(function() {
|
257 |
scroll_events.bind_events( {
|
|
|
258 |
scroll_elements: [";
|
259 |
$i = 0;
|
260 |
if (is_array($divs)){
|
1 |
<?php
|
2 |
/*
|
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.2
|
7 |
Author: Yuval Oren
|
8 |
+
Author URI: http://wpflow.com
|
9 |
License: GPLv2
|
10 |
*/
|
11 |
|
29 |
function ga_events_install() {
|
30 |
$ga_events_options = array(
|
31 |
'id' => '',
|
32 |
+
'universal' => '0',
|
33 |
'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
|
34 |
'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
|
35 |
);
|
49 |
|
50 |
function ga_events_settings_page() {
|
51 |
?>
|
52 |
+
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
53 |
+
<div id="ga_main" class="wrap">
|
54 |
<?php screen_icon( 'plugins' ); ?>
|
55 |
<h2>GA Scroll Events Plugin</h2>
|
56 |
|
61 |
</form>
|
62 |
|
63 |
</div>
|
64 |
+
<div class="wrap ga_events_sidebar">
|
65 |
+
<table class="form-table widefat" >
|
66 |
+
<thead>
|
67 |
+
<th>Upgrade to Pro</th>
|
68 |
+
</thead>
|
69 |
+
<tbody>
|
70 |
+
<tr class="features">
|
71 |
+
<td>
|
72 |
+
<ul>
|
73 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Assign Event Value</strong></li>
|
74 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Shortcode support</strong></li>
|
75 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>HTML Tags support</strong></li>
|
76 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Bounce Rate Control</strong></li>
|
77 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Improved link tracking</strong></li>
|
78 |
+
<li><i class="fa fa-check-square-o fa-lg"></i><strong>Pro Support</strong></li>
|
79 |
+
</ul>
|
80 |
+
</td>
|
81 |
+
</tr>
|
82 |
+
<tr class="tfoot">
|
83 |
+
<td>
|
84 |
+
<div class="wpcta">
|
85 |
+
<a class="btn btn-subscribe" href="http://wpflow.com">
|
86 |
+
<span class="btn-title ">
|
87 |
+
Starting from
|
88 |
+
<span class="btn-data">
|
89 |
+
<span class="price">$29</span>
|
90 |
+
</span>
|
91 |
+
</span>
|
92 |
+
</a>
|
93 |
+
</div>
|
94 |
+
</td>
|
95 |
+
</tr>
|
96 |
+
</tbody>
|
97 |
+
</table>
|
98 |
+
<!-- Begin MailChimp Signup Form -->
|
99 |
+
<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
|
100 |
+
<style type="text/css">
|
101 |
+
#mc_embed_signup{background:#fff; clear:left; font:13px Helvetica,Arial,sans-serif; width:194px;}
|
102 |
+
/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
|
103 |
+
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
|
104 |
+
</style>
|
105 |
+
<div id="mc_embed_signup">
|
106 |
+
<form action="http://wpflow.us6.list-manage.com/subscribe/post?u=3a1990ecd0eee6198c11e5fc1&id=7e01c30e7f" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
|
107 |
+
<div class="form-content">
|
108 |
+
<h4>Receive plugin updates, news, promo codes and more</h4>
|
109 |
+
<label for="mce-EMAIL">Subscribe to our mailing list</label>
|
110 |
+
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
|
111 |
+
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
|
112 |
+
<div style="position: absolute; left: -5000px;"><input type="text" name="b_3a1990ecd0eee6198c11e5fc1_7e01c30e7f" value=""></div>
|
113 |
+
</div>
|
114 |
+
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn-subscribe "></div>
|
115 |
+
</form>
|
116 |
+
</div>
|
117 |
+
|
118 |
+
<!--End mc_embed_signup-->
|
119 |
+
</div>
|
120 |
+
|
121 |
|
122 |
<?php
|
123 |
}
|
124 |
|
125 |
+
function load_custom_wp_admin_style() {
|
126 |
+
wp_register_style( 'custom_wp_admin_css', plugins_url('css/style.css', __FILE__));
|
127 |
+
wp_enqueue_style( 'custom_wp_admin_css' );
|
128 |
+
}
|
129 |
+
|
130 |
+
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
|
131 |
+
|
132 |
add_action('admin_init', 'ga_events_admin_init');
|
133 |
|
134 |
function ga_events_admin_init() {
|
135 |
register_setting('ga_events_options','ga_events_options','ga_events_validate');
|
136 |
add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
|
137 |
+
add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
|
138 |
+
add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
|
139 |
+
add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events','ga_events_main');
|
140 |
+
add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events','ga_events_main');
|
141 |
+
add_settings_field('ga_events_sidebar', '','ga_events_setting_sidebar','ga_events','ga_events_main');
|
142 |
|
143 |
|
144 |
}
|
145 |
|
146 |
function ga_events_section_text() {
|
147 |
+
echo "<a href='http://wpflow.com/documentation'>Plugin Documentation</a>";
|
148 |
}
|
149 |
|
150 |
function ga_events_setting_input() {
|
151 |
$options = get_option('ga_events_options');
|
152 |
$id = $options['id'];
|
153 |
+
echo "<label>Google Analytics Identifier</label>";
|
154 |
+
echo "<span class='ga_intable'><input class='inputs' id='id' name='ga_events_options[id]' type='text' value='$id' /></span>";
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
function ga_events_setting_uni_input() {
|
159 |
+
$options = get_option('ga_events_options');
|
160 |
+
$id = $options['universal'];
|
161 |
+
echo "<label>Universal Tracking Code</label>";
|
162 |
+
echo "<span class='ga_intable'><input id='universal' name='ga_events_options[universal]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
|
163 |
|
164 |
}
|
165 |
|
166 |
function ga_events_setting_divs_input() {
|
167 |
$options = get_option('ga_events_options');
|
168 |
$divs = $options['divs'];
|
169 |
+
echo "<label>Scroll Events</label><br />";
|
170 |
+
echo "<table 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></th></thead><tbody>";
|
171 |
if (!($divs[0][0])){
|
172 |
echo "<tr>";
|
173 |
echo "<td><input id='divs' name='ga_events_options[divs][0][0]' type='text' value='".$divs[0][0]."' /></td>";
|
204 |
function ga_events_setting_click_input() {
|
205 |
$options = get_option('ga_events_options');
|
206 |
$click = $options['click'];
|
207 |
+
echo "<label>Click Events</label><br />";
|
208 |
+
echo "<table 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></th></thead><tbody>";
|
209 |
if (!($click[0][0])){
|
210 |
echo "<tr>";
|
211 |
echo "<td><input id='click' name='ga_events_options[click][0][0]' type='text' value='".$click[0][0]."' /></td>";
|
249 |
|
250 |
}
|
251 |
|
252 |
+
function ga_events_setting_sidebar(){
|
253 |
+
}
|
254 |
|
255 |
function ga_events_validate($form){
|
256 |
$updated = array();
|
257 |
$updated['id'] = $form['id'];
|
258 |
+
$updated['universal'] = $form['universal'];
|
259 |
|
260 |
for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
|
261 |
if ($form['divs'][$i][0]){
|
299 |
$id = $options['id'];
|
300 |
$domain = $_SERVER['SERVER_NAME'];
|
301 |
|
302 |
+
if (isset($options['universal']) && $options['universal']) {
|
303 |
+
echo "<script>
|
304 |
+
if (typeof ga === 'undefined') {
|
305 |
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
306 |
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
307 |
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
308 |
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
+
ga('create','$id', '$domain');
|
311 |
+
ga('send', 'pageview');
|
312 |
+
}
|
313 |
+
</script>";
|
314 |
+
} else {
|
315 |
+
echo "<script type='text/javascript'>
|
316 |
+
if (typeof _gaq === 'undefined') {
|
317 |
+
var _gaq = _gaq || [];
|
318 |
+
_gaq.push(['_setAccount', '$id']);
|
319 |
+
_gaq.push(['_setDomainName', '$domain']);
|
320 |
+
_gaq.push(['_setAllowLinker', true]);
|
321 |
+
_gaq.push(['_trackPageview']);
|
322 |
+
|
323 |
+
(function() {
|
324 |
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
325 |
+
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
|
326 |
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
327 |
+
})();
|
328 |
+
}
|
329 |
+
|
330 |
+
|
331 |
+
</script>";
|
332 |
+
}
|
333 |
}
|
334 |
|
335 |
add_action( 'wp_footer', 'ga_events_footer', 100 );
|
338 |
$options = get_option('ga_events_options');
|
339 |
$divs = $options['divs'];
|
340 |
$click = $options['click'];
|
341 |
+
$universal = $options['universal'];
|
342 |
+
if ($universal == ""){
|
343 |
+
$universal = 0;
|
344 |
+
}
|
345 |
echo "
|
346 |
<script>
|
347 |
|
348 |
jQuery(document).ready(function() {
|
349 |
scroll_events.bind_events( {
|
350 |
+
universal: ".$universal.",
|
351 |
scroll_elements: [";
|
352 |
$i = 0;
|
353 |
if (is_array($divs)){
|
js/ga-scroll-events.js
CHANGED
@@ -12,25 +12,40 @@ var scroll_events = (function ($) {
|
|
12 |
|
13 |
var scroll_elements = [];
|
14 |
var click_elements = [];
|
|
|
15 |
|
16 |
-
var track_event = function (category, action, label) {
|
17 |
var event_category = !category ? '' : category;
|
18 |
var event_action = !action ? '' : action;
|
19 |
var event_label = !label ? '' : label;
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
};
|
22 |
|
23 |
var click_event = function (event) {
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
};
|
26 |
|
27 |
return {
|
28 |
bind_events : function (settings) {
|
29 |
scroll_elements = settings.scroll_elements;
|
30 |
click_elements = settings.click_elements;
|
|
|
31 |
var i;
|
32 |
for (i = 0; i < click_elements.length; i++) {
|
33 |
var clicked = click_elements[i];
|
|
|
34 |
$(clicked.select).on('click', clicked, click_event);
|
35 |
}
|
36 |
|
@@ -44,7 +59,7 @@ var scroll_events = (function ($) {
|
|
44 |
if (!scroll_elements[i].sent) {
|
45 |
scroll_elements[i].offset = $(scroll_elements[i].select).offset();
|
46 |
if (scroll_elements[i].offset && ga_scroll_top + ga_window >= scroll_elements[i].offset.top + $(scroll_elements[i].select).height()) {
|
47 |
-
track_event(scroll_elements[i].category, scroll_elements[i].action, scroll_elements[i].label);
|
48 |
scroll_elements[i].sent = true;
|
49 |
}
|
50 |
}
|
12 |
|
13 |
var scroll_elements = [];
|
14 |
var click_elements = [];
|
15 |
+
var universal = 0;
|
16 |
|
17 |
+
var track_event = function (category, action, label, universal) {
|
18 |
var event_category = !category ? '' : category;
|
19 |
var event_action = !action ? '' : action;
|
20 |
var event_label = !label ? '' : label;
|
21 |
+
if (universal) {
|
22 |
+
ga('send','event', category, action, label);
|
23 |
+
} else {
|
24 |
+
_gaq.push(['_trackEvent',category, action, label]);
|
25 |
+
}
|
26 |
+
|
27 |
};
|
28 |
|
29 |
var click_event = function (event) {
|
30 |
+
track_event(event.data.category, event.data.action, event.data.label, event.data.universal);
|
31 |
+
|
32 |
+
if (event.currentTarget.hasOwnProperty('href')) {
|
33 |
+
event.preventDefault();
|
34 |
+
setTimeout(function () {
|
35 |
+
window.location = event.currentTarget.href;
|
36 |
+
}, 100);
|
37 |
+
}
|
38 |
};
|
39 |
|
40 |
return {
|
41 |
bind_events : function (settings) {
|
42 |
scroll_elements = settings.scroll_elements;
|
43 |
click_elements = settings.click_elements;
|
44 |
+
universal = settings.universal;
|
45 |
var i;
|
46 |
for (i = 0; i < click_elements.length; i++) {
|
47 |
var clicked = click_elements[i];
|
48 |
+
clicked.universal = universal;
|
49 |
$(clicked.select).on('click', clicked, click_event);
|
50 |
}
|
51 |
|
59 |
if (!scroll_elements[i].sent) {
|
60 |
scroll_elements[i].offset = $(scroll_elements[i].select).offset();
|
61 |
if (scroll_elements[i].offset && ga_scroll_top + ga_window >= scroll_elements[i].offset.top + $(scroll_elements[i].select).height()) {
|
62 |
+
track_event(scroll_elements[i].category, scroll_elements[i].action, scroll_elements[i].label, universal);
|
63 |
scroll_elements[i].sent = true;
|
64 |
}
|
65 |
}
|
readme.txt
CHANGED
@@ -1,21 +1,37 @@
|
|
1 |
=== WP Google Analytics Events ===
|
2 |
Contributors: yuvalo
|
3 |
Tags: analytics, google, events, ga
|
4 |
-
Tested up to: 3.
|
5 |
-
Stable tag: 1.
|
6 |
License: GPLv2
|
7 |
Requires at least: 3.0
|
8 |
|
9 |
-
|
10 |
== Description ==
|
11 |
-
The WP Google Analytics Events plugin allows you to send events to Google Analytics for
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
== Installation ==
|
14 |
-
Add the plugin by uploading the zip file or by installing it from the Wordpress
|
15 |
Activate the plugin and go to the WP Google Analytics Settings page.
|
16 |
Fill in your Google Analytics account identifier, add scroll and start creating scroll and click events.
|
17 |
|
|
|
|
|
18 |
== Screenshots ==
|
19 |
1. Plugin Options screenshot-1.png
|
20 |
2. Google Analytics real time events screenshot-2.png
|
21 |
-
== Changelog == = Version 1.
|
|
|
|
|
|
|
|
1 |
=== WP Google Analytics Events ===
|
2 |
Contributors: yuvalo
|
3 |
Tags: analytics, google, events, ga
|
4 |
+
Tested up to: 3.8.1
|
5 |
+
Stable tag: 1.2
|
6 |
License: GPLv2
|
7 |
Requires at least: 3.0
|
8 |
|
9 |
+
Track Events Google Analytics on your website - Enables you to send an event when a user Scrolls or Click an element on your website.
|
10 |
== Description ==
|
11 |
+
The WP Google Analytics Events plugin allows you to send events to Google Analytics for:
|
12 |
+
1. A user scrolls to a point of interest on your site
|
13 |
+
2. Clicking elements on the page, such as a Video play button or an Ajax submit form.
|
14 |
+
|
15 |
+
For example, create a Google Analytics event when a visitor scrolled down and viewed your pricing table. Track Video Plays and banner clicks.
|
16 |
+
Get to know what your visitors are doing on the website.
|
17 |
+
|
18 |
+
The plugin also supports the new Universal Tracking code by Google.
|
19 |
+
|
20 |
+
|
21 |
+
http://www.youtube.com/watch?v=UP8mfuV9huI
|
22 |
+
|
23 |
== Installation ==
|
24 |
+
Add the plugin by uploading the zip file or by installing it from the Wordpress Plugin directory.
|
25 |
Activate the plugin and go to the WP Google Analytics Settings page.
|
26 |
Fill in your Google Analytics account identifier, add scroll and start creating scroll and click events.
|
27 |
|
28 |
+
http://www.youtube.com/watch?v=UP8mfuV9huI
|
29 |
+
|
30 |
== Screenshots ==
|
31 |
1. Plugin Options screenshot-1.png
|
32 |
2. Google Analytics real time events screenshot-2.png
|
33 |
+
== Changelog == = Version 1.2 =
|
34 |
+
1. Fixes an issue that would cause tracking a page twice.
|
35 |
+
2. Admin look and feel changes.
|
36 |
+
3. Use the Universal Trcking code.
|
37 |
+
4. Added a short delay for link clicks.
|
wp-ga-events1.png
ADDED
Binary file
|
wp-ga-events2.png
ADDED
Binary file
|