Version Description
- 09/09/2014 =
- Fixed- Minor bugs
Download this release
Release Info
Developer | Tatvic |
Plugin | Enhanced Ecommerce Google Analytics Plugin for WooCommerce |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
includes/class-wc-enhanced-ecommerce-google-analytics-integration.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*
|
8 |
* @class WC_Enhanced_Ecommerce_Google_Analytics
|
9 |
* @extends WC_Integration
|
10 |
-
* @author Sudhir Mishra <
|
11 |
*/
|
12 |
|
13 |
class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
@@ -59,8 +59,22 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
59 |
|
60 |
//Enable display feature code checkbox
|
61 |
add_action("admin_footer", array($this, "check_UA_enabled"));
|
|
|
|
|
|
|
62 |
}
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
/**
|
65 |
* Initialise Settings Form Fields
|
66 |
*
|
@@ -180,7 +194,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
180 |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
181 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
182 |
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
|
183 |
-
|
184 |
ga("create", "' . esc_js($tracking_id) . '", "' . $set_domain_name . '");
|
185 |
'.$ga_display_feature_code.'
|
186 |
ga("require", "ec", "ec.js");
|
@@ -229,7 +243,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
229 |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
230 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
231 |
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
|
232 |
-
|
233 |
ga("create", "'. esc_js($tracking_id) . '", "' . $set_domain_name . '");
|
234 |
'.$ga_display_feature_code.'
|
235 |
ga("require", "ec", "ec.js");
|
@@ -297,10 +311,10 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
297 |
if (version_compare($woocommerce->version, "2.1", ">=")) {
|
298 |
wc_enqueue_js('
|
299 |
t_cnt=0;
|
300 |
-
t_ttl_prod=jQuery(".products li").length;
|
301 |
jQuery(".products li").each(function(index){
|
302 |
t_cnt++;
|
303 |
-
|
304 |
"id": jQuery(this).find(".ls-pro-sku").val(),
|
305 |
"name": jQuery(this).find(".ls-pro-name").val(),
|
306 |
"category": jQuery(this).find(".ls-pro-category").val(),
|
@@ -345,8 +359,8 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
345 |
|
346 |
} else {
|
347 |
|
348 |
-
|
349 |
-
|
350 |
t_ttl_prod=jQuery(".products li").length;
|
351 |
jQuery(".products li").each(function(index){
|
352 |
t_cnt++;
|
@@ -517,8 +531,10 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
517 |
global $woocommerce;
|
518 |
$category = get_the_terms($product->ID, "product_cat");
|
519 |
$categories = "";
|
|
|
520 |
foreach ($category as $term) {
|
521 |
$categories.=$term->name . ",";
|
|
|
522 |
}
|
523 |
//remove last comma(,) if multiple categories are there
|
524 |
$categories = rtrim($categories, ",");
|
@@ -563,9 +579,11 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
563 |
|
564 |
$category = get_the_terms($product->ID, "product_cat");
|
565 |
$categories = "";
|
|
|
566 |
foreach ($category as $term) {
|
567 |
$categories.=$term->name . ",";
|
568 |
}
|
|
|
569 |
//remove last comma(,) if multiple categories are there
|
570 |
$categories = rtrim($categories, ",");
|
571 |
|
@@ -624,19 +642,22 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
624 |
}
|
625 |
|
626 |
global $woocommerce;
|
627 |
-
|
|
|
628 |
foreach ($woocommerce->cart->cart_contents as $item) {
|
629 |
$p = get_product($item["product_id"]);
|
630 |
|
631 |
$category = get_the_terms($item["product_id"], "product_cat");
|
632 |
$categories = "";
|
|
|
633 |
foreach ($category as $term) {
|
634 |
$categories.=$term->name . ",";
|
|
|
635 |
}
|
636 |
//remove last comma(,) if multiple categories are there
|
637 |
$categories = rtrim($categories, ",");
|
638 |
|
639 |
-
$code
|
640 |
$code .= '"name": "' . esc_js($p->get_title()) . '",';
|
641 |
$code .= '"category": "' . esc_js($categories) . '",';
|
642 |
$code .= '"price": "' . esc_js($p->get_price()) . '",';
|
@@ -644,7 +665,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
644 |
}
|
645 |
|
646 |
$code_step_1 = $code . 'ga("ec:setAction","checkout",{"step": 1});';
|
647 |
-
$code_step_1 .= 'ga("send", "event", "Enhanced-Ecommerce",
|
648 |
if (version_compare($woocommerce->version, "2.1", ">=")) {
|
649 |
wc_enqueue_js($code_step_1);
|
650 |
} else {
|
@@ -653,7 +674,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
653 |
|
654 |
|
655 |
$code_step_2 = $code . 'ga("ec:setAction","checkout",{"step": 2});';
|
656 |
-
$code_step_2 .= 'ga("send", "event", "Enhanced-Ecommerce",
|
657 |
|
658 |
if (is_user_logged_in()) {
|
659 |
if (version_compare($woocommerce->version, "2.1", ">=")) {
|
@@ -665,7 +686,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
|
665 |
$step_2_on_proceed_to_pay = (!is_user_logged_in() && !$this->enable_guest_checkout ) || (!is_user_logged_in() && $this->enable_guest_checkout && $this->track_login_step_for_guest_user);
|
666 |
|
667 |
$code_step_3 = $code . 'ga("ec:setAction","checkout",{"step": 3});';
|
668 |
-
$code_step_3 .= 'ga("send", "event", "Enhanced-Ecommerce", "
|
669 |
|
670 |
$inline_js = 'jQuery(document).on("click","#place_order",function(e){';
|
671 |
if ($step_2_on_proceed_to_pay) {
|
7 |
*
|
8 |
* @class WC_Enhanced_Ecommerce_Google_Analytics
|
9 |
* @extends WC_Integration
|
10 |
+
* @author Sudhir Mishra <sudhir@tatvic.com>
|
11 |
*/
|
12 |
|
13 |
class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
|
59 |
|
60 |
//Enable display feature code checkbox
|
61 |
add_action("admin_footer", array($this, "check_UA_enabled"));
|
62 |
+
|
63 |
+
//add version details in footer
|
64 |
+
add_action("wp_footer",array($this,"add_plugin_details"));
|
65 |
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* display details of plugin
|
69 |
+
*
|
70 |
+
* @access public
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
|
74 |
+
function add_plugin_details(){
|
75 |
+
echo '<!-- Plugin Version: 1.0.8-->';
|
76 |
+
}
|
77 |
+
|
78 |
/**
|
79 |
* Initialise Settings Form Fields
|
80 |
*
|
194 |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
195 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
196 |
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
|
197 |
+
|
198 |
ga("create", "' . esc_js($tracking_id) . '", "' . $set_domain_name . '");
|
199 |
'.$ga_display_feature_code.'
|
200 |
ga("require", "ec", "ec.js");
|
243 |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
244 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
245 |
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
|
246 |
+
|
247 |
ga("create", "'. esc_js($tracking_id) . '", "' . $set_domain_name . '");
|
248 |
'.$ga_display_feature_code.'
|
249 |
ga("require", "ec", "ec.js");
|
311 |
if (version_compare($woocommerce->version, "2.1", ">=")) {
|
312 |
wc_enqueue_js('
|
313 |
t_cnt=0;
|
314 |
+
t_ttl_prod=jQuery(".ls-pro-sku").length; //jQuery(".products li").length;
|
315 |
jQuery(".products li").each(function(index){
|
316 |
t_cnt++;
|
317 |
+
ga("ec:addImpression", {
|
318 |
"id": jQuery(this).find(".ls-pro-sku").val(),
|
319 |
"name": jQuery(this).find(".ls-pro-name").val(),
|
320 |
"category": jQuery(this).find(".ls-pro-category").val(),
|
359 |
|
360 |
} else {
|
361 |
|
362 |
+
$woocommerce->add_inline_js('
|
363 |
+
t_cnt=0;
|
364 |
t_ttl_prod=jQuery(".products li").length;
|
365 |
jQuery(".products li").each(function(index){
|
366 |
t_cnt++;
|
531 |
global $woocommerce;
|
532 |
$category = get_the_terms($product->ID, "product_cat");
|
533 |
$categories = "";
|
534 |
+
if($category){
|
535 |
foreach ($category as $term) {
|
536 |
$categories.=$term->name . ",";
|
537 |
+
}
|
538 |
}
|
539 |
//remove last comma(,) if multiple categories are there
|
540 |
$categories = rtrim($categories, ",");
|
579 |
|
580 |
$category = get_the_terms($product->ID, "product_cat");
|
581 |
$categories = "";
|
582 |
+
if($category){
|
583 |
foreach ($category as $term) {
|
584 |
$categories.=$term->name . ",";
|
585 |
}
|
586 |
+
}
|
587 |
//remove last comma(,) if multiple categories are there
|
588 |
$categories = rtrim($categories, ",");
|
589 |
|
642 |
}
|
643 |
|
644 |
global $woocommerce;
|
645 |
+
|
646 |
+
$code="";
|
647 |
foreach ($woocommerce->cart->cart_contents as $item) {
|
648 |
$p = get_product($item["product_id"]);
|
649 |
|
650 |
$category = get_the_terms($item["product_id"], "product_cat");
|
651 |
$categories = "";
|
652 |
+
if($category){
|
653 |
foreach ($category as $term) {
|
654 |
$categories.=$term->name . ",";
|
655 |
+
}
|
656 |
}
|
657 |
//remove last comma(,) if multiple categories are there
|
658 |
$categories = rtrim($categories, ",");
|
659 |
|
660 |
+
$code .= 'ga("ec:addProduct", {"id": "' . esc_js($p->get_sku()) . '",';
|
661 |
$code .= '"name": "' . esc_js($p->get_title()) . '",';
|
662 |
$code .= '"category": "' . esc_js($categories) . '",';
|
663 |
$code .= '"price": "' . esc_js($p->get_price()) . '",';
|
665 |
}
|
666 |
|
667 |
$code_step_1 = $code . 'ga("ec:setAction","checkout",{"step": 1});';
|
668 |
+
$code_step_1 .= 'ga("send", "event", "Enhanced-Ecommerce","checkout_step_1",{"nonInteraction": 1});';
|
669 |
if (version_compare($woocommerce->version, "2.1", ">=")) {
|
670 |
wc_enqueue_js($code_step_1);
|
671 |
} else {
|
674 |
|
675 |
|
676 |
$code_step_2 = $code . 'ga("ec:setAction","checkout",{"step": 2});';
|
677 |
+
$code_step_2 .= 'ga("send", "event", "Enhanced-Ecommerce","checkout_step_2",{"nonInteraction": 1});';
|
678 |
|
679 |
if (is_user_logged_in()) {
|
680 |
if (version_compare($woocommerce->version, "2.1", ">=")) {
|
686 |
$step_2_on_proceed_to_pay = (!is_user_logged_in() && !$this->enable_guest_checkout ) || (!is_user_logged_in() && $this->enable_guest_checkout && $this->track_login_step_for_guest_user);
|
687 |
|
688 |
$code_step_3 = $code . 'ga("ec:setAction","checkout",{"step": 3});';
|
689 |
+
$code_step_3 .= 'ga("send", "event", "Enhanced-Ecommerce", "checkout_step_3",{"nonInteraction": 1});';
|
690 |
|
691 |
$inline_js = 'jQuery(document).on("click","#place_order",function(e){';
|
692 |
if ($step_2_on_proceed_to_pay) {
|
readme.txt
CHANGED
@@ -7,8 +7,8 @@ Author URI: http://www.tatvic.com/
|
|
7 |
Author: Tatvic
|
8 |
Requires at least: 3.6
|
9 |
Tested up to: 3.9.2
|
10 |
-
Stable tag: 1.0.
|
11 |
-
Version: 1.0.
|
12 |
License: GPLv3
|
13 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
14 |
|
@@ -92,4 +92,6 @@ Starting the WooCommerce 2.1 release there are no conflicts. However for earlier
|
|
92 |
= 1.0.7 - 28/08/2014 =
|
93 |
* Added new feature - Display Advertising Feature
|
94 |
* Fixed-Allow back quotes and single quotes in product name, category name etc.
|
95 |
-
|
|
|
|
7 |
Author: Tatvic
|
8 |
Requires at least: 3.6
|
9 |
Tested up to: 3.9.2
|
10 |
+
Stable tag: 1.0.8
|
11 |
+
Version: 1.0.8
|
12 |
License: GPLv3
|
13 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
14 |
|
92 |
= 1.0.7 - 28/08/2014 =
|
93 |
* Added new feature - Display Advertising Feature
|
94 |
* Fixed-Allow back quotes and single quotes in product name, category name etc.
|
95 |
+
|
96 |
+
= 1.0.8 - 09/09/2014 =
|
97 |
+
* Fixed- Minor bugs
|
woocommerce-enhanced-ecommerce-google-analytics-integration.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
/* Copyright 2014 Sudhir Mishra (email :
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -21,7 +21,7 @@
|
|
21 |
Description: Allows Enhanced E-commerce Google Analytics tracking code to be inserted into WooCommerce store pages.
|
22 |
Author: Tatvic
|
23 |
Author URI: http://www.tatvic.com
|
24 |
-
Version: 1.0.
|
25 |
*/
|
26 |
|
27 |
// Add the integration to WooCommerce
|
1 |
<?php
|
2 |
|
3 |
+
/* Copyright 2014 Sudhir Mishra (email : sudhir@tatvic.com)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License, version 2, as
|
21 |
Description: Allows Enhanced E-commerce Google Analytics tracking code to be inserted into WooCommerce store pages.
|
22 |
Author: Tatvic
|
23 |
Author URI: http://www.tatvic.com
|
24 |
+
Version: 1.0.8
|
25 |
*/
|
26 |
|
27 |
// Add the integration to WooCommerce
|