Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.6.6

Version Description

  • 03/03/2022 =
  • New: In this release, we have Enhanced and optimized in Google Analytics tracking event.
  • Tweak: Now, the admin user will be able to change the thank you page conversion tracking method while setting up the plugin under Google Analytics tab.
  • Tweak: Plugin will no longer be supported for the woocommerce versions anything less than 2.8
Download this release

Release Info

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

Code changes from version 4.6.5 to 4.6.6

admin/css/style.css CHANGED
@@ -2,6 +2,14 @@
2
  @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,500&display=swap');
3
  /*rc */
4
  /* 11 */
 
 
 
 
 
 
 
 
5
  .btn-11 {
6
  overflow: hidden;
7
  animation: shiny-btn2 2s ease-in-out infinite;
2
  @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,500&display=swap');
3
  /*rc */
4
  /* 11 */
5
+ select#tvc_conversion_tracking_type{
6
+ border: 1px solid #C6C6C6;
7
+ border-radius: 6px;
8
+ box-sizing: border-box;
9
+ cursor: pointer;
10
+ -webkit-user-select: none;
11
+ padding-right: 30px;
12
+ }
13
  .btn-11 {
14
  overflow: hidden;
15
  animation: shiny-btn2 2s ease-in-out infinite;
admin/partials/general-fields.php CHANGED
@@ -162,6 +162,7 @@ if (isset($_POST['ee_submit_plugin'])) {
162
  $settings['ga_OPTOUT'] = isset($_POST["ga_OPTOUT"])?sanitize_text_field($_POST["ga_OPTOUT"]):"";
163
  $settings['ga_PrivacyPolicy'] = isset($_POST["ga_PrivacyPolicy"])?sanitize_text_field($_POST["ga_PrivacyPolicy"]):"";
164
  $settings['google-analytic'] = '';
 
165
 
166
  $TVC_Admin_Helper->save_ee_options_settings($settings);
167
 
@@ -339,6 +340,19 @@ if(isset($google_detail['setting'])){
339
  </label>
340
  </td>
341
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  <tr>
343
  <th>
344
  <label class = "align-middle" for="ga_OPTOUT"><?php esc_html_e("Google Analytics Opt Out","conversios"); ?></label>
162
  $settings['ga_OPTOUT'] = isset($_POST["ga_OPTOUT"])?sanitize_text_field($_POST["ga_OPTOUT"]):"";
163
  $settings['ga_PrivacyPolicy'] = isset($_POST["ga_PrivacyPolicy"])?sanitize_text_field($_POST["ga_PrivacyPolicy"]):"";
164
  $settings['google-analytic'] = '';
165
+ $settings['tvc_conversion_tracking_type'] = isset($_POST["tvc_conversion_tracking_type"])?sanitize_text_field($_POST["tvc_conversion_tracking_type"]):"";
166
 
167
  $TVC_Admin_Helper->save_ee_options_settings($settings);
168
 
340
  </label>
341
  </td>
342
  </tr>
343
+ <tr>
344
+ <th>
345
+ <label class = "align-middle" for="ga_PrivacyPolicy"><?php esc_html_e("Order Conversion Trigger","conversios"); ?></label>
346
+ </th>
347
+ <td>
348
+ <?php $tvc_con_tracking_type = isset($data['tvc_conversion_tracking_type'])?$data['tvc_conversion_tracking_type']:""; ?>
349
+ <select name="tvc_conversion_tracking_type" id="tvc_conversion_tracking_type">
350
+ <option value="woo-thankyou-hook" <?php echo ($tvc_con_tracking_type != "on-thankyou-page")?"selected":""; ?>><?php esc_html_e("Woo Thankyou Hook","conversios"); ?></option>
351
+ <option value="on-thankyou-page" <?php echo ($tvc_con_tracking_type == "on-thankyou-page")?"selected":""; ?>><?php esc_html_e("On Thankyou Page","conversios"); ?></option>
352
+ </select>
353
+ <i style="cursor: help;" class="fas fa-question-circle" title="<?php esc_html_e("If your thank you page conversion tracking does not work with the current tracking method then switch to another method.","conversios"); ?>"></i>
354
+ </td>
355
+ </tr>
356
  <tr>
357
  <th>
358
  <label class = "align-middle" for="ga_OPTOUT"><?php esc_html_e("Google Analytics Opt Out","conversios"); ?></label>
enhanced-ecommerce-google-analytics.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
- * Version: 4.6.5
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
@@ -23,7 +23,7 @@
23
  * Text Domain: www.tatvic.com
24
  * Domain Path: /languages
25
  * WC requires at least: 3.5.0
26
- * WC tested up to: 6.1.1
27
  */
28
 
29
  /**
@@ -37,7 +37,7 @@ if ( ! defined( 'WPINC' ) ) {
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
- define( 'PLUGIN_TVC_VERSION', '4.6.5' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
15
  * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
+ * Version: 4.6.6
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
23
  * Text Domain: www.tatvic.com
24
  * Domain Path: /languages
25
  * WC requires at least: 3.5.0
26
+ * WC tested up to: 6.2.1
27
  */
28
 
29
  /**
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
+ define( 'PLUGIN_TVC_VERSION', '4.6.6' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/class-enhanced-ecommerce-google-analytics.php CHANGED
@@ -76,7 +76,8 @@ class Enhanced_Ecommerce_Google_Analytics {
76
  $this->load_dependencies();
77
  $this->set_locale();
78
  $this->define_admin_hooks();
79
- $this->define_public_hooks();
 
80
  $this->check_dependency();
81
  add_filter( 'plugin_action_links_' .plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' ), array($this,'tvc_plugin_action_links'),10 );
82
  }
@@ -98,61 +99,55 @@ class Enhanced_Ecommerce_Google_Analytics {
98
  * @access private
99
  */
100
  private function load_dependencies() {
 
 
 
 
 
101
 
102
-
103
-
104
- /**
105
- * The class responsible for orchestrating the actions and filters of the
106
- * core plugin.
107
- */
108
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-enhanced-ecommerce-google-analytics-loader.php';
109
-
110
- /**
111
- * The class responsible for defining internationalization functionality
112
- * of the plugin.
113
- */
114
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-enhanced-ecommerce-google-analytics-i18n.php';
115
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-tvc-admin-db-helper.php';
116
-
117
- require_once plugin_dir_path(dirname(__FILE__)) . 'includes/data/class-tvc-ajax-calls.php';
118
- require_once plugin_dir_path(dirname(__FILE__)) . 'includes/data/class-tvc-ajax-file.php';
119
- require_once plugin_dir_path(dirname(__FILE__)) . 'includes/data/class-tvc-taxonomies.php';
120
-
121
- require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-tvc-register-scripts.php';
122
- /**
123
- * The class responsible for defining all actions that occur in the admin area.
124
- */
125
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-enhanced-ecommerce-google-analytics-admin.php';
126
-
127
- /**
128
- * New conversios UI file list
129
- */
130
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-onboarding.php';
131
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-onboarding-helper.php';
132
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-dashboard-helper.php';
133
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-admin.php';
134
- /**
135
- * End New conversios UI file list
136
- */
137
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-tvc-admin-auto-product-sync-helper.php';
138
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-survey.php';
139
-
140
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
- /**
143
- * The class responsible for defining all actions that occur in the public-facing
144
- * side of the site.
145
- */
146
-
147
- $TVC_Admin_Helper = new TVC_Admin_Helper();
148
- $plan_id = $TVC_Admin_Helper->get_plan_id();
149
- if($plan_id == 1){
150
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public.php';
151
- }else{
152
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public-pro.php';
153
- }
154
- $this->loader = new Enhanced_Ecommerce_Google_Analytics_Loader();
155
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
  /**
@@ -194,8 +189,8 @@ class Enhanced_Ecommerce_Google_Analytics {
194
  * @since 1.0.0
195
  * @access private
196
  */
197
- private function define_public_hooks() {
198
- $plugin_public = new Enhanced_Ecommerce_Google_Analytics_Public( $this->get_plugin_name(), $this->get_version() );
199
  }
200
 
201
  /**
@@ -204,21 +199,21 @@ class Enhanced_Ecommerce_Google_Analytics {
204
  * @since 1.0.0
205
  */
206
  public function run() {
207
- if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
208
- add_action('woocommerce_init' , function (){
209
- $this->loader->run();
210
- });
211
- }
212
- else{
213
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
214
- if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
215
- $this->loader->run();
216
- }else if( is_plugin_active( 'enhanced-e-commerce-for-woocommerce-store/enhanced-ecommerce-google-analytics.php' ) ){
217
- if(!isset($_POST['action'])){
218
- printf('<div class="notice tvc-notice notice-error"><p>%s</p></div>',esc_html__("Hey, It seems WooCommerce plugin is not active on your wp-admin. Conversios.io - Google Analytics and Google Shopping plugin can only be activated if you have active WooCommerce plugin in your wp-admin.","conversios"));
219
- }
220
- }
221
  }
 
222
  }
223
 
224
  /**
76
  $this->load_dependencies();
77
  $this->set_locale();
78
  $this->define_admin_hooks();
79
+ //$this->define_public_hooks();
80
+ add_action('init', array($this, 'define_public_hooks'));
81
  $this->check_dependency();
82
  add_filter( 'plugin_action_links_' .plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' ), array($this,'tvc_plugin_action_links'),10 );
83
  }
99
  * @access private
100
  */
101
  private function load_dependencies() {
102
+ /**
103
+ * The class responsible for orchestrating the actions and filters of the
104
+ * core plugin.
105
+ */
106
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-enhanced-ecommerce-google-analytics-loader.php';
107
 
108
+ /**
109
+ * The class responsible for defining internationalization functionality
110
+ * of the plugin.
111
+ */
112
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-enhanced-ecommerce-google-analytics-i18n.php';
113
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-tvc-admin-db-helper.php';
114
+
115
+ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/data/class-tvc-ajax-calls.php';
116
+ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/data/class-tvc-ajax-file.php';
117
+ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/data/class-tvc-taxonomies.php';
118
+
119
+ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-tvc-register-scripts.php';
120
+ /**
121
+ * The class responsible for defining all actions that occur in the admin area.
122
+ */
123
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-enhanced-ecommerce-google-analytics-admin.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
+ /**
126
+ * New conversios UI file list
127
+ */
128
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-onboarding.php';
129
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-onboarding-helper.php';
130
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-dashboard-helper.php';
131
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-admin.php';
132
+ /**
133
+ * End New conversios UI file list
134
+ */
135
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-tvc-admin-auto-product-sync-helper.php';
136
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-survey.php';
137
 
138
+ /**
139
+ * The class responsible for defining all actions that occur in the public-facing
140
+ * side of the site.
141
+ */
 
 
 
 
 
 
 
 
 
142
 
143
+ $TVC_Admin_Helper = new TVC_Admin_Helper();
144
+ $plan_id = $TVC_Admin_Helper->get_plan_id();
145
+ if($plan_id == 1){
146
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public.php';
147
+ }else{
148
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public-pro.php';
149
+ }
150
+ $this->loader = new Enhanced_Ecommerce_Google_Analytics_Loader();
151
  }
152
 
153
  /**
189
  * @since 1.0.0
190
  * @access private
191
  */
192
+ public function define_public_hooks() {
193
+ new Enhanced_Ecommerce_Google_Analytics_Public( $this->get_plugin_name(), $this->get_version() );
194
  }
195
 
196
  /**
199
  * @since 1.0.0
200
  */
201
  public function run() {
202
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
203
+ add_action('woocommerce_init' , function (){
204
+ $this->loader->run();
205
+ });
206
+ }
207
+ else{
208
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
209
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
210
+ $this->loader->run();
211
+ }else if( is_plugin_active( 'enhanced-e-commerce-for-woocommerce-store/enhanced-ecommerce-google-analytics.php' ) ){
212
+ if(!isset($_POST['action'])){
213
+ printf('<div class="notice tvc-notice notice-error"><p>%s</p></div>',esc_html__("Hey, It seems WooCommerce plugin is not active on your wp-admin. Conversios.io - Google Analytics and Google Shopping plugin can only be activated if you have active WooCommerce plugin in your wp-admin.","conversios"));
214
+ }
 
215
  }
216
+ }
217
  }
218
 
219
  /**
public/class-enhanced-ecommerce-google-analytics-public-pro.php CHANGED
@@ -64,6 +64,9 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
64
  protected $remarketing_snippet_id;
65
  protected $remarketing_snippets;
66
  protected $conversio_send_to;
 
 
 
67
 
68
  /**
69
  * Enhanced_Ecommerce_Google_Analytics_Public constructor.
@@ -75,6 +78,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
75
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
76
  $this->plugin_name = sanitize_text_field($plugin_name);
77
  $this->version = sanitize_text_field($version);
 
 
78
  $this->tvc_call_hooks();
79
 
80
  $this->ga_Dname = "auto";
@@ -106,57 +111,54 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
106
  $this->remarketing_snippets = base64_decode($remarketing['snippets']);
107
  $this->remarketing_snippet_id = sanitize_text_field(isset($remarketing['id'])?esc_attr($remarketing['id']):"");
108
  }
109
- if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
110
- // Put your plugin code here
111
- add_action('woocommerce_init' , function (){
112
- $this->ga_LC = get_woocommerce_currency(); //Local Currency from Back end
113
- $this->wc_version_compare("tvc_lc=" . json_encode(esc_js($this->ga_LC)) . ";");
114
- /*
115
- * start tvc_options
116
- */
117
- $current_user = wp_get_current_user();
118
- //$current_user ="";
119
- $user_id = "";
120
- $user_type = "guest_user";
121
- if ( isset($current_user->ID) && $current_user->ID != 0 ) {
122
- $user_id = $current_user->ID;
123
- $current_user_type = 'register_user';
124
- }
125
- $this->tvc_options = array(
126
- "feature_product_label"=>esc_html__("Feature Product"),
127
- "on_sale_label"=>esc_html__("On Sale"),
128
- "affiliation"=>esc_js(get_bloginfo('name')),
129
- "local_time"=>esc_js(time()),
130
- "is_admin"=>esc_attr(is_admin()),
131
- "currency"=>esc_js($this->ga_LC),
132
- "tracking_option"=>esc_js($this->tracking_option),
133
- "property_id"=>esc_js($this->ga_id),
134
- "measurement_id"=>esc_js($this->gm_id),
135
- "google_ads_id"=>esc_js($this->google_ads_id),
136
- "google_merchant_center_id"=>esc_js($this->google_merchant_id),
137
- "o_add_gtag_snippet"=>esc_js($this->ga_ST),
138
- "o_enhanced_e_commerce_tracking"=>esc_js($this->ga_eeT),
139
- "o_log_step_gest_user"=>esc_js($this->ga_gUser),
140
- "o_impression_thresold"=>esc_js($this->ga_imTh),
141
- "o_ip_anonymization"=>esc_js($this->ga_IPA),
142
- "o_ga_OPTOUT"=>esc_js($this->ga_OPTOUT),
143
- "ads_tracking_id"=>esc_js($this->ads_tracking_id),
144
- "remarketing_tags"=>esc_js($this->ads_ert),
145
- "dynamic_remarketing_tags"=>esc_js($this->ads_edrt),
146
- "google_ads_conversion_tracking"=>esc_js($this->google_ads_conversion_tracking),
147
- "conversio_send_to"=>esc_js($this->conversio_send_to),
148
- "page_type"=>esc_js($this->add_page_type()),
149
- "user_id"=>esc_js($user_id),
150
- "user_type"=>esc_js($user_type),
151
- "day_type"=>esc_js($this->add_day_type()),
152
- "remarketing_snippet_id"=>esc_js($this->remarketing_snippet_id),
153
- "tvc_ajax_url"=>esc_url_raw(admin_url( 'admin-ajax.php' ))
154
- );
155
- /*
156
- * end tvc_options
157
- */
158
- });
159
- } // end if woocommerce
160
  }
161
 
162
  public function tvc_call_hooks(){
@@ -166,13 +168,21 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
166
 
167
  add_action("wp_footer", array($this, "t_products_impre_clicks"));
168
  add_action("woocommerce_after_shop_loop_item", array($this, "bind_product_metadata"));
169
- add_action("woocommerce_thankyou", array($this, "ecommerce_tracking_code"));
170
- add_action("woocommerce_after_single_product", array($this, "product_detail_view"));
 
 
 
 
 
171
  add_action("woocommerce_after_cart", array($this, "remove_cart_tracking"));
172
  //check out step 1,2,3
173
- add_action("woocommerce_before_checkout_form", array($this, "checkout_step_1_tracking"));
174
- add_action("woocommerce_before_checkout_form", array($this, "checkout_step_2_tracking"));
175
- add_action("woocommerce_before_checkout_form", array($this, "checkout_step_3_tracking"));
 
 
 
176
  add_action("woocommerce_after_add_to_cart_button", array($this, "add_to_cart"));
177
  //add version details in footer
178
  add_action("wp_footer", array($this, "add_plugin_details"));
@@ -285,14 +295,11 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
285
  }
286
  }
287
  public function get_option($key){
288
- $ee_options = array();
289
- $my_option = get_option( 'ee_options' );
290
-
291
- if(!empty($my_option)){
292
- $ee_options = unserialize($my_option);
293
  }
294
- if(isset($ee_options[$key])){
295
- return $ee_options[$key];
296
  }
297
  }
298
  /**
@@ -396,13 +403,12 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
396
  * @return void
397
  */
398
  function wc_version_compare($codeSnippet) {
399
- global $woocommerce;
400
-
401
- if (version_compare($woocommerce->version, "2.1", ">=")) {
402
- wc_enqueue_js($codeSnippet);
403
- } else {
404
- $woocommerce->add_inline_js($codeSnippet);
405
- }
406
  }
407
  /**
408
  * Enhanced Ecommerce GA plugin Settings
@@ -414,7 +420,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
414
  global $woocommerce;
415
  //common validation----start
416
  if (is_admin() || $this->ga_ST == "" || current_user_can("manage_options") || !$this->ga_PrivacyPolicy) {
417
- return;
418
  }
419
  // IP Anonymization
420
  if ($this->ga_IPA) {
@@ -553,7 +559,45 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
553
  }
554
  }
555
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
  /**
558
  * Google Analytics eCommerce tracking
559
  *
@@ -561,11 +605,19 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
561
  * @param mixed $order_id
562
  * @return void
563
  */
564
- function ecommerce_tracking_code($order_id) {
565
  global $woocommerce;
566
- if ($this->disable_tracking($this->ga_eeT) || current_user_can("manage_options") || get_post_meta($order_id, "_tracked", true) == 1){
567
- return;
 
 
 
 
568
  }
 
 
 
 
569
  // Doing eCommerce tracking so unhook standard tracking from the footer
570
  remove_action("wp_footer", array($this, "ee_settings"));
571
  /*
@@ -573,7 +625,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
573
  * var tvc_oc
574
  */
575
  $orderpage_prod_Array = array();
576
- $order = new WC_Order($order_id);
577
  //Get Applied Coupon Codes
578
  $coupons_list = '';
579
  if(version_compare($woocommerce->version, "3.7", ">")){
@@ -608,12 +660,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
608
  }
609
  }
610
  $categories=esc_js(join(",", $out));
611
- $product_type = "";
612
- if (version_compare($woocommerce->version, "2.7", "<")) {
613
- $product_type = $_product->product_type;
614
- }else{
615
- $product_type =$_product->get_type();
616
- }
617
  if($product_type == "variation"){
618
  $attributes=esc_js(wc_get_formatted_variation($_product->get_variation_attributes(), true));
619
  /*if ($_product->variation_has_weight) {
@@ -623,50 +670,28 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
623
  /*if ($_product->has_weight()) {
624
  //$p_weight = $_product->get_weight().' '.esc_attr(get_option('woocommerce_weight_unit'));
625
  }*/
626
- }
627
- if (version_compare($woocommerce->version, "2.7", "<")) {
628
- $orderpage_prod_Array[get_permalink($_product->ID)]=array(
629
- "tvc_id" => esc_js($_product->ID),
630
- "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
631
- "tvc_n" => html_entity_decode(esc_js($item["name"])),
632
- "tvc_p" => esc_js($order->get_item_total($item)),
633
- //"tvc_rp" => $_product->regular_price,
634
- //"tvc_sp" => $_product->sale_price,
635
- "tvc_pd" => esc_js($this->cal_prod_discount($_product->regular_price, $_product->sale_price)),
636
- "tvc_c" => esc_js($categories),
637
- "tvc_attr" => esc_js($attributes),
638
- "tvc_q"=>esc_js($item["qty"]),
639
- //"tvc_wt" => $p_weight,
640
- "tvc_var" => esc_js($this->getAttributesVariation($_product)),
641
- /*"tvc_di" => $_product->get_dimensions(), //dimensions
642
- "tvc_ss" => $_product->is_in_stock(),
643
- "tvc_st" => $_product->get_stock_quantity(),
644
- "tvc_tst" => $_product->get_total_stock(),
645
- "tvc_rc" => $_product->get_rating_count(),
646
- "tvc_rs" => $_product->get_average_rating()*/
647
- );
648
- }else{
649
- $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
650
- "tvc_id" => esc_js($_product->get_id()),
651
- "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
652
- "tvc_n" => esc_js($_product->get_title()),
653
- "tvc_p" => esc_js($order->get_item_total($item)),
654
- // "tvc_rp" => $_product->get_regular_price(),
655
- // "tvc_sp" => $_product->get_sale_price(),
656
- "tvc_pd" => esc_js($this->cal_prod_discount($_product->get_regular_price(), $_product->get_sale_price())),
657
- "tvc_c" => esc_js($categories),
658
- "tvc_attr" => esc_js($attributes),
659
- "tvc_q"=>esc_js($item["qty"]),
660
- //"tvc_wt" => $p_weight,
661
- "tvc_var" => esc_js($this->getAttributesVariation($_product)),
662
- /*"tvc_di" => $_product->get_dimensions(), //dimensions
663
- "tvc_ss" => $_product->is_in_stock(),
664
- "tvc_st" => $_product->get_stock_quantity(),
665
- "tvc_tst" => $_product->get_total_stock(),
666
- "tvc_rc" => $_product->get_rating_count(),
667
- "tvc_rs" => $_product->get_average_rating()*/
668
- );
669
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
  }
671
  //make json for prod meta data on order page
672
  $this->wc_version_compare("tvc_oc=" . json_encode($orderpage_prod_Array) . ";");
@@ -676,13 +701,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
676
  * Get the trans data
677
  * Var tvc_td
678
  */
679
- //get shipping cost based on version >2.1 get_total_shipping() < get_shipping
680
- $tvc_sc = "";
681
- if (version_compare($woocommerce->version, "2.1", ">=")) {
682
- $tvc_sc = $order->get_total_shipping();
683
- } else {
684
- $tvc_sc = $order->get_shipping();
685
- }
686
  $user_bill_addr="";
687
  $user_ship_addr="";
688
  if(isset($this->tvc_options["user_id"]) && $this->tvc_options["user_id"]!="" ){
@@ -756,15 +776,12 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
756
  * @return void
757
  */
758
  public function product_detail_view() {
759
- if ($this->disable_tracking($this->ga_eeT)) {
760
  return;
761
  }
762
- global $product,$woocommerce;
763
- if(version_compare($woocommerce->version, "2.7", "<")){
764
- $category = get_the_terms($product->ID, "product_cat");
765
- }else{
766
- $category = get_the_terms($product->get_id(), "product_cat");
767
- }
768
  $categories = "";
769
  if ($category) {
770
  foreach ($category as $term) {
@@ -774,39 +791,21 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
774
  //remove last comma(,) if multiple categories are there
775
  $categories = rtrim($categories, ",");
776
  //product detail view json
777
- $prodpage_detail_json = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
778
 
779
- if(version_compare($woocommerce->version, "2.7", "<")){
780
- $prodpage_detail_json = array(
781
- "tvc_id" => esc_js($product->id),
782
- "tvc_i" => $product->get_sku() ? esc_js($product->get_sku()) : esc_js($product->id),
783
- "tvc_n" => esc_js($product->get_title()),
784
- "tvc_c" => esc_js($categories),
785
- "tvc_p" => esc_js($product->get_price()),
786
- "tvc_pd" => esc_js($this->cal_prod_discount($product->regular_price, $product->sale_price)),
787
- "tvc_ps" => esc_js($product->get_stock_status()),
788
- "tvc_tst" => esc_js($product->get_total_stock()),
789
- "tvc_q" => esc_js($product->get_stock_quantity()),
790
- "tvc_var" => esc_js($this->getAttributesVariation($product)),
791
- "is_featured" => esc_js($product->is_featured()),
792
- "is_onSale" => esc_js($product->is_on_sale())
793
- );
794
- }else{
795
- $prodpage_detail_json = array(
796
- "tvc_id" => esc_js($product->get_id()),
797
- "tvc_i" => $product->get_sku() ? esc_js($product->get_sku()) : esc_js($product->get_id()),
798
- "tvc_n" => esc_js($product->get_title()),
799
- "tvc_c" => esc_js($categories),
800
- "tvc_p" => esc_js($product->get_price()),
801
- "tvc_pd" => esc_js($this->cal_prod_discount($product->get_regular_price(), $product->get_sale_price())),
802
- "tvc_ps" => esc_js($product->get_stock_status()),
803
- "tvc_tst" => esc_js($product->get_stock_quantity()),
804
- "tvc_q" => esc_js($product->get_stock_quantity()),
805
- "tvc_var" => esc_js($this->getAttributesVariation($product)),
806
- "is_featured" => esc_js($product->is_featured()),
807
- "is_onSale" => esc_js($product->is_on_sale())
808
- );
809
- }
810
  //prod page detail view json
811
  $this->wc_version_compare("tvc_po=" . json_encode($prodpage_detail_json) . ";");
812
  ?>
@@ -820,615 +819,533 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
820
  <?php
821
  }
822
 
823
- /**
824
- * Enhanced E-commerce tracking for product impressions on category pages (hidden fields) , product page (related section)
825
- * home page (featured section and recent section)
826
- *
827
- * @access public
828
- * @return void
829
- */
830
- public function bind_product_metadata() {
831
- if ($this->disable_tracking($this->ga_eeT)) {
832
- return;
833
- }
834
-
835
- global $product,$woocommerce;
836
- if (version_compare($woocommerce->version, "2.7", "<")) {
837
- $category = get_the_terms($product->Id, "product_cat");
838
- } else {
839
- $category = get_the_terms($product->get_id(), "product_cat");
840
- }
841
-
842
- $categories = "";
843
 
844
- if ($category) {
845
- foreach ($category as $term) {
846
- $categories.=$term->name . ",";
847
- }
 
 
848
  }
849
- //remove last comma(,) if multiple categories are there
850
- $categories = rtrim($categories, ",");
851
- //declare all variable as a global which will used for make json
852
- global $homepage_json_fp,$homepage_json_ATC_link, $homepage_json_rp,$prodpage_json_relProd,$catpage_json,$prodpage_json_ATC_link,$catpage_json_ATC_link;
853
- //is home page then make all necessory json
854
- if (is_home() || is_front_page()) {
855
- if (!is_array($homepage_json_fp) && !is_array($homepage_json_rp) && !is_array($homepage_json_ATC_link)) {
856
- $homepage_json_fp = array();
857
- $homepage_json_rp = array();
858
- $homepage_json_ATC_link=array();
859
- }
860
-
861
- // ATC link Array
862
- if(version_compare($woocommerce->version, "2.7", "<")){
863
- $homepage_json_ATC_link[$product->add_to_cart_url()]=
864
- array(
865
- "ATC-link"=>esc_url_raw(get_permalink($product->id))
866
- );
867
- }else{
868
- $homepage_json_ATC_link[$product->add_to_cart_url()]=
869
- array(
870
- "ATC-link"=>esc_url_raw(get_permalink($product->get_id()))
871
- );
872
- }
873
- //check if product is featured product or not
874
- if ($product->is_featured()) {
875
- //check if product is already exists in homepage featured json
876
- if(version_compare($woocommerce->version, "2.7", "<")){
877
- if(!array_key_exists(get_permalink($product->id),$homepage_json_fp)){
878
- $homepage_json_fp[get_permalink($product->id)] = array(
879
- "tvc_id" => esc_js($product->id),
880
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
881
- "tvc_n" => esc_js($product->get_title()),
882
- "tvc_p" => esc_js($product->get_price()),
883
- "tvc_c" => esc_js($categories),
884
- "ATC-link"=> esc_url_raw($product->add_to_cart_url())
885
- );
886
- //else add product in homepage recent product json
887
- }else {
888
- $homepage_json_rp[get_permalink($product->get_id())] =array(
889
- "tvc_id" => esc_js($product->get_id()),
890
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
891
- "tvc_n" => esc_js($product->get_title()),
892
- "tvc_p" => esc_js($product->get_price()),
893
- "tvc_c" => esc_js($categories)
894
- );
895
- }
896
- }else{
897
- if(!array_key_exists(get_permalink($product->get_id()),$homepage_json_fp)){
898
- $homepage_json_fp[get_permalink($product->get_id())] = array(
899
- "tvc_id" => esc_js($product->get_id()),
900
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
901
- "tvc_n" => esc_js($product->get_title()),
902
- "tvc_p" => esc_js($product->get_price()),
903
- "tvc_c" => esc_js($categories),
904
- "ATC-link"=> esc_url_raw($product->add_to_cart_url())
905
- );
906
- //else add product in homepage recent product json
907
- }else {
908
- $homepage_json_rp[get_permalink($product->get_id())] =array(
909
- "tvc_id" => esc_js($product->get_id()),
910
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
911
- "tvc_n" => esc_js($product->get_title()),
912
- "tvc_p" => esc_js($product->get_price()),
913
- "tvc_c" => esc_js($categories)
914
- );
915
- }
916
- }
917
-
918
- } else {
919
- //else prod add in homepage recent json
920
- if(version_compare($woocommerce->version, "2.7", "<")){
921
- $homepage_json_rp[get_permalink($product->id)] =array(
922
- "tvc_id" => esc_js($product->id),
923
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
924
- "tvc_n" => esc_js($product->get_title()),
925
- "tvc_p" => esc_js($product->get_price()),
926
- "tvc_c" => esc_js($categories)
927
- );
928
- }else{
929
- $homepage_json_rp[get_permalink($product->get_id())] =array(
930
- "tvc_id" => esc_js($product->get_id()),
931
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
932
- "tvc_n" => esc_js($product->get_title()),
933
- "tvc_p" => esc_js($product->get_price()),
934
- "tvc_c" => esc_js($categories)
935
- );
936
- }
937
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
938
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
939
  }
940
- //if product page then related product page array
941
- else if(is_product()){
942
- if(!is_array($prodpage_json_relProd) && !is_array($prodpage_json_ATC_link)){
943
- $prodpage_json_relProd = array();
944
- $prodpage_json_ATC_link = array();
945
- }
946
- // ATC link Array
947
- if(version_compare($woocommerce->version, "2.7", "<")){
948
- $prodpage_json_ATC_link[$product->add_to_cart_url()]=
949
- array(
950
- "ATC-link"=> esc_url_raw(get_permalink($product->id))
951
- );
952
-
953
- $prodpage_json_relProd[get_permalink($product->id)] = array(
954
- "tvc_id" => esc_js($product->id),
955
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
956
- "tvc_n" => esc_js($product->get_title()),
957
- "tvc_p" => esc_js($product->get_price()),
958
- "tvc_c" => esc_js($categories),
959
- );
960
- }else{
961
- $prodpage_json_ATC_link[$product->add_to_cart_url()]=
962
- array(
963
- "ATC-link"=> esc_url_raw(get_permalink($product->get_id()))
964
- );
965
-
966
- $prodpage_json_relProd[get_permalink($product->get_id())] = array(
967
- "tvc_id" => esc_js($product->get_id()),
968
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
969
- "tvc_n" => esc_js($product->get_title()),
970
- "tvc_p" => esc_js($product->get_price()),
971
- "tvc_c" => esc_js($categories)
972
-
973
- );
974
- }
975
  }
976
- //category page, search page and shop page json
977
- else if (is_product_category() || is_search() || is_shop()) {
978
- if (!is_array($catpage_json) && !is_array($catpage_json_ATC_link)){
979
- $catpage_json=array();
980
- $catpage_json_ATC_link=array();
981
- }
982
- //cat page ATC array
983
- if(version_compare($woocommerce->version, "2.7", "<")){
984
- $catpage_json_ATC_link[$product->add_to_cart_url()]=
985
- array(
986
- "ATC-link"=>esc_url_raw(get_permalink($product->id))
987
- );
988
-
989
- $catpage_json[get_permalink($product->id)] =array(
990
- "tvc_id" => esc_js($product->id),
991
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
992
- "tvc_n" => esc_js($product->get_title()),
993
- "tvc_p" => esc_js($product->get_price()),
994
- "tvc_c" => esc_js($categories),
995
- );
996
- }else{
997
- $catpage_json_ATC_link[$product->add_to_cart_url()]=
998
- array(
999
- "ATC-link"=>esc_url_raw(get_permalink($product->get_id()))
1000
- );
1001
 
1002
- $catpage_json[get_permalink($product->get_id())] =array(
1003
- "tvc_id" => esc_js($product->get_id()),
1004
- "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
1005
- "tvc_n" => esc_js($product->get_title()),
1006
- "tvc_p" => esc_js($product->get_price()),
1007
- "tvc_c" => esc_js($categories)
 
 
 
1008
 
1009
- );
1010
- }
1011
- }
 
 
 
 
 
 
1012
  }
1013
 
1014
- /**
1015
- * Enhanced E-commerce tracking for product impressions,clicks on Home pages
1016
- *
1017
- * @access public
1018
- * @return void
1019
- */
1020
- function t_products_impre_clicks() {
1021
- if ($this->disable_tracking($this->ga_eeT)) {
1022
- return;
1023
- }
1024
-
1025
- //get impression threshold
1026
- $impression_threshold = $this->ga_imTh;
1027
 
1028
- //Product impression on Home Page
1029
- global $homepage_json_fp,$homepage_json_ATC_link, $homepage_json_rp,$prodpage_json_relProd,$catpage_json,$prodpage_json_ATC_link,$catpage_json_ATC_link;
1030
- //home page json for featured products and recent product sections
1031
- //check if php array is empty
1032
- if(empty($homepage_json_ATC_link)){
1033
- $homepage_json_ATC_link=array(); //define empty array so if empty then in json will be []
1034
- }
1035
- if(empty($homepage_json_fp)){
1036
- $homepage_json_fp=array(); //define empty array so if empty then in json will be []
1037
- }
1038
- if(empty($homepage_json_rp)){ //home page recent product array
1039
- $homepage_json_rp=array();
1040
- }
1041
- if(empty($prodpage_json_relProd)){ //prod page related section array
1042
- $prodpage_json_relProd=array();
1043
- }
1044
- if(empty($prodpage_json_ATC_link)){
1045
- $prodpage_json_ATC_link=array(); //prod page ATC link json
1046
- }
1047
- if(empty($catpage_json)){ //category page array
1048
- $catpage_json=array();
1049
- }
1050
- if(empty($catpage_json_ATC_link)){ //category page array
1051
- $catpage_json_ATC_link=array();
1052
- }
1053
- //home page json
1054
- $this->wc_version_compare("homepage_json_ATC_link=" . json_encode($homepage_json_ATC_link) . ";");
1055
- $this->wc_version_compare("tvc_fp=" . json_encode($homepage_json_fp) . ";");
1056
- $this->wc_version_compare("tvc_rcp=" . json_encode($homepage_json_rp) . ";");
1057
- //product page json
1058
- $this->wc_version_compare("tvc_rdp=" . json_encode($prodpage_json_relProd) . ";");
1059
- $this->wc_version_compare("prodpage_json_ATC_link=" . json_encode($prodpage_json_ATC_link) . ";");
1060
- //category page json
1061
- $this->wc_version_compare("tvc_pgc=" . json_encode($catpage_json) . ";");
1062
- $this->wc_version_compare("catpage_json_ATC_link=" . json_encode($catpage_json_ATC_link) . ";");
1063
- if($this->ga_id || $this->tracking_option == "UA" || $this->tracking_option == "BOTH") {
1064
- $hmpg_impressions_jQ = '
1065
- var items = [];
1066
- //set local currencies
1067
- gtag("set", {"currency": tvc_lc});
1068
- function t_products_impre_clicks(t_json_name,t_action){
1069
- t_send_threshold=0;
1070
- t_prod_pos=0;
1071
- t_json_length=Object.keys(t_json_name).length;
1072
-
1073
- for(var t_item in t_json_name) {
1074
- t_send_threshold++;
1075
- t_prod_pos++;
1076
- items.push({
1077
- "id": t_json_name[t_item].tvc_i,
1078
- "name": t_json_name[t_item].tvc_n,
1079
- "category": t_json_name[t_item].tvc_c,
1080
- "price": t_json_name[t_item].tvc_p,
1081
- });
1082
-
1083
- if(t_json_length > ' . esc_js($impression_threshold) .' ){
1084
-
1085
- if((t_send_threshold%' . esc_js($impression_threshold) . ')==0){
1086
- t_json_length=t_json_length-' . esc_js($impression_threshold) . ';
1087
- gtag("event", "view_item_list", { "event_category":"Enhanced-Ecommerce",
1088
- "event_label":"product_impression_"+t_action, "items":items,"non_interaction": true});
1089
- items = [];
1090
- }
1091
- if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1092
- gtag("event","view_item_list", {
1093
- "value": t_json_name[t_item].tvc_p,
1094
- "items": [
1095
- {
1096
- "id": t_json_name[t_item].tvc_id,
1097
- "google_business_vertical": "retail"
1098
- }
1099
- ]
1100
- });
1101
- }
1102
- }else{
1103
-
1104
- t_json_length--;
1105
- if(t_json_length==0){
1106
- gtag("event", "view_item_list", { "event_category":"Enhanced-Ecommerce",
1107
- "event_label":"product_impression_"+t_action, "items":items,"non_interaction": true});
1108
- items = [];
1109
- }
1110
- if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1111
- gtag("event","view_item_list", {
1112
- "value": t_json_name[t_item].tvc_p,
1113
- "items": [
1114
- {
1115
- "id": t_json_name[t_item].tvc_id,
1116
- "google_business_vertical": "retail"
1117
- }
1118
- ]
1119
- });
1120
- }
1121
- }
1122
- }
1123
- }
1124
-
1125
- //function for comparing urls in json object
1126
- function prod_exists_in_JSON(t_url,t_json_name,t_action){
1127
- if(t_json_name.hasOwnProperty(t_url)){
1128
- t_call_fired=true;
1129
- gtag("event", "select_content", {
1130
- "event_category":"Enhanced-Ecommerce",
1131
- "event_label":"product_click_"+t_action,
1132
- "content_type": "product",
1133
- "items": [
1134
  {
1135
- "id":t_json_name[t_url].tvc_i,
1136
- "name": t_json_name[t_url].tvc_n,
1137
- "category":t_json_name[t_url].tvc_c,
1138
- "price": t_json_name[t_url].tvc_p,
1139
  }
1140
- ],
1141
- "non_interaction": true
1142
- });
1143
- }else{
1144
- t_call_fired=false;
1145
- }
1146
- return t_call_fired;
1147
- }
1148
- function prod_ATC_link_exists(t_url,t_ATC_json_name,t_prod_data_json,t_qty){
1149
- t_prod_url_key=t_ATC_json_name[t_url]["ATC-link"];
1150
-
1151
- if(t_prod_data_json.hasOwnProperty(t_prod_url_key)){
1152
- t_call_fired=true;
1153
- // Enhanced E-commerce Add to cart clicks
1154
- gtag("event", "add_to_cart", {
1155
- "event_category":"Enhanced-Ecommerce",
1156
- "event_label":"add_to_cart_click",
1157
- "non_interaction": true,
1158
- "items": [{
1159
- "id" : t_prod_data_json[t_prod_url_key].tvc_i,
1160
- "name":t_prod_data_json[t_prod_url_key].tvc_n,
1161
- "category" : t_prod_data_json[t_prod_url_key].tvc_c,
1162
- "price": t_prod_data_json[t_prod_url_key].tvc_p,
1163
- "quantity" :t_qty
1164
- }]
1165
- });
1166
- if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1167
- gtag("event","add_to_cart", {
1168
- "value": t_prod_data_json[t_prod_url_key].tvc_p,
1169
- "items": [
 
 
 
 
 
1170
  {
1171
- "id": t_prod_data_json[t_prod_url_key].tvc_id,
1172
- "google_business_vertical": "retail"
 
 
1173
  }
1174
- ]
1175
- });
1176
- }
1177
-
1178
- }else{
1179
- t_call_fired=false;
1180
- }
1181
- return t_call_fired;
1182
-
1183
- }
1184
-
1185
- ';
1186
- }
1187
- if($this->gm_id && $this->tracking_option == "GA4") {
1188
- $hmpg_impressions_jQ = '
1189
- var items = [];
1190
- function t_products_impre_clicks(t_json_name,t_action){
1191
- t_send_threshold=0;
1192
- t_prod_pos=0;
1193
- t_json_length=Object.keys(t_json_name).length;
1194
- for(var t_item in t_json_name) {
1195
- t_send_threshold++;
1196
- t_prod_pos++;
1197
- items.push({
1198
- "item_id": t_json_name[t_item].tvc_i,
1199
- "item_name": t_json_name[t_item].tvc_n,
1200
- "item_category": t_json_name[t_item].tvc_c,
1201
- "price": t_json_name[t_item].tvc_p,
1202
- "currency": tvc_lc
1203
- });
1204
- if(t_json_length > ' . esc_js($impression_threshold) . ' ){
1205
- if((t_send_threshold%' . esc_js($impression_threshold) . ')==0){
1206
- t_json_length=t_json_length-' . esc_js($impression_threshold) . ';
1207
- gtag("event", "view_item_list", {
1208
- "event_category":"Enhanced-Ecommerce",
1209
- "event_label":"product_impression_"+t_action,
1210
- "items":items,
1211
- "non_interaction": true
1212
- });
1213
- items = [];
1214
- }
1215
- if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1216
- gtag("event","view_item_list", {
1217
- "value": t_json_name[t_item].tvc_p,
1218
- "items": [
1219
- {
1220
- "id": t_json_name[t_item].tvc_id,
1221
- "google_business_vertical": "retail"
1222
- }
1223
- ]
1224
- });
1225
- }
1226
- }else{
1227
- t_json_length--;
1228
- if(t_json_length==0){
1229
- gtag("event", "view_item_list", {
1230
- "event_category":"Enhanced-Ecommerce",
1231
- "event_label":"product_impression_"+t_action,
1232
- "items":items,
1233
- "non_interaction": true
1234
- });
1235
- items = [];
1236
- }
1237
- if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1238
- gtag("event","view_item_list", {
1239
- "value": t_json_name[t_item].tvc_p,
1240
- "items": [
1241
- {
1242
- "id": t_json_name[t_item].tvc_id,
1243
- "google_business_vertical": "retail"
1244
  }
1245
- ]
1246
- });
1247
- }
1248
- }
1249
- }
1250
- }
1251
-
1252
- //function for comparing urls in json object
1253
- function prod_exists_in_JSON(t_url,t_json_name,t_action){
1254
- if(t_json_name.hasOwnProperty(t_url)){
1255
- t_call_fired=true;
1256
- gtag("event", "select_item", {
1257
- "event_category":"Enhanced-Ecommerce",
1258
- "event_label":"product_click_"+t_action,
1259
- "items": [
1260
- {
1261
- "item_id":t_json_name[t_url].tvc_i,
1262
- "item_name": t_json_name[t_url].tvc_n,
1263
- "item_category":t_json_name[t_url].tvc_c,
1264
- "price": t_json_name[t_url].tvc_p,
1265
- "currency": tvc_lc
1266
- }
1267
- ],
1268
- "non_interaction": true
1269
- });
1270
-
1271
- }else{
1272
- t_call_fired=false;
1273
- }
1274
- return t_call_fired;
1275
- }
1276
- function prod_ATC_link_exists(t_url,t_ATC_json_name,t_prod_data_json,t_qty){
1277
- t_prod_url_key=t_ATC_json_name[t_url]["ATC-link"];
1278
- if(t_prod_data_json.hasOwnProperty(t_prod_url_key)){
1279
- t_call_fired=true;
1280
- // Enhanced E-commerce Add to cart clicks
1281
- gtag("event", "add_to_cart", {
1282
- "event_category":"Enhanced-Ecommerce",
1283
- "event_label":"add_to_cart_click",
1284
- "non_interaction": true,
1285
- "items": [{
1286
- "item_id" : t_prod_data_json[t_prod_url_key].tvc_i,
1287
- "item_name":t_prod_data_json[t_prod_url_key].tvc_n,
1288
- "item_category" : t_prod_data_json[t_prod_url_key].tvc_c,
1289
- "price": t_prod_data_json[t_prod_url_key].tvc_p,
1290
- "currency": tvc_lc,
1291
- "quantity" :t_qty
1292
- }]
1293
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1294
 
1295
- if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1296
- gtag("event","add_to_cart", {
1297
- "value": t_prod_data_json[t_prod_url_key].tvc_p,
1298
- "items": [
1299
- {
1300
- "id": t_prod_data_json[t_prod_url_key].tvc_id,
1301
- "google_business_vertical": "retail"
1302
- }
1303
- ]
1304
- });
1305
- }
1306
- }else{
1307
- t_call_fired=false;
1308
- }
1309
- return t_call_fired;
1310
- }
1311
- ';
1312
- }
1313
- if(is_home() || is_front_page()){
1314
- $hmpg_impressions_jQ .='
1315
- if(tvc_fp.length !== 0){
1316
- t_products_impre_clicks(tvc_fp,"fp");
1317
- }
1318
- if(tvc_rcp.length !== 0){
1319
- t_products_impre_clicks(tvc_rcp,"rp");
1320
- }
1321
- jQuery("a:not([href*=add-to-cart],.product_type_variable, .product_type_grouped)").on("click",function(){
1322
- t_url=jQuery(this).attr("href");
1323
- //home page call for click
1324
- t_call_fired=prod_exists_in_JSON(t_url,tvc_fp,"fp");
1325
- if(!t_call_fired){
1326
- prod_exists_in_JSON(t_url,tvc_rcp,"rp");
1327
- }
1328
- });
1329
- //ATC click
1330
- jQuery("a[href*=add-to-cart]").on("click",function(){
1331
- t_url=jQuery(this).attr("href");
1332
- t_qty=$(this).parent().find("input[name=quantity]").val();
1333
- //default quantity 1 if quantity box is not there
1334
- if(t_qty=="" || t_qty===undefined){
1335
- t_qty="1";
1336
- }
1337
- t_call_fired=prod_ATC_link_exists(t_url,homepage_json_ATC_link,tvc_fp,t_qty);
1338
- if(!t_call_fired){
1339
- prod_ATC_link_exists(t_url,homepage_json_ATC_link,tvc_rcp,t_qty);
1340
- }
1341
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1342
 
1343
- ';
1344
- }else if(is_search()){
1345
- $hmpg_impressions_jQ .='
1346
- //search page json
1347
- if(tvc_pgc.length !== 0){
1348
- t_products_impre_clicks(tvc_pgc,"srch");
1349
- }
1350
- //search page prod click
1351
- jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
1352
- t_url=jQuery(this).attr("href");
1353
- //cat page prod call for click
1354
- prod_exists_in_JSON(t_url,tvc_pgc,"srch");
1355
- });
1356
-
1357
- ';
1358
- }else if (is_product()) {
1359
- //product page releted products
1360
- $hmpg_impressions_jQ .='
1361
- if(tvc_rdp.length !== 0){
1362
- t_products_impre_clicks(tvc_rdp,"rdp");
1363
- }
1364
- //product click - image and product name
1365
- jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
1366
- t_url=jQuery(this).attr("href");
1367
- //prod page related call for click
1368
- prod_exists_in_JSON(t_url,tvc_rdp,"rdp");
1369
- });
1370
- //Prod ATC link click in related product section
1371
- jQuery("a[href*=add-to-cart]").on("click",function(){
1372
- t_url=jQuery(this).attr("href");
1373
-
1374
- t_qty=$(this).parent().find("input[name=quantity]").val();
1375
- //default quantity 1 if quantity box is not there
1376
- if(t_qty=="" || t_qty===undefined){
1377
- t_qty="1";
1378
- }
1379
- prod_ATC_link_exists(t_url,prodpage_json_ATC_link,tvc_rdp,t_qty);
1380
- });
1381
- ';
1382
- }else if (is_product_category()) {
1383
- $hmpg_impressions_jQ .='
1384
- //category page json
1385
- if(tvc_pgc.length !== 0){
1386
- t_products_impre_clicks(tvc_pgc,"cp");
1387
- }
1388
- //Prod category ATC link click in related product section
1389
- jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
1390
- t_url=jQuery(this).attr("href");
1391
- //cat page prod call for click
1392
- prod_exists_in_JSON(t_url,tvc_pgc,"cp");
1393
- });
1394
-
1395
- ';
1396
- }else if(is_shop()){
1397
- $hmpg_impressions_jQ .='
1398
- //shop page json
1399
- if(tvc_pgc.length !== 0){
1400
- t_products_impre_clicks(tvc_pgc,"sp");
1401
- }
1402
- //shop page prod click
1403
- jQuery("a:not(.product_type_variable, .product_type_grouped)").on("click",function(){
1404
- t_url=jQuery(this).attr("href");
1405
- //cat page prod call for click
1406
- prod_exists_in_JSON(t_url,tvc_pgc,"sp");
1407
- });
1408
-
1409
-
1410
- ';
1411
- }
1412
- //common ATC link for Category page , Shop Page and Search Page
1413
- if(is_product_category() || is_shop() || is_search()){
1414
- $hmpg_impressions_jQ .='
1415
- //ATC link click
1416
- jQuery("a[href*=add-to-cart]").on("click",function(){
1417
- t_url=jQuery(this).attr("href");
1418
- t_qty=$(this).parent().find("input[name=quantity]").val();
1419
- //default quantity 1 if quantity box is not there
1420
- if(t_qty=="" || t_qty===undefined){
1421
- t_qty="1";
1422
- }
1423
- prod_ATC_link_exists(t_url,catpage_json_ATC_link,tvc_pgc,t_qty);
1424
- });
1425
- ';
1426
- }
1427
- //on home page, product page , category page
1428
- if (is_home() || is_front_page() || is_product() || is_product_category() || is_search() || is_shop()){
1429
- $this->wc_version_compare($hmpg_impressions_jQ);
1430
- }
1431
- }
1432
 
1433
  /**
1434
  * Enhanced E-commerce tracking for remove from cart
@@ -1443,45 +1360,31 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1443
  global $woocommerce;
1444
  $cartpage_prod_array_main = array();
1445
  foreach ($woocommerce->cart->cart_contents as $key => $item) {
1446
- //Version compare
1447
- if (version_compare($woocommerce->version, "2.7", "<")) {
1448
- $prod_meta = get_product($item["product_id"]);
1449
- } else {
1450
- $prod_meta = wc_get_product($item["product_id"]);
1451
- }
1452
- if (version_compare($woocommerce->version, "3.3", "<")) {
1453
- $cart_remove_link=html_entity_decode($woocommerce->cart->get_remove_url($key));
1454
- } else {
1455
- $cart_remove_link=html_entity_decode(wc_get_cart_remove_url($key));
1456
- }
1457
- $category = get_the_terms($item["product_id"], "product_cat");
1458
- $categories = "";
1459
- if ($category) {
1460
- foreach ($category as $term) {
1461
- $categories.=$term->name . ",";
1462
- }
1463
- }
1464
- //remove last comma(,) if multiple categories are there
1465
- $categories = rtrim($categories, ",");
1466
- if(version_compare($woocommerce->version, "2.7", "<")){
1467
- $cartpage_prod_array_main[$cart_remove_link] =array(
1468
- "tvc_id" => esc_js($prod_meta->ID),
1469
- "tvc_i" => esc_js($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->ID),
1470
- "tvc_n" => html_entity_decode(esc_js($prod_meta->get_title())),
1471
- "tvc_p" => esc_js($prod_meta->get_price()),
1472
- "tvc_c" => esc_js($categories),
1473
- "tvc_q"=> esc_js($woocommerce->cart->cart_contents[$key]["quantity"])
1474
- );
1475
- }else{
1476
- $cartpage_prod_array_main[$cart_remove_link] =array(
1477
- "tvc_id" => esc_js($prod_meta->get_id()),
1478
- "tvc_i" => esc_js($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->get_id()),
1479
- "tvc_n" => html_entity_decode(esc_js($prod_meta->get_title())),
1480
- "tvc_p" => esc_js($prod_meta->get_price()),
1481
- "tvc_c" => esc_js($categories),
1482
- "tvc_q"=>esc_js($woocommerce->cart->cart_contents[$key]["quantity"])
1483
- );
1484
  }
 
 
 
 
 
 
 
 
 
 
 
1485
  }
1486
 
1487
  //Cart Page item Array to Json
@@ -1537,65 +1440,65 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1537
  }
1538
  }
1539
 
1540
- /**
1541
- * Enhanced E-commerce tracking checkout step 1
1542
- *
1543
- * @access public
1544
- * @return void
1545
- */
1546
- public function checkout_step_1_tracking() {
1547
- if ($this->disable_tracking($this->ga_eeT)) {
1548
- return;
1549
- }
1550
- //call fn to make json
1551
- $this->get_ordered_items();
1552
- if($this->ga_id || $this->tracking_option == "UA" || $this->tracking_option == "BOTH") {
1553
- $code= '
1554
- var items = [];
1555
- gtag("set", {"currency": tvc_lc});
1556
- for(var t_item in tvc_ch){
1557
- items.push({
1558
- "id": tvc_ch[t_item].tvc_i,
1559
- "name": tvc_ch[t_item].tvc_n,
1560
- "category": tvc_ch[t_item].tvc_c,
1561
- "attributes": tvc_ch[t_item].tvc_attr,
1562
- "price": tvc_ch[t_item].tvc_p,
1563
- "quantity": tvc_ch[t_item].tvc_q
1564
- });
1565
- }';
1566
-
1567
- $code_step_1 = $code . 'gtag("event", "begin_checkout", {"event_category":"Enhanced-Ecommerce",
1568
- "event_label":"checkout_step_1","items":items,"non_interaction": true });';
1569
-
1570
- //check woocommerce version and add code
1571
- $this->wc_version_compare($code_step_1);
1572
- }
1573
 
1574
- if( $this->gm_id && $this->tracking_option == "GA4") {
1575
- $code = '
1576
- var items = [];
1577
- for(var t_item in tvc_ch){
1578
- items.push({
1579
- "item_id": tvc_ch[t_item].tvc_i,
1580
- "item_name": tvc_ch[t_item].tvc_n,
1581
- "item_category": tvc_ch[t_item].tvc_c,
1582
- "item_variant": tvc_ch[t_item].tvc_attr,
1583
- "price": tvc_ch[t_item].tvc_p,
1584
- "quantity": tvc_ch[t_item].tvc_q
1585
- });
1586
- }';
1587
 
1588
- $code_step_1 = $code . 'gtag("event", "begin_checkout", {
1589
- "event_category":"Enhanced-Ecommerce",
1590
- "event_label":"checkout_step_1",
1591
- "items":items,
1592
- "non_interaction": true
1593
- });';
1594
 
1595
- //check woocommerce version and add code
1596
- $this->wc_version_compare($code_step_1);
1597
- }
1598
- }
1599
 
1600
  /**
1601
  * Enhanced E-commerce tracking checkout step 2
@@ -1604,8 +1507,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1604
  * @return void
1605
  */
1606
  public function checkout_step_2_tracking() {
1607
- if ($this->disable_tracking($this->ga_eeT)) {
1608
- return;
1609
  }
1610
  if($this->ga_id || $this->tracking_option == "UA" || $this->tracking_option == "BOTH" || $this->gm_id) {
1611
  $code= '
@@ -1643,10 +1546,9 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1643
  * @access public
1644
  * @return void
1645
  */
1646
- public function checkout_step_3_tracking() {
1647
-
1648
- if ($this->disable_tracking($this->ga_eeT)) {
1649
- return;
1650
  }
1651
  if($this->ga_id || $this->tracking_option == "UA" || $this->tracking_option == "BOTH" || $this->gm_id) {
1652
  $code= '
@@ -1692,43 +1594,27 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1692
  $code = "";
1693
  //get all items added into the cart
1694
  foreach ($woocommerce->cart->cart_contents as $item) {
1695
- //Version Compare
1696
- if ( version_compare($woocommerce->version, "2.7", "<")) {
1697
- $p = get_product($item["product_id"]);
1698
- } else {
1699
- $p = wc_get_product($item["product_id"]);
1700
- }
1701
-
1702
- $category = get_the_terms($item["product_id"], "product_cat");
1703
- $categories = "";
1704
- if ($category) {
1705
- foreach ($category as $term) {
1706
- $categories.=$term->name . ",";
1707
- }
1708
- }
1709
- //remove last comma(,) if multiple categories are there
1710
- $categories = rtrim($categories, ",");
1711
- if(version_compare($woocommerce->version, "2.7", "<")){
1712
- $chkout_json[get_permalink($p->ID)] = array(
1713
- "tvc_id" => esc_js($p->ID),
1714
- "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->ID),
1715
- "tvc_n" => html_entity_decode(esc_js($p->get_title())),
1716
- "tvc_p" => esc_js($p->get_price()),
1717
- "tvc_c" => esc_js($categories),
1718
- "tvc_q" => esc_js($item["quantity"]),
1719
- "isfeatured"=>esc_js($p->is_featured())
1720
- );
1721
- }else{
1722
- $chkout_json[get_permalink($p->get_id())] = array(
1723
- "tvc_id" => esc_js($p->get_id()),
1724
- "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->get_id()),
1725
- "tvc_n" => html_entity_decode(esc_js($p->get_title())),
1726
- "tvc_p" => esc_js($p->get_price()),
1727
- "tvc_c" => esc_js($categories),
1728
- "tvc_q" => esc_js($item["quantity"]),
1729
- "isfeatured"=>esc_js($p->is_featured())
1730
- );
1731
  }
 
 
 
 
 
 
 
 
 
 
 
 
1732
  }
1733
  //return $code;
1734
  //make product data json on check out page
64
  protected $remarketing_snippet_id;
65
  protected $remarketing_snippets;
66
  protected $conversio_send_to;
67
+ protected $tvc_conversion_tracking_type;
68
+
69
+ protected $ee_options;
70
 
71
  /**
72
  * Enhanced_Ecommerce_Google_Analytics_Public constructor.
78
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
79
  $this->plugin_name = sanitize_text_field($plugin_name);
80
  $this->version = sanitize_text_field($version);
81
+ $this->ee_options = $this->TVC_Admin_Helper->get_ee_options_settings();
82
+ $this->tvc_conversion_tracking_type = sanitize_text_field($this->get_option("tvc_conversion_tracking_type"));
83
  $this->tvc_call_hooks();
84
 
85
  $this->ga_Dname = "auto";
111
  $this->remarketing_snippets = base64_decode($remarketing['snippets']);
112
  $this->remarketing_snippet_id = sanitize_text_field(isset($remarketing['id'])?esc_attr($remarketing['id']):"");
113
  }
114
+
115
+ $this->ga_LC = get_woocommerce_currency(); //Local Currency from Back end
116
+ $this->wc_version_compare("tvc_lc=" . json_encode(esc_js($this->ga_LC)) . ";");
117
+ /*
118
+ * start tvc_options
119
+ */
120
+ $current_user = wp_get_current_user();
121
+ //$current_user ="";
122
+ $user_id = "";
123
+ $user_type = "guest_user";
124
+ if ( isset($current_user->ID) && $current_user->ID != 0 ) {
125
+ $user_id = $current_user->ID;
126
+ $current_user_type = 'register_user';
127
+ }
128
+ $this->tvc_options = array(
129
+ "feature_product_label"=>esc_html__("Feature Product"),
130
+ "on_sale_label"=>esc_html__("On Sale"),
131
+ "affiliation"=>esc_js(get_bloginfo('name')),
132
+ "local_time"=>esc_js(time()),
133
+ "is_admin"=>esc_attr(is_admin()),
134
+ "currency"=>esc_js($this->ga_LC),
135
+ "tracking_option"=>esc_js($this->tracking_option),
136
+ "property_id"=>esc_js($this->ga_id),
137
+ "measurement_id"=>esc_js($this->gm_id),
138
+ "google_ads_id"=>esc_js($this->google_ads_id),
139
+ "google_merchant_center_id"=>esc_js($this->google_merchant_id),
140
+ "o_add_gtag_snippet"=>esc_js($this->ga_ST),
141
+ "o_enhanced_e_commerce_tracking"=>esc_js($this->ga_eeT),
142
+ "o_log_step_gest_user"=>esc_js($this->ga_gUser),
143
+ "o_impression_thresold"=>esc_js($this->ga_imTh),
144
+ "o_ip_anonymization"=>esc_js($this->ga_IPA),
145
+ "o_ga_OPTOUT"=>esc_js($this->ga_OPTOUT),
146
+ "ads_tracking_id"=>esc_js($this->ads_tracking_id),
147
+ "remarketing_tags"=>esc_js($this->ads_ert),
148
+ "dynamic_remarketing_tags"=>esc_js($this->ads_edrt),
149
+ "google_ads_conversion_tracking"=>esc_js($this->google_ads_conversion_tracking),
150
+ "conversio_send_to"=>esc_js($this->conversio_send_to),
151
+ "page_type"=>esc_js($this->add_page_type()),
152
+ "user_id"=>esc_js($user_id),
153
+ "user_type"=>esc_js($user_type),
154
+ "day_type"=>esc_js($this->add_day_type()),
155
+ "remarketing_snippet_id"=>esc_js($this->remarketing_snippet_id),
156
+ "tvc_ajax_url"=>esc_url_raw(admin_url( 'admin-ajax.php' ))
157
+ );
158
+ /*
159
+ * end tvc_options
160
+ */
161
+
 
 
 
162
  }
163
 
164
  public function tvc_call_hooks(){
168
 
169
  add_action("wp_footer", array($this, "t_products_impre_clicks"));
170
  add_action("woocommerce_after_shop_loop_item", array($this, "bind_product_metadata"));
171
+ if($this->tvc_conversion_tracking_type == "on-thankyou-page"){
172
+ add_action("wp_head", array($this, "ecommerce_tracking_code"));
173
+ }else{
174
+ add_action("woocommerce_thankyou", array($this, "ecommerce_tracking_code"));
175
+ }
176
+ //add_action("woocommerce_after_single_product", array($this, "product_detail_view"));
177
+ add_action("wp_head", array($this, "product_detail_view"));
178
  add_action("woocommerce_after_cart", array($this, "remove_cart_tracking"));
179
  //check out step 1,2,3
180
+ //add_action("woocommerce_before_checkout_form", array($this, "checkout_step_1_tracking"));
181
+ //add_action("woocommerce_before_checkout_form", array($this, "checkout_step_2_tracking"));
182
+ //add_action("woocommerce_before_checkout_form", array($this, "checkout_step_3_tracking"));
183
+ add_action("wp_head", array($this, "checkout_step_1_tracking"));
184
+ add_action("wp_head", array($this, "checkout_step_2_tracking"));
185
+ add_action("wp_head", array($this, "checkout_step_3_tracking"));
186
  add_action("woocommerce_after_add_to_cart_button", array($this, "add_to_cart"));
187
  //add version details in footer
188
  add_action("wp_footer", array($this, "add_plugin_details"));
295
  }
296
  }
297
  public function get_option($key){
298
+ if(empty($this->ee_options)){
299
+ $this->ee_options = $this->TVC_Admin_Helper->get_ee_options_settings();
 
 
 
300
  }
301
+ if(isset($this->ee_options[$key])){
302
+ return $this->ee_options[$key];
303
  }
304
  }
305
  /**
403
  * @return void
404
  */
405
  function wc_version_compare($codeSnippet) {
406
+ global $woocommerce;
407
+ if (version_compare($woocommerce->version, "2.1", ">=")) {
408
+ wc_enqueue_js($codeSnippet);
409
+ } else {
410
+ $woocommerce->add_inline_js($codeSnippet);
411
+ }
 
412
  }
413
  /**
414
  * Enhanced Ecommerce GA plugin Settings
420
  global $woocommerce;
421
  //common validation----start
422
  if (is_admin() || $this->ga_ST == "" || current_user_can("manage_options") || !$this->ga_PrivacyPolicy) {
423
+ return;
424
  }
425
  // IP Anonymization
426
  if ($this->ga_IPA) {
559
  }
560
  }
561
  }
562
+ protected function tvc_get_order_with_url_order_key(){
563
+ $_get = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
564
+ if ( isset( $_get['key'] ) ) {
565
+ $order_key = $_get['key'];
566
+ return wc_get_order( wc_get_order_id_by_order_key( $order_key ) );
567
+ }
568
+ }
569
+ protected function tvc_get_order_from_query_vars(){
570
+ global $wp ;
571
+ $order_id = absint( $wp->query_vars['order-received'] );
572
+ if ( $order_id && 0 != $order_id && wc_get_order( $order_id ) ) {
573
+ return wc_get_order( $order_id );
574
+ }
575
+ }
576
+ protected function tvc_get_order_from_order_received_page(){
577
+ if ( $this->tvc_get_order_from_query_vars() ) {
578
+ return $this->tvc_get_order_from_query_vars();
579
+ } else {
580
+ if ( $this->tvc_get_order_with_url_order_key() ) {
581
+ return $this->tvc_get_order_with_url_order_key();
582
+ } else {
583
+ return false;
584
+ }
585
+ }
586
+ }
587
 
588
+ /*protected function tvc_get_order_id(){
589
+ global $wp ;
590
+ $order_id = absint( $wp->query_vars['order-received'] );
591
+ if ( $order_id && 0 != $order_id && wc_get_order( $order_id ) ) {
592
+ return wc_get_order( $order_id );
593
+ }else{
594
+ $_get = filter_input_array( INPUT_GET, FILTER_SANITIZE_STRING );
595
+ if ( isset( $_get['key'] ) ) {
596
+ $order_key = $_get['key'];
597
+ return wc_get_order_id_by_order_key( $order_key );
598
+ }
599
+ }
600
+ }*/
601
  /**
602
  * Google Analytics eCommerce tracking
603
  *
605
  * @param mixed $order_id
606
  * @return void
607
  */
608
+ function ecommerce_tracking_code($order_id = null) {
609
  global $woocommerce;
610
+ $order = "";
611
+ if($order_id == null && is_order_received_page()){
612
+ $order = $this->tvc_get_order_from_order_received_page();
613
+ $order_id = $order->get_id();
614
+ }else{
615
+ $order = new WC_Order($order_id);
616
  }
617
+ if ($this->disable_tracking($this->ga_eeT) || current_user_can("manage_options") || get_post_meta($order_id, "_tracked", true) == 1 || !is_order_received_page() ){
618
+ return;
619
+ }
620
+ get_post_meta($order_id, "_tracked", true);
621
  // Doing eCommerce tracking so unhook standard tracking from the footer
622
  remove_action("wp_footer", array($this, "ee_settings"));
623
  /*
625
  * var tvc_oc
626
  */
627
  $orderpage_prod_Array = array();
628
+
629
  //Get Applied Coupon Codes
630
  $coupons_list = '';
631
  if(version_compare($woocommerce->version, "3.7", ">")){
660
  }
661
  }
662
  $categories=esc_js(join(",", $out));
663
+ $product_type =$_product->get_type();
 
 
 
 
 
664
  if($product_type == "variation"){
665
  $attributes=esc_js(wc_get_formatted_variation($_product->get_variation_attributes(), true));
666
  /*if ($_product->variation_has_weight) {
670
  /*if ($_product->has_weight()) {
671
  //$p_weight = $_product->get_weight().' '.esc_attr(get_option('woocommerce_weight_unit'));
672
  }*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
  }
674
+ $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
675
+ "tvc_id" => esc_js($_product->get_id()),
676
+ "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
677
+ "tvc_n" => esc_js($_product->get_title()),
678
+ "tvc_p" => esc_js($order->get_item_total($item)),
679
+ // "tvc_rp" => $_product->get_regular_price(),
680
+ // "tvc_sp" => $_product->get_sale_price(),
681
+ "tvc_pd" => esc_js($this->cal_prod_discount($_product->get_regular_price(), $_product->get_sale_price())),
682
+ "tvc_c" => esc_js($categories),
683
+ "tvc_attr" => esc_js($attributes),
684
+ "tvc_q"=>esc_js($item["qty"]),
685
+ //"tvc_wt" => $p_weight,
686
+ "tvc_var" => esc_js($this->getAttributesVariation($_product)),
687
+ /*"tvc_di" => $_product->get_dimensions(), //dimensions
688
+ "tvc_ss" => $_product->is_in_stock(),
689
+ "tvc_st" => $_product->get_stock_quantity(),
690
+ "tvc_tst" => $_product->get_total_stock(),
691
+ "tvc_rc" => $_product->get_rating_count(),
692
+ "tvc_rs" => $_product->get_average_rating()*/
693
+ );
694
+
695
  }
696
  //make json for prod meta data on order page
697
  $this->wc_version_compare("tvc_oc=" . json_encode($orderpage_prod_Array) . ";");
701
  * Get the trans data
702
  * Var tvc_td
703
  */
704
+ //get shipping cost
705
+ $tvc_sc = $order->get_total_shipping();
 
 
 
 
 
706
  $user_bill_addr="";
707
  $user_ship_addr="";
708
  if(isset($this->tvc_options["user_id"]) && $this->tvc_options["user_id"]!="" ){
776
  * @return void
777
  */
778
  public function product_detail_view() {
779
+ if ( $this->disable_tracking($this->ga_eeT) || !is_product() ) {
780
  return;
781
  }
782
+ global $wp_query, $woocommerce ;
783
+ $product = wc_get_product();
784
+ $category = get_the_terms($product->get_id(), "product_cat");
 
 
 
785
  $categories = "";
786
  if ($category) {
787
  foreach ($category as $term) {
791
  //remove last comma(,) if multiple categories are there
792
  $categories = rtrim($categories, ",");
793
  //product detail view json
794
+ $prodpage_detail_json = array(
795
+ "tvc_id" => esc_js($product->get_id()),
796
+ "tvc_i" => $product->get_sku() ? esc_js($product->get_sku()) : esc_js($product->get_id()),
797
+ "tvc_n" => esc_js($product->get_title()),
798
+ "tvc_c" => esc_js($categories),
799
+ "tvc_p" => esc_js($product->get_price()),
800
+ "tvc_pd" => esc_js($this->cal_prod_discount($product->get_regular_price(), $product->get_sale_price())),
801
+ "tvc_ps" => esc_js($product->get_stock_status()),
802
+ "tvc_tst" => esc_js($product->get_stock_quantity()),
803
+ "tvc_q" => esc_js($product->get_stock_quantity()),
804
+ "tvc_var" => esc_js($this->getAttributesVariation($product)),
805
+ "is_featured" => esc_js($product->is_featured()),
806
+ "is_onSale" => esc_js($product->is_on_sale())
807
+ );
808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
809
  //prod page detail view json
810
  $this->wc_version_compare("tvc_po=" . json_encode($prodpage_detail_json) . ";");
811
  ?>
819
  <?php
820
  }
821
 
822
+ /**
823
+ * Enhanced E-commerce tracking for product impressions on category pages (hidden fields) , product page (related section)
824
+ * home page (featured section and recent section)
825
+ *
826
+ * @access public
827
+ * @return void
828
+ */
829
+ public function bind_product_metadata() {
830
+ if ($this->disable_tracking($this->ga_eeT)) {
831
+ return;
832
+ }
 
 
 
 
 
 
 
 
 
833
 
834
+ global $product,$woocommerce;
835
+ $category = get_the_terms($product->get_id(), "product_cat");
836
+ $categories = "";
837
+ if ($category) {
838
+ foreach ($category as $term) {
839
+ $categories.=$term->name . ",";
840
  }
841
+ }
842
+ //remove last comma(,) if multiple categories are there
843
+ $categories = rtrim($categories, ",");
844
+ //declare all variable as a global which will used for make json
845
+ global $homepage_json_fp,$homepage_json_ATC_link, $homepage_json_rp,$prodpage_json_relProd,$catpage_json,$prodpage_json_ATC_link,$catpage_json_ATC_link;
846
+ //is home page then make all necessory json
847
+ if (is_home() || is_front_page()) {
848
+ if (!is_array($homepage_json_fp) && !is_array($homepage_json_rp) && !is_array($homepage_json_ATC_link)) {
849
+ $homepage_json_fp = array();
850
+ $homepage_json_rp = array();
851
+ $homepage_json_ATC_link=array();
852
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853
 
854
+ // ATC link Array
855
+ $homepage_json_ATC_link[$product->add_to_cart_url()]=
856
+ array(
857
+ "ATC-link"=>esc_url_raw(get_permalink($product->get_id()))
858
+ );
859
+
860
+ //check if product is featured product or not
861
+ if ($product->is_featured()) {
862
+ //check if product is already exists in homepage featured json
863
+ if(!array_key_exists(get_permalink($product->get_id()),$homepage_json_fp)){
864
+ $homepage_json_fp[get_permalink($product->get_id())] = array(
865
+ "tvc_id" => esc_js($product->get_id()),
866
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
867
+ "tvc_n" => esc_js($product->get_title()),
868
+ "tvc_p" => esc_js($product->get_price()),
869
+ "tvc_c" => esc_js($categories),
870
+ "ATC-link"=> esc_url_raw($product->add_to_cart_url())
871
+ );
872
+ //else add product in homepage recent product json
873
+ }else {
874
+ $homepage_json_rp[get_permalink($product->get_id())] =array(
875
+ "tvc_id" => esc_js($product->get_id()),
876
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
877
+ "tvc_n" => esc_js($product->get_title()),
878
+ "tvc_p" => esc_js($product->get_price()),
879
+ "tvc_c" => esc_js($categories)
880
+ );
881
  }
882
+ } else {
883
+ $homepage_json_rp[get_permalink($product->get_id())] =array(
884
+ "tvc_id" => esc_js($product->get_id()),
885
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
886
+ "tvc_n" => esc_js($product->get_title()),
887
+ "tvc_p" => esc_js($product->get_price()),
888
+ "tvc_c" => esc_js($categories)
889
+ );
890
+ }
891
+ } else if(is_product()){
892
+ //if product page then related product page array
893
+ if(!is_array($prodpage_json_relProd) && !is_array($prodpage_json_ATC_link)){
894
+ $prodpage_json_relProd = array();
895
+ $prodpage_json_ATC_link = array();
896
  }
897
+ // ATC link Array
898
+ $prodpage_json_ATC_link[$product->add_to_cart_url()]=
899
+ array(
900
+ "ATC-link"=> esc_url_raw(get_permalink($product->get_id()))
901
+ );
902
+ $prodpage_json_relProd[get_permalink($product->get_id())] = array(
903
+ "tvc_id" => esc_js($product->get_id()),
904
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
905
+ "tvc_n" => esc_js($product->get_title()),
906
+ "tvc_p" => esc_js($product->get_price()),
907
+ "tvc_c" => esc_js($categories)
908
+ );
909
+ } else if (is_product_category() || is_search() || is_shop()) {
910
+ //category page, search page and shop page json
911
+ if (!is_array($catpage_json) && !is_array($catpage_json_ATC_link)){
912
+ $catpage_json=array();
913
+ $catpage_json_ATC_link=array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
914
  }
915
+ //cat page ATC array
916
+ $catpage_json_ATC_link[$product->add_to_cart_url()]=
917
+ array(
918
+ "ATC-link"=>esc_url_raw(get_permalink($product->get_id()))
919
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
920
 
921
+ $catpage_json[get_permalink($product->get_id())] =array(
922
+ "tvc_id" => esc_js($product->get_id()),
923
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
924
+ "tvc_n" => esc_js($product->get_title()),
925
+ "tvc_p" => esc_js($product->get_price()),
926
+ "tvc_c" => esc_js($categories)
927
+ );
928
+ }
929
+ }
930
 
931
+ /**
932
+ * Enhanced E-commerce tracking for product impressions,clicks on Home pages
933
+ *
934
+ * @access public
935
+ * @return void
936
+ */
937
+ function t_products_impre_clicks() {
938
+ if ($this->disable_tracking($this->ga_eeT)) {
939
+ return;
940
  }
941
 
942
+ //get impression threshold
943
+ $impression_threshold = $this->ga_imTh;
 
 
 
 
 
 
 
 
 
 
 
944
 
945
+ //Product impression on Home Page
946
+ global $homepage_json_fp,$homepage_json_ATC_link, $homepage_json_rp,$prodpage_json_relProd,$catpage_json,$prodpage_json_ATC_link,$catpage_json_ATC_link;
947
+ //home page json for featured products and recent product sections
948
+ //check if php array is empty
949
+ if(empty($homepage_json_ATC_link)){
950
+ $homepage_json_ATC_link=array(); //define empty array so if empty then in json will be []
951
+ }
952
+ if(empty($homepage_json_fp)){
953
+ $homepage_json_fp=array(); //define empty array so if empty then in json will be []
954
+ }
955
+ if(empty($homepage_json_rp)){ //home page recent product array
956
+ $homepage_json_rp=array();
957
+ }
958
+ if(empty($prodpage_json_relProd)){ //prod page related section array
959
+ $prodpage_json_relProd=array();
960
+ }
961
+ if(empty($prodpage_json_ATC_link)){
962
+ $prodpage_json_ATC_link=array(); //prod page ATC link json
963
+ }
964
+ if(empty($catpage_json)){ //category page array
965
+ $catpage_json=array();
966
+ }
967
+ if(empty($catpage_json_ATC_link)){ //category page array
968
+ $catpage_json_ATC_link=array();
969
+ }
970
+ //home page json
971
+ $this->wc_version_compare("homepage_json_ATC_link=" . json_encode($homepage_json_ATC_link) . ";");
972
+ $this->wc_version_compare("tvc_fp=" . json_encode($homepage_json_fp) . ";");
973
+ $this->wc_version_compare("tvc_rcp=" . json_encode($homepage_json_rp) . ";");
974
+ //product page json
975
+ $this->wc_version_compare("tvc_rdp=" . json_encode($prodpage_json_relProd) . ";");
976
+ $this->wc_version_compare("prodpage_json_ATC_link=" . json_encode($prodpage_json_ATC_link) . ";");
977
+ //category page json
978
+ $this->wc_version_compare("tvc_pgc=" . json_encode($catpage_json) . ";");
979
+ $this->wc_version_compare("catpage_json_ATC_link=" . json_encode($catpage_json_ATC_link) . ";");
980
+ if($this->ga_id || $this->tracking_option == "UA" || $this->tracking_option == "BOTH") {
981
+ $hmpg_impressions_jQ = '
982
+ var items = [];
983
+ //set local currencies
984
+ gtag("set", {"currency": tvc_lc});
985
+ function t_products_impre_clicks(t_json_name,t_action){
986
+ t_send_threshold=0;
987
+ t_prod_pos=0;
988
+ t_json_length=Object.keys(t_json_name).length;
989
+
990
+ for(var t_item in t_json_name) {
991
+ t_send_threshold++;
992
+ t_prod_pos++;
993
+ items.push({
994
+ "id": t_json_name[t_item].tvc_i,
995
+ "name": t_json_name[t_item].tvc_n,
996
+ "category": t_json_name[t_item].tvc_c,
997
+ "price": t_json_name[t_item].tvc_p,
998
+ });
999
+
1000
+ if(t_json_length > ' . esc_js($impression_threshold) .' ){
1001
+
1002
+ if((t_send_threshold%' . esc_js($impression_threshold) . ')==0){
1003
+ t_json_length=t_json_length-' . esc_js($impression_threshold) . ';
1004
+ gtag("event", "view_item_list", { "event_category":"Enhanced-Ecommerce",
1005
+ "event_label":"product_impression_"+t_action, "items":items,"non_interaction": true});
1006
+ items = [];
1007
+ }
1008
+ if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1009
+ gtag("event","view_item_list", {
1010
+ "value": t_json_name[t_item].tvc_p,
1011
+ "items": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1012
  {
1013
+ "id": t_json_name[t_item].tvc_id,
1014
+ "google_business_vertical": "retail"
 
 
1015
  }
1016
+ ]
1017
+ });
1018
+ }
1019
+ }else{
1020
+
1021
+ t_json_length--;
1022
+ if(t_json_length==0){
1023
+ gtag("event", "view_item_list", { "event_category":"Enhanced-Ecommerce",
1024
+ "event_label":"product_impression_"+t_action, "items":items,"non_interaction": true});
1025
+ items = [];
1026
+ }
1027
+ if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1028
+ gtag("event","view_item_list", {
1029
+ "value": t_json_name[t_item].tvc_p,
1030
+ "items": [
1031
+ {
1032
+ "id": t_json_name[t_item].tvc_id,
1033
+ "google_business_vertical": "retail"
1034
+ }
1035
+ ]
1036
+ });
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+
1042
+ //function for comparing urls in json object
1043
+ function prod_exists_in_JSON(t_url,t_json_name,t_action){
1044
+ if(t_json_name.hasOwnProperty(t_url)){
1045
+ t_call_fired=true;
1046
+ gtag("event", "select_content", {
1047
+ "event_category":"Enhanced-Ecommerce",
1048
+ "event_label":"product_click_"+t_action,
1049
+ "content_type": "product",
1050
+ "items": [
1051
  {
1052
+ "id":t_json_name[t_url].tvc_i,
1053
+ "name": t_json_name[t_url].tvc_n,
1054
+ "category":t_json_name[t_url].tvc_c,
1055
+ "price": t_json_name[t_url].tvc_p,
1056
  }
1057
+ ],
1058
+ "non_interaction": true
1059
+ });
1060
+ }else{
1061
+ t_call_fired=false;
1062
+ }
1063
+ return t_call_fired;
1064
+ }
1065
+ function prod_ATC_link_exists(t_url,t_ATC_json_name,t_prod_data_json,t_qty){
1066
+ t_prod_url_key=t_ATC_json_name[t_url]["ATC-link"];
1067
+
1068
+ if(t_prod_data_json.hasOwnProperty(t_prod_url_key)){
1069
+ t_call_fired=true;
1070
+ // Enhanced E-commerce Add to cart clicks
1071
+ gtag("event", "add_to_cart", {
1072
+ "event_category":"Enhanced-Ecommerce",
1073
+ "event_label":"add_to_cart_click",
1074
+ "non_interaction": true,
1075
+ "items": [{
1076
+ "id" : t_prod_data_json[t_prod_url_key].tvc_i,
1077
+ "name":t_prod_data_json[t_prod_url_key].tvc_n,
1078
+ "category" : t_prod_data_json[t_prod_url_key].tvc_c,
1079
+ "price": t_prod_data_json[t_prod_url_key].tvc_p,
1080
+ "quantity" :t_qty
1081
+ }]
1082
+ });
1083
+ if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1084
+ gtag("event","add_to_cart", {
1085
+ "value": t_prod_data_json[t_prod_url_key].tvc_p,
1086
+ "items": [
1087
+ {
1088
+ "id": t_prod_data_json[t_prod_url_key].tvc_id,
1089
+ "google_business_vertical": "retail"
1090
+ }
1091
+ ]
1092
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1093
  }
1094
+
1095
+ }else{
1096
+ t_call_fired=false;
1097
+ }
1098
+ return t_call_fired;
1099
+
1100
+ }
1101
+
1102
+ ';
1103
+ }
1104
+ if($this->gm_id && $this->tracking_option == "GA4") {
1105
+ $hmpg_impressions_jQ = '
1106
+ var items = [];
1107
+ function t_products_impre_clicks(t_json_name,t_action){
1108
+ t_send_threshold=0;
1109
+ t_prod_pos=0;
1110
+ t_json_length=Object.keys(t_json_name).length;
1111
+ for(var t_item in t_json_name) {
1112
+ t_send_threshold++;
1113
+ t_prod_pos++;
1114
+ items.push({
1115
+ "item_id": t_json_name[t_item].tvc_i,
1116
+ "item_name": t_json_name[t_item].tvc_n,
1117
+ "item_category": t_json_name[t_item].tvc_c,
1118
+ "price": t_json_name[t_item].tvc_p,
1119
+ "currency": tvc_lc
1120
+ });
1121
+ if(t_json_length > ' . esc_js($impression_threshold) . ' ){
1122
+ if((t_send_threshold%' . esc_js($impression_threshold) . ')==0){
1123
+ t_json_length=t_json_length-' . esc_js($impression_threshold) . ';
1124
+ gtag("event", "view_item_list", {
1125
+ "event_category":"Enhanced-Ecommerce",
1126
+ "event_label":"product_impression_"+t_action,
1127
+ "items":items,
1128
+ "non_interaction": true
1129
+ });
1130
+ items = [];
1131
+ }
1132
+ if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1133
+ gtag("event","view_item_list", {
1134
+ "value": t_json_name[t_item].tvc_p,
1135
+ "items": [
1136
+ {
1137
+ "id": t_json_name[t_item].tvc_id,
1138
+ "google_business_vertical": "retail"
1139
+ }
1140
+ ]
1141
+ });
1142
+ }
1143
+ }else{
1144
+ t_json_length--;
1145
+ if(t_json_length==0){
1146
+ gtag("event", "view_item_list", {
1147
+ "event_category":"Enhanced-Ecommerce",
1148
+ "event_label":"product_impression_"+t_action,
1149
+ "items":items,
1150
+ "non_interaction": true
1151
+ });
1152
+ items = [];
1153
+ }
1154
+ if(adsTringId != "" && ( ads_ert == 1 || ads_edrt == 1)){
1155
+ gtag("event","view_item_list", {
1156
+ "value": t_json_name[t_item].tvc_p,
1157
+ "items": [
1158
+ {
1159
+ "id": t_json_name[t_item].tvc_id,
1160
+ "google_business_vertical": "retail"
1161
+ }
1162
+ ]
1163
+ });
1164
+ }
1165
+ }
1166
+ }
1167
+ }
1168
+
1169
+ //function for comparing urls in json object
1170
+ function prod_exists_in_JSON(t_url,t_json_name,t_action){
1171
+ if(t_json_name.hasOwnProperty(t_url)){
1172
+ t_call_fired=true;
1173
+ gtag("event", "select_item", {
1174
+ "event_category":"Enhanced-Ecommerce",
1175
+ "event_label":"product_click_"+t_action,
1176
+ "items": [
1177
+ {
1178