Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.0.1

Version Description

  • 06/08/2021 =
  • We have fixed Google Ads Conversion Tracking issue (Pro)
Download this release

Release Info

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

Code changes from version 4.0 to 4.0.1

admin/class-tvc-admin-helper.php CHANGED
@@ -34,8 +34,8 @@ Class TVC_Admin_Helper{
34
  * verstion auto updated
35
  */
36
  public function need_auto_update_db(){
37
- $old_ee_auto_update_id ="tvc_3.0.4";
38
- $new_ee_auto_update_id ="tvc_4.0.0";
39
  $ee_auto_update_id = get_option('ee_auto_update_id');
40
  if($ee_auto_update_id!=""){
41
  if( $ee_auto_update_id != $new_ee_auto_update_id){
@@ -174,6 +174,41 @@ Class TVC_Admin_Helper{
174
  }
175
  }
176
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  * import GMC products in DB
178
  */
179
  public function import_gmc_products_sync_in_db($next_page_token = null){
34
  * verstion auto updated
35
  */
36
  public function need_auto_update_db(){
37
+ $old_ee_auto_update_id = "tvc_3.0.4";
38
+ $new_ee_auto_update_id = "tvc_4.0.0";
39
  $ee_auto_update_id = get_option('ee_auto_update_id');
40
  if($ee_auto_update_id!=""){
41
  if( $ee_auto_update_id != $new_ee_auto_update_id){
174
  }
175
  }
176
  /*
177
+ * update conversion send_to
178
+ */
179
+ public function update_conversion_send_to(){
180
+ $customer_id = $this->get_currentCustomerId();
181
+ $merchant_id = $this->get_merchantId();
182
+ if($customer_id != "" && $merchant_id != ""){
183
+ $response = $this->customApiObj->get_conversion_list($customer_id, $merchant_id);
184
+
185
+ if(property_exists($response,"error") && $response->error == false){
186
+ if(property_exists($response,"data") && $response->data != "" && !empty($response->data)){
187
+ foreach ($response->data as $key => $value) {
188
+ $con_string=strip_tags($value->tagSnippets); //what i want is you
189
+ $con_string = trim(preg_replace('/\s\s+/', '', $con_string));
190
+ $con_string = str_replace(" ", "", $con_string);
191
+ $con_string = str_replace("'", "", $con_string);
192
+ $con_string = str_replace("return false;", "", $con_string);
193
+ $con_string = str_replace("event,conversion,{", ",event:conversion,", $con_string);
194
+ $con_array = explode(",", $con_string);
195
+ if(!empty($con_array) && in_array("event:conversion", $con_array)){
196
+ foreach ($con_array as $key => $con_value) {
197
+ $con_val_array = explode(":", $con_value);
198
+ if(in_array("send_to", $con_val_array)){
199
+ update_option("ee_conversio_send_to", $con_val_array[1]);
200
+ break 2;
201
+ }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+
208
+
209
+ }
210
+ }
211
+ /*
212
  * import GMC products in DB
213
  */
214
  public function import_gmc_products_sync_in_db($next_page_token = null){
admin/partials/general-fields.php CHANGED
@@ -26,7 +26,13 @@ if (isset($_GET['connect']) && isset($_GET['subscription_id'])) {
26
 
27
  if(property_exists($google_detail,"error") && $google_detail->error == false && !isset($_POST['ee_submit_plugin'])){
28
  if(property_exists($google_detail,"data") && $google_detail->data != ""){
 
 
 
29
  $googleDetail = $google_detail->data;
 
 
 
30
  //'website_url' => $googleDetail->site_url,
31
  $postData = [
32
  'merchant_id' => $googleDetail->merchant_id,
@@ -94,15 +100,21 @@ if (isset($_GET['connect']) && isset($_GET['subscription_id'])) {
94
  $_POST['ga_PrivacyPolicy'] = 'on';
95
  $_POST['google-analytic'] = '';
96
  //update option in wordpress local database
 
97
  update_option('ads_tracking_id', $googleDetail->google_ads_id);
98
  update_option('ads_ert', $googleDetail->remarketing_tags);
99
  update_option('ads_edrt', $googleDetail->dynamic_remarketing_tags);
100
  Enhanced_Ecommerce_Google_Settings::add_update_settings('ee_options');
101
- //save data in DB
 
 
102
  $TVC_Admin_Helper->set_update_api_to_db($googleDetail, false);
 
 
 
103
  $TVC_Admin_Helper->update_remarketing_snippets();
104
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
105
- if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != ""){
106
  wp_redirect("admin.php?page=enhanced-ecommerce-google-analytics-admin-display&tab=sync_product_page&welcome_msg=true");
107
  exit;
108
  }else{
@@ -179,8 +191,6 @@ if(isset($google_detail['setting'])){
179
  $plan_id = $googleDetail->plan_id;
180
  }
181
  }
182
-
183
-
184
  ?>
185
  <div class="tab-content">
186
  <?php if($message_p){
26
 
27
  if(property_exists($google_detail,"error") && $google_detail->error == false && !isset($_POST['ee_submit_plugin'])){
28
  if(property_exists($google_detail,"data") && $google_detail->data != ""){
29
+ /*
30
+ * function call for save conversion send to in WP DB
31
+ */
32
  $googleDetail = $google_detail->data;
33
+ if($googleDetail->plan_id != 1 && $googleDetail->google_ads_conversion_tracking == 1){
34
+ $TVC_Admin_Helper->update_conversion_send_to();
35
+ }
36
  //'website_url' => $googleDetail->site_url,
37
  $postData = [
38
  'merchant_id' => $googleDetail->merchant_id,
100
  $_POST['ga_PrivacyPolicy'] = 'on';
101
  $_POST['google-analytic'] = '';
102
  //update option in wordpress local database
103
+ update_option('google_ads_conversion_tracking', $googleDetail->google_ads_conversion_tracking);
104
  update_option('ads_tracking_id', $googleDetail->google_ads_id);
105
  update_option('ads_ert', $googleDetail->remarketing_tags);
106
  update_option('ads_edrt', $googleDetail->dynamic_remarketing_tags);
107
  Enhanced_Ecommerce_Google_Settings::add_update_settings('ee_options');
108
+ /*
109
+ * function call for save API data in WP DB
110
+ */
111
  $TVC_Admin_Helper->set_update_api_to_db($googleDetail, false);
112
+ /*
113
+ * function call for save remarketing snippets in WP DB
114
+ */
115
  $TVC_Admin_Helper->update_remarketing_snippets();
116
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
117
+ if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != ""){
118
  wp_redirect("admin.php?page=enhanced-ecommerce-google-analytics-admin-display&tab=sync_product_page&welcome_msg=true");
119
  exit;
120
  }else{
191
  $plan_id = $googleDetail->plan_id;
192
  }
193
  }
 
 
194
  ?>
195
  <div class="tab-content">
196
  <?php if($message_p){
enhanced-ecommerce-google-analytics.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Enhanced E-commerce for Woocommerce store
17
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
18
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
19
- * Version: 4.0
20
  * Author: Tatvic
21
  * Author URI: www.tatvic.com
22
  * License: GPL-2.0+
@@ -38,7 +38,7 @@ if ( ! defined( 'WPINC' ) ) {
38
  * Start at version 1.0.0 and use SemVer - https://semver.org
39
  * Rename this for your plugin and update it as you release new versions.
40
  */
41
- define( 'PLUGIN_TVC_VERSION', '4.0' );
42
  $fullName = plugin_basename( __FILE__ );
43
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
44
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
16
  * Plugin Name: Enhanced E-commerce for Woocommerce store
17
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
18
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
19
+ * Version: 4.0.1
20
  * Author: Tatvic
21
  * Author URI: www.tatvic.com
22
  * License: GPL-2.0+
38
  * Start at version 1.0.0 and use SemVer - https://semver.org
39
  * Rename this for your plugin and update it as you release new versions.
40
  */
41
+ define( 'PLUGIN_TVC_VERSION', '4.0.1' );
42
  $fullName = plugin_basename( __FILE__ );
43
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
44
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/setup/CustomApi.php CHANGED
@@ -342,6 +342,33 @@ class CustomApi{
342
  return $e->getMessage();
343
  }
344
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  public function verifyLicenceKey($licence_key, $subscription_id) {
346
  try {
347
  echo $url = $this->apiDomain . '/licence/verify-key';
342
  return $e->getMessage();
343
  }
344
  }
345
+ public function get_conversion_list($customer_id, $merchant_id) {
346
+ try {
347
+ $header = array(
348
+ "Authorization: Bearer MTIzNA==",
349
+ "content-type: application/json"
350
+ );
351
+ $curl_url = $this->apiDomain . "/google-ads/conversion-list";
352
+ $postData = [
353
+ 'merchant_id' => $merchant_id,
354
+ 'customer_id' => $customer_id
355
+ ];
356
+ $postData = json_encode($postData);
357
+ $ch = curl_init();
358
+ curl_setopt_array($ch, array(
359
+ CURLOPT_URL => esc_url($curl_url),
360
+ CURLOPT_RETURNTRANSFER => true,
361
+ CURLOPT_TIMEOUT => 1000,
362
+ CURLOPT_HTTPHEADER => $header,
363
+ CURLOPT_POSTFIELDS => $postData
364
+ ));
365
+ $response = curl_exec($ch);
366
+ $response = json_decode($response);
367
+ return $response;
368
+ } catch (Exception $e) {
369
+ return $e->getMessage();
370
+ }
371
+ }
372
  public function verifyLicenceKey($licence_key, $subscription_id) {
373
  try {
374
  echo $url = $this->apiDomain . '/licence/verify-key';
includes/setup/google-ads.php CHANGED
@@ -5,12 +5,14 @@ class GoogleAds {
5
  protected $subscriptionId = "";
6
  protected $google_detail;
7
  protected $customApiObj;
 
8
  public function __construct($theURL = '') {
9
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
10
  $this->customApiObj = new CustomApi();
11
  $this->url = $this->TVC_Admin_Helper->get_connect_url();
12
  $this->subscriptionId = $this->TVC_Admin_Helper->get_subscriptionId();
13
- $this->google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
 
14
  $this->create_form();
15
  }
16
 
@@ -34,6 +36,16 @@ class GoogleAds {
34
  update_option('ads_edrt', 0);
35
  $googleDetail_setting->dynamic_remarketing_tags = 0;
36
  }
 
 
 
 
 
 
 
 
 
 
37
  if(isset($_POST['link_google_analytics_with_google_ads'])){
38
  $googleDetail_setting->link_google_analytics_with_google_ads = $_POST['link_google_analytics_with_google_ads'];
39
  }else{
@@ -136,6 +148,16 @@ class GoogleAds {
136
  </div>
137
  </div>
138
  </div>
 
 
 
 
 
 
 
 
 
 
139
  <div class="col-md-12">
140
  <div class="form-group">
141
  <div class="tvc-custom-control tvc-custom-checkbox">
5
  protected $subscriptionId = "";
6
  protected $google_detail;
7
  protected $customApiObj;
8
+ protected $plan_id;
9
  public function __construct($theURL = '') {
10
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
11
  $this->customApiObj = new CustomApi();
12
  $this->url = $this->TVC_Admin_Helper->get_connect_url();
13
  $this->subscriptionId = $this->TVC_Admin_Helper->get_subscriptionId();
14
+ $this->google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
15
+ $this->plan_id = $this->TVC_Admin_Helper->get_plan_id();
16
  $this->create_form();
17
  }
18
 
36
  update_option('ads_edrt', 0);
37
  $googleDetail_setting->dynamic_remarketing_tags = 0;
38
  }
39
+ if($this->plan_id != 1){
40
+ if(isset($_POST['google_ads_conversion_tracking'])){
41
+ update_option('google_ads_conversion_tracking', $_POST['google_ads_conversion_tracking']);
42
+ $googleDetail_setting->google_ads_conversion_tracking = $_POST['google_ads_conversion_tracking'];
43
+ $this->TVC_Admin_Helper->update_conversion_send_to();
44
+ }else{
45
+ update_option('google_ads_conversion_tracking', 0);
46
+ $googleDetail_setting->google_ads_conversion_tracking = 0;
47
+ }
48
+ }
49
  if(isset($_POST['link_google_analytics_with_google_ads'])){
50
  $googleDetail_setting->link_google_analytics_with_google_ads = $_POST['link_google_analytics_with_google_ads'];
51
  }else{
148
  </div>
149
  </div>
150
  </div>
151
+ <?php if($this->plan_id != 1){ ?>
152
+ <div class="col-md-12">
153
+ <div class="form-group">
154
+ <div class="tvc-custom-control tvc-custom-checkbox">
155
+ <input type="checkbox" class="tvc-custom-control-input" id="google_ads_conversion_tracking" name="google_ads_conversion_tracking" value="1" <?php echo ($googleDetail->google_ads_conversion_tracking == 1) ? 'checked="checked"' : ''; ?>>
156
+ <label class="custom-control-label" for="google_ads_conversion_tracking">Enable Google Ads conversion tracking</label>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ <?php } ?>
161
  <div class="col-md-12">
162
  <div class="form-group">
163
  <div class="tvc-custom-control tvc-custom-checkbox">
public/class-enhanced-ecommerce-google-analytics-public-pro.php CHANGED
@@ -63,6 +63,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
63
  protected $TVC_Admin_Helper;
64
  protected $remarketing_snippet_id;
65
  protected $remarketing_snippets;
 
 
66
  /**
67
  * Enhanced_Ecommerce_Google_Analytics_Public constructor.
68
  * @param $plugin_name
@@ -98,9 +100,9 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
98
  $this->ga_IPA = $this->get_option("ga_IPA") == "on" ? true : false; //IP Anony.
99
  $this->ads_ert = get_option('ads_ert'); //Enable remarketing tags
100
  $this->ads_edrt = get_option('ads_edrt'); //Enable dynamic remarketing tags
101
- $this->ads_tracking_id = get_option('ads_tracking_id');
102
- $this->ads_ert = get_option('ads_ert');
103
- $this->ads_edrt = get_option('ads_edrt');
104
 
105
  $remarketing = unserialize(get_option('ee_remarketing_snippets'));
106
  if(!empty($remarketing) && isset($remarketing['snippets']) && $remarketing['snippets']){
@@ -144,6 +146,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
144
  "ads_tracking_id"=>$this->ads_tracking_id,
145
  "remarketing_tags"=>$this->ads_ert,
146
  "dynamic_remarketing_tags"=>$this->ads_edrt,
 
 
147
  "page_type"=>$this->add_page_type(),
148
  "user_id"=>$user_id,
149
  "user_type"=>$user_type,
63
  protected $TVC_Admin_Helper;
64
  protected $remarketing_snippet_id;
65
  protected $remarketing_snippets;
66
+ protected $conversio_send_to;
67
+
68
  /**
69
  * Enhanced_Ecommerce_Google_Analytics_Public constructor.
70
  * @param $plugin_name
100
  $this->ga_IPA = $this->get_option("ga_IPA") == "on" ? true : false; //IP Anony.
101
  $this->ads_ert = get_option('ads_ert'); //Enable remarketing tags
102
  $this->ads_edrt = get_option('ads_edrt'); //Enable dynamic remarketing tags
103
+ $this->ads_tracking_id = get_option('ads_tracking_id');
104
+ $this->google_ads_conversion_tracking = get_option('google_ads_conversion_tracking');
105
+ $this->conversio_send_to = get_option('ee_conversio_send_to');
106
 
107
  $remarketing = unserialize(get_option('ee_remarketing_snippets'));
108
  if(!empty($remarketing) && isset($remarketing['snippets']) && $remarketing['snippets']){
146
  "ads_tracking_id"=>$this->ads_tracking_id,
147
  "remarketing_tags"=>$this->ads_ert,
148
  "dynamic_remarketing_tags"=>$this->ads_edrt,
149
+ "google_ads_conversion_tracking"=>$this->google_ads_conversion_tracking,
150
+ "conversio_send_to"=>$this->conversio_send_to,
151
  "page_type"=>$this->add_page_type(),
152
  "user_id"=>$user_id,
153
  "user_type"=>$user_type,
public/js/tvc-ee-google-analytics.js CHANGED
@@ -331,6 +331,15 @@ class TVC_Enhanced {
331
  "items": ads_items
332
  });
333
  }
 
 
 
 
 
 
 
 
 
334
  var last_purchase_time = this.getCookie("time_to_purchase");
335
  var time_to_purchase = purchase_time - last_purchase_time;
336
  this.eraseCookie("time_to_purchase");
331
  "items": ads_items
332
  });
333
  }
334
+
335
+ if(this.options.google_ads_conversion_tracking == 1 && this.options.conversio_send_to != ""){
336
+ gtag('event', 'conversion', {
337
+ 'send_to': this.options.conversio_send_to,
338
+ 'value': tvc_td.revenue,
339
+ 'currency': this.options.currency,
340
+ 'transaction_id': tvc_td.id,
341
+ });
342
+ }
343
  var last_purchase_time = this.getCookie("time_to_purchase");
344
  var time_to_purchase = purchase_time - last_purchase_time;
345
  this.eraseCookie("time_to_purchase");
readme.txt CHANGED
@@ -8,13 +8,15 @@ Author: Tatvic
8
  Requires at least: 1.4.1
9
  Tested up to: 5.8
10
  Requires PHP: 5.6 or Higher
11
- Stable tag: 4.0.0
12
- Version: 4.0.0
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
16
  Automates eCommerce tracking in Google Analytics and the complete Google Shopping solution with dynamic remarketing tags.
17
 
 
 
18
  == Product Description ==
19
 
20
  ###GOOGLE ANALYTICS PLUGIN FOR WOOCOMMERCE
@@ -389,6 +391,9 @@ You can resolve the duplication of data by removing the manually implemented GA
389
 
390
  == Changelog ==
391
 
 
 
 
392
  = 4.0.0 - 29/07/2021 =
393
 
394
  * Over the years, our team has worked tremendously hard in delivering the best possible version of the plugin delivered to you.
8
  Requires at least: 1.4.1
9
  Tested up to: 5.8
10
  Requires PHP: 5.6 or Higher
11
+ Stable tag: 4.0.1
12
+ Version: 4.0.1
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
16
  Automates eCommerce tracking in Google Analytics and the complete Google Shopping solution with dynamic remarketing tags.
17
 
18
+ https://youtu.be/s-L6VvY0sVw?rel=0
19
+
20
  == Product Description ==
21
 
22
  ###GOOGLE ANALYTICS PLUGIN FOR WOOCOMMERCE
391
 
392
  == Changelog ==
393
 
394
+ = 4.0.1 - 06/08/2021 =
395
+ * We have fixed Google Ads Conversion Tracking issue (Pro)
396
+
397
  = 4.0.0 - 29/07/2021 =
398
 
399
  * Over the years, our team has worked tremendously hard in delivering the best possible version of the plugin delivered to you.