Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 1.1.0

Version Description

  • 08/08/2017 =
    • Minor Bug Fixes & Optimization.
Download this release

Release Info

Developer Tatvic
Plugin Icon 128x128 Enhanced Ecommerce Google Analytics Plugin for WooCommerce
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.21.1 to 1.1.0

includes/class-wc-enhanced-ecommerce-google-analytics-integration.php CHANGED
@@ -18,7 +18,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
18
  * @return void
19
  */
20
  //set plugin version
21
- public $tvc_eeVer = '1.0.21.1';
22
  public function __construct() {
23
 
24
  //Set Global Variables
@@ -317,6 +317,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
317
  * @return void
318
  */
319
  function ecommerce_tracking_code($order_id) {
 
320
  global $woocommerce;
321
  if ($this->disable_tracking($this->ga_eeT) || current_user_can("manage_options") || get_post_meta($order_id, "_tracked", true) == 1)
322
  return;
@@ -324,7 +325,6 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
324
  $tracking_id = $this->ga_id;
325
  if (!$tracking_id)
326
  return;
327
-
328
  // Doing eCommerce tracking so unhook standard tracking from the footer
329
  remove_action("wp_footer", array($this, "ee_settings"));
330
 
@@ -363,7 +363,6 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
363
  } else {
364
  $ga_pageview = "";
365
  }
366
-
367
  $code = '(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
368
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
369
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
@@ -374,13 +373,14 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
374
  ga("require", "ec", "ec.js");
375
  ' . $ga_pageview . '
376
  ';
 
377
  // Order items
378
  if ($order->get_items()) {
379
  foreach ($order->get_items() as $item) {
380
  $_product = $order->get_product_from_item($item);
381
-
382
  if (isset($_product->variation_data)) {
383
- $categories=esc_js(woocommerce_get_formatted_variation($_product->variation_data, true));
 
384
  } else {
385
  $out = array();
386
  if(version_compare($woocommerce->version, "2.7", "<")){
@@ -388,7 +388,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
388
  }else{
389
  $categories = get_the_terms($_product->get_id(), "product_cat");
390
  }
391
-
392
  if ($categories) {
393
  foreach ($categories as $category) {
394
  $out[] = $category->name;
@@ -396,13 +396,12 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
396
  }
397
  $categories=esc_js(join(",", $out));
398
  }
399
-
400
  //orderpage Prod json
401
  if(version_compare($woocommerce->version, "2.7", "<")){
402
  $orderpage_prod_Array[get_permalink($_product->id)]=array(
403
  "tvc_id" => esc_html($_product->id),
404
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->id),
405
- "tvc_n" => esc_js($item["name"]),
406
  "tvc_p" => esc_js($order->get_item_total($item)),
407
  "tvc_c" => $categories,
408
  "tvc_q"=>esc_js($item["qty"])
@@ -411,7 +410,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
411
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
412
  "tvc_id" => esc_html($_product->get_id()),
413
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
414
- "tvc_n" => esc_js($item["name"]),
415
  "tvc_p" => esc_js($order->get_item_total($item)),
416
  "tvc_c" => $categories,
417
  "tvc_q"=>esc_js($item["qty"])
@@ -822,11 +821,10 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
822
  $this->wc_version_compare("tvc_pgc=" . json_encode($catpage_json) . ";");
823
  $this->wc_version_compare("catpage_json_ATC_link=" . json_encode($catpage_json_ATC_link) . ";");
824
 
825
-
826
  $hmpg_impressions_jQ = '
827
  ga("require", "ec", "ec.js");
828
  ga("set", "&cu", tvc_lc);
829
- function t_products_impre_clicks(t_json_name,t_action,t_list){
830
  t_send_threshold=0;
831
  t_prod_pos=0;
832
 
@@ -840,7 +838,6 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
840
  "id": t_json_name[t_item].tvc_i,
841
  "name": t_json_name[t_item].tvc_n,
842
  "category": t_json_name[t_item].tvc_c,
843
- "list":t_list,
844
  "price": t_json_name[t_item].tvc_p,
845
  "position": t_json_name[t_item].tvc_po,
846
  });
@@ -861,7 +858,7 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
861
  }
862
 
863
  //function for comparing urls in json object
864
- function prod_exists_in_JSON(t_url,t_json_name,t_list,t_action){
865
  if(t_json_name.hasOwnProperty(t_url)){
866
  t_call_fired=true;
867
  ga("ec:addProduct", {
@@ -871,7 +868,6 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
871
  "price": t_json_name[t_url].tvc_p,
872
  "position": t_json_name[t_url].tvc_po,
873
  });
874
- ga("ec:setAction", "click", {"list": t_list});
875
  ga("send", "event", "Enhanced-Ecommerce","click", "product_click_"+t_action, {"nonInteraction": 1});
876
  }else{
877
  t_call_fired=false;
@@ -904,17 +900,17 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
904
  if(is_home() || is_front_page()){
905
  $hmpg_impressions_jQ .='
906
  if(tvc_fp.length !== 0){
907
- t_products_impre_clicks(tvc_fp,"fp","Featured Products");
908
  }
909
  if(tvc_rcp.length !== 0){
910
- t_products_impre_clicks(tvc_rcp,"rp","Recent Products");
911
  }
912
  jQuery("a:not([href*=add-to-cart],.product_type_variable, .product_type_grouped)").on("click",function(){
913
  t_url=jQuery(this).attr("href");
914
  //home page call for click
915
- t_call_fired=prod_exists_in_JSON(t_url,tvc_fp,"Featured Products","fp");
916
  if(!t_call_fired){
917
- prod_exists_in_JSON(t_url,tvc_rcp,"Recent Products","rp");
918
  }
919
  });
920
  //ATC click
@@ -936,13 +932,13 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
936
  $hmpg_impressions_jQ .='
937
  //search page json
938
  if(tvc_pgc.length !== 0){
939
- t_products_impre_clicks(tvc_pgc,"srch","Search Results");
940
  }
941
  //search page prod click
942
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
943
  t_url=jQuery(this).attr("href");
944
  //cat page prod call for click
945
- prod_exists_in_JSON(t_url,catpage_json,"Search Results","srch");
946
  });
947
 
948
  ';
@@ -950,13 +946,13 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
950
  //product page releted products
951
  $hmpg_impressions_jQ .='
952
  if(tvc_rdp.length !== 0){
953
- t_products_impre_clicks(tvc_rdp,"rdp","Related Products");
954
  }
955
  //product click - image and product name
956
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
957
  t_url=jQuery(this).attr("href");
958
  //prod page related call for click
959
- prod_exists_in_JSON(t_url,tvc_rdp,"Related Products","rdp");
960
  });
961
  //Prod ATC link click in related product section
962
  jQuery("a[href*=add-to-cart]").on("click",function(){
@@ -973,13 +969,13 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
973
  $hmpg_impressions_jQ .='
974
  //category page json
975
  if(tvc_pgc.length !== 0){
976
- t_products_impre_clicks(tvc_pgc,"cp","Category Page");
977
  }
978
  //Prod category ATC link click in related product section
979
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
980
  t_url=jQuery(this).attr("href");
981
  //cat page prod call for click
982
- prod_exists_in_JSON(t_url,tvc_pgc,"Category Page","cp");
983
  });
984
 
985
  ';
@@ -987,13 +983,13 @@ class WC_Enhanced_Ecommerce_Google_Analytics extends WC_Integration {
987
  $hmpg_impressions_jQ .='
988
  //shop page json
989
  if(tvc_pgc.length !== 0){
990
- t_products_impre_clicks(tvc_pgc,"sp","Shop Page");
991
  }
992
  //shop page prod click
993
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
994
  t_url=jQuery(this).attr("href");
995
  //cat page prod call for click
996
- prod_exists_in_JSON(t_url,tvc_pgc,"Shop Page","sp");
997
  });
998
 
999
 
18
  * @return void
19
  */
20
  //set plugin version
21
+ public $tvc_eeVer = '1.1.0';
22
  public function __construct() {
23
 
24
  //Set Global Variables
317
  * @return void
318
  */
319
  function ecommerce_tracking_code($order_id) {
320
+
321
  global $woocommerce;
322
  if ($this->disable_tracking($this->ga_eeT) || current_user_can("manage_options") || get_post_meta($order_id, "_tracked", true) == 1)
323
  return;
325
  $tracking_id = $this->ga_id;
326
  if (!$tracking_id)
327
  return;
 
328
  // Doing eCommerce tracking so unhook standard tracking from the footer
329
  remove_action("wp_footer", array($this, "ee_settings"));
330
 
363
  } else {
364
  $ga_pageview = "";
365
  }
 
366
  $code = '(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
367
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
368
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
373
  ga("require", "ec", "ec.js");
374
  ' . $ga_pageview . '
375
  ';
376
+
377
  // Order items
378
  if ($order->get_items()) {
379
  foreach ($order->get_items() as $item) {
380
  $_product = $order->get_product_from_item($item);
 
381
  if (isset($_product->variation_data)) {
382
+ $categories=esc_js(wc_get_formatted_variation($_product->get_variation_attributes(), true));
383
+
384
  } else {
385
  $out = array();
386
  if(version_compare($woocommerce->version, "2.7", "<")){
388
  }else{
389
  $categories = get_the_terms($_product->get_id(), "product_cat");
390
  }
391
+
392
  if ($categories) {
393
  foreach ($categories as $category) {
394
  $out[] = $category->name;
396
  }
397
  $categories=esc_js(join(",", $out));
398
  }
 
399
  //orderpage Prod json
400
  if(version_compare($woocommerce->version, "2.7", "<")){
401
  $orderpage_prod_Array[get_permalink($_product->id)]=array(
402
  "tvc_id" => esc_html($_product->id),
403
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->id),
404
+ "tvc_n" => esc_js($_product->get_name()),
405
  "tvc_p" => esc_js($order->get_item_total($item)),
406
  "tvc_c" => $categories,
407
  "tvc_q"=>esc_js($item["qty"])
410
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
411
  "tvc_id" => esc_html($_product->get_id()),
412
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
413
+ "tvc_n" => esc_js($_product->get_name()),
414
  "tvc_p" => esc_js($order->get_item_total($item)),
415
  "tvc_c" => $categories,
416
  "tvc_q"=>esc_js($item["qty"])
821
  $this->wc_version_compare("tvc_pgc=" . json_encode($catpage_json) . ";");
822
  $this->wc_version_compare("catpage_json_ATC_link=" . json_encode($catpage_json_ATC_link) . ";");
823
 
 
824
  $hmpg_impressions_jQ = '
825
  ga("require", "ec", "ec.js");
826
  ga("set", "&cu", tvc_lc);
827
+ function t_products_impre_clicks(t_json_name,t_action){
828
  t_send_threshold=0;
829
  t_prod_pos=0;
830
 
838
  "id": t_json_name[t_item].tvc_i,
839
  "name": t_json_name[t_item].tvc_n,
840
  "category": t_json_name[t_item].tvc_c,
 
841
  "price": t_json_name[t_item].tvc_p,
842
  "position": t_json_name[t_item].tvc_po,
843
  });
858
  }
859
 
860
  //function for comparing urls in json object
861
+ function prod_exists_in_JSON(t_url,t_json_name,t_action){
862
  if(t_json_name.hasOwnProperty(t_url)){
863
  t_call_fired=true;
864
  ga("ec:addProduct", {
868
  "price": t_json_name[t_url].tvc_p,
869
  "position": t_json_name[t_url].tvc_po,
870
  });
 
871
  ga("send", "event", "Enhanced-Ecommerce","click", "product_click_"+t_action, {"nonInteraction": 1});
872
  }else{
873
  t_call_fired=false;
900
  if(is_home() || is_front_page()){
901
  $hmpg_impressions_jQ .='
902
  if(tvc_fp.length !== 0){
903
+ t_products_impre_clicks(tvc_fp,"fp");
904
  }
905
  if(tvc_rcp.length !== 0){
906
+ t_products_impre_clicks(tvc_rcp,"rp");
907
  }
908
  jQuery("a:not([href*=add-to-cart],.product_type_variable, .product_type_grouped)").on("click",function(){
909
  t_url=jQuery(this).attr("href");
910
  //home page call for click
911
+ t_call_fired=prod_exists_in_JSON(t_url,tvc_fp,"fp");
912
  if(!t_call_fired){
913
+ prod_exists_in_JSON(t_url,tvc_rcp,"rp");
914
  }
915
  });
916
  //ATC click
932
  $hmpg_impressions_jQ .='
933
  //search page json
934
  if(tvc_pgc.length !== 0){
935
+ t_products_impre_clicks(tvc_pgc,"srch");
936
  }
937
  //search page prod click
938
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
939
  t_url=jQuery(this).attr("href");
940
  //cat page prod call for click
941
+ prod_exists_in_JSON(t_url,tvc_pgc,"srch");
942
  });
943
 
944
  ';
946
  //product page releted products
947
  $hmpg_impressions_jQ .='
948
  if(tvc_rdp.length !== 0){
949
+ t_products_impre_clicks(tvc_rdp,"rdp");
950
  }
951
  //product click - image and product name
952
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
953
  t_url=jQuery(this).attr("href");
954
  //prod page related call for click
955
+ prod_exists_in_JSON(t_url,tvc_rdp,"rdp");
956
  });
957
  //Prod ATC link click in related product section
958
  jQuery("a[href*=add-to-cart]").on("click",function(){
969
  $hmpg_impressions_jQ .='
970
  //category page json
971
  if(tvc_pgc.length !== 0){
972
+ t_products_impre_clicks(tvc_pgc,"cp");
973
  }
974
  //Prod category ATC link click in related product section
975
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
976
  t_url=jQuery(this).attr("href");
977
  //cat page prod call for click
978
+ prod_exists_in_JSON(t_url,tvc_pgc,"cp");
979
  });
980
 
981
  ';
983
  $hmpg_impressions_jQ .='
984
  //shop page json
985
  if(tvc_pgc.length !== 0){
986
+ t_products_impre_clicks(tvc_pgc,"sp");
987
  }
988
  //shop page prod click
989
  jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
990
  t_url=jQuery(this).attr("href");
991
  //cat page prod call for click
992
+ prod_exists_in_JSON(t_url,tvc_pgc,"sp");
993
  });
994
 
995
 
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: 4.8
10
- Stable tag: 1.0.21.1
11
- Version: 1.0.21.1
12
  License: GPLv3
13
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
14
 
@@ -55,10 +55,10 @@ We have recently launched an Advanced Google Analytics Plugin for WooCommerce wh
55
  == Note : ==
56
  == Our plugin does not support the below features out of the box ==
57
  * Highly Customized store
58
- * Child/Custom Themes
59
  * Product types other than Simple Product
60
  * Store with the Subscription product for Orders.
61
  * Ecommerce Pages with Shortcodes
 
62
 
63
  == Installation ==
64
  1. Download the plugin file to your computer and unzip it
@@ -141,12 +141,16 @@ Configuring goals are out of the scope of our plugin. Our plugin is designed to
141
 
142
  = Does your Plugin support Product Refund? =
143
 
144
- Our existing plugin does not track product refund data, however you can buy our <a href="https://codecanyon.net/item/actionable-google-analytics-for-woocommerce/9899552" target="_blank">paid plugin</a> to get access to product Refund data
145
 
146
  = Does your plugin supports Multilingual Wordpress site? =
147
 
148
  Our plugin does not support Multilingual Wordpress site.
149
 
 
 
 
 
150
  = How to verify if you have implemented the Plugin well? =
151
 
152
  To verify if you have implemented the plugin well, just log in to your Google Analytics account & check if the data is coming well in your Enhanced Ecommerce Reports.
@@ -226,4 +230,7 @@ Important Note: When you update the plugin, please save your settings again.
226
  * Minor Bug Fixes.
227
 
228
  = 1.0.21.1 - 13/07/2017 =
229
- * Minor Changes.
 
 
 
7
  Author: Tatvic
8
  Requires at least: 3.6
9
  Tested up to: 4.8
10
+ Stable tag: 1.1.0
11
+ Version: 1.1.0
12
  License: GPLv3
13
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
14
 
55
  == Note : ==
56
  == Our plugin does not support the below features out of the box ==
57
  * Highly Customized store
 
58
  * Product types other than Simple Product
59
  * Store with the Subscription product for Orders.
60
  * Ecommerce Pages with Shortcodes
61
+ * For the Child theme support; kindly contact us at analytics2(at)tatvic(dot)com
62
 
63
  == Installation ==
64
  1. Download the plugin file to your computer and unzip it
141
 
142
  = Does your Plugin support Product Refund? =
143
 
144
+ Our existing plugin does not track product refund data, however you can buy our <a href="https://codecanyon.net/item/actionable-google-analytics-for-woocommerce/9899552?ref=tatvic" target="_blank">paid plugin</a> to get access to product Refund data
145
 
146
  = Does your plugin supports Multilingual Wordpress site? =
147
 
148
  Our plugin does not support Multilingual Wordpress site.
149
 
150
+ = Does your plugin supports Child/Custom Theme? =
151
+
152
+ For the Child/Custom theme support; kindly contact us at analytics2(at)tatvic(dot)com.
153
+
154
  = How to verify if you have implemented the Plugin well? =
155
 
156
  To verify if you have implemented the plugin well, just log in to your Google Analytics account & check if the data is coming well in your Enhanced Ecommerce Reports.
230
  * Minor Bug Fixes.
231
 
232
  = 1.0.21.1 - 13/07/2017 =
233
+ * Minor Changes.
234
+
235
+ = 1.1.0 - 08/08/2017 =
236
+ * Minor Bug Fixes & Optimization.
woocommerce-enhanced-ecommerce-google-analytics-integration.php CHANGED
@@ -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.21.1
25
  */
26
  if (!defined('ABSPATH')) {
27
  exit; // Exit if accessed directly
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.1.0
25
  */
26
  if (!defined('ABSPATH')) {
27
  exit; // Exit if accessed directly