Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.8.3

Version Description

  • 18/07/2022 =
  • New Feature (PRO) - Improve accuracy of ads Conversion tracking by enabling Google ads enhanced conversions. Users can also select the conversion label for specific conversion tracking (if any) in Google ads.
Download this release

Release Info

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

Code changes from version 4.8.2 to 4.8.3

admin/class-tvc-admin-helper.php CHANGED
@@ -275,11 +275,28 @@ Class TVC_Admin_Helper{
275
  update_option("ee_remarketing_snippets", serialize( $remarketing_snippets ));
276
  }
277
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  /*
279
- * update conversion send_to
280
  */
281
  public function update_conversion_send_to(){
282
- $customer_id = $this->get_currentCustomerId();
283
  $merchant_id = $this->get_merchantId();
284
  if($customer_id != "" && $merchant_id != ""){
285
  $response = $this->customApiObj->get_conversion_list($customer_id, $merchant_id);
@@ -298,15 +315,15 @@ Class TVC_Admin_Helper{
298
  foreach ($con_array as $key => $con_value) {
299
  $con_val_array = explode(":", $con_value);
300
  if(in_array("send_to", $con_val_array)){
301
- update_option("ee_conversio_send_to", $con_val_array[1] );
302
- break 2;
303
  }
304
  }
305
  }
306
  }
307
  }
308
  }
309
- }
310
  }
311
  /*
312
  * import GMC products in DB
275
  update_option("ee_remarketing_snippets", serialize( $remarketing_snippets ));
276
  }
277
  }
278
+ public function get_conversion_label($con_string){
279
+ $con_string = trim(preg_replace('/\s\s+/', '', $con_string));
280
+ $con_string = str_replace(" ", "", $con_string);
281
+ $con_string = str_replace("'", "", $con_string);
282
+ $con_string = str_replace("return false;", "", $con_string);
283
+ $con_string = str_replace("event,conversion,{", ",event:conversion,", $con_string);
284
+ $con_array = explode(",", $con_string);
285
+ $con_val_array = array();
286
+ if(!empty($con_array) && in_array("event:conversion", $con_array)){
287
+ foreach ($con_array as $key => $con_value) {
288
+ $con_val_array = explode(":", $con_value);
289
+ if(in_array("send_to", $con_val_array)){
290
+ return $con_val_array[1];
291
+ }
292
+ }
293
+ }
294
+ }
295
  /*
296
+ * update conversion send_to dapricated version 4.8.2
297
  */
298
  public function update_conversion_send_to(){
299
+ /*$customer_id = $this->get_currentCustomerId();
300
  $merchant_id = $this->get_merchantId();
301
  if($customer_id != "" && $merchant_id != ""){
302
  $response = $this->customApiObj->get_conversion_list($customer_id, $merchant_id);
315
  foreach ($con_array as $key => $con_value) {
316
  $con_val_array = explode(":", $con_value);
317
  if(in_array("send_to", $con_val_array)){
318
+ //update_option("ee_conversio_send_to", $con_val_array[1] );
319
+ //break 2;
320
  }
321
  }
322
  }
323
  }
324
  }
325
  }
326
+ }*/
327
  }
328
  /*
329
  * import GMC products in DB
admin/css/enhanced-ecommerce-google-analytics-admin.css CHANGED
@@ -701,4 +701,8 @@ img{
701
  display: block;
702
  animation: tvc_popup_box_open 0.5s;
703
  -webkit-animation: tvc_popup_box_open 0.5s;
 
 
 
 
704
  }
701
  display: block;
702
  animation: tvc_popup_box_open 0.5s;
703
  -webkit-animation: tvc_popup_box_open 0.5s;
704
+ }
705
+
706
+ .google_conversion_label_message{
707
+ margin-top: 20px;
708
  }
admin/helper/class-onboarding-helper.php CHANGED
@@ -348,9 +348,9 @@ if(!class_exists('Conversios_Onboarding_Helper')):
348
  */
349
  $TVC_Admin_Helper->update_remarketing_snippets();
350
 
351
- if($googleDetail->plan_id != 1 && sanitize_text_field($googleDetail->google_ads_conversion_tracking) == 1){
352
- $TVC_Admin_Helper->update_conversion_send_to();
353
- }
354
  /**
355
  * save gmail and view ID in WP DB
356
  */
348
  */
349
  $TVC_Admin_Helper->update_remarketing_snippets();
350
 
351
+ /*if($googleDetail->plan_id != 1 && sanitize_text_field($googleDetail->google_ads_conversion_tracking) == 1){
352
+ //$TVC_Admin_Helper->update_conversion_send_to();
353
+ }*/
354
  /**
355
  * save gmail and view ID in WP DB
356
  */
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.8.2
19
  * Author: Conversios
20
  * Author URI: conversios.io
21
  * License: GPL-2.0+
@@ -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.8.2' );
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.8.3
19
  * Author: Conversios
20
  * Author URI: conversios.io
21
  * License: GPL-2.0+
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.8.3' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/setup/CustomApi.php CHANGED
@@ -351,7 +351,7 @@ class CustomApi{
351
  return $return;
352
  }else{
353
  $return->error = true;
354
- $return->errors = $result->errors;
355
  //$return->error = $result->data;
356
  $return->status = $response_code;
357
  return $return;
351
  return $return;
352
  }else{
353
  $return->error = true;
354
+ //$return->errors = $result->errors;
355
  //$return->error = $result->data;
356
  $return->status = $response_code;
357
  return $return;
includes/setup/google-ads.php CHANGED
@@ -9,11 +9,14 @@ class GoogleAds {
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_onboarding_page_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
 
19
  public function create_form() {
@@ -40,10 +43,20 @@ class GoogleAds {
40
  if(isset($_POST['google_ads_conversion_tracking'])){
41
  update_option('google_ads_conversion_tracking', sanitize_text_field($_POST['google_ads_conversion_tracking']) );
42
  $googleDetail_setting->google_ads_conversion_tracking = sanitize_text_field($_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'])){
@@ -148,16 +161,6 @@ class GoogleAds {
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 (esc_attr($googleDetail->google_ads_conversion_tracking) == 1) ? 'checked="checked"' : ''; ?>>
156
- <label class="custom-control-label" for="google_ads_conversion_tracking"><?php esc_html_e("Enable Google Ads conversion tracking","conversios"); ?><span class="tvc-pro"> (PRO)</span></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">
@@ -174,11 +177,75 @@ class GoogleAds {
174
  <ul>
175
  <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Enable remarketing tags","conversios"); ?></li>
176
  <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Enable dynamic remarketing tags","conversios"); ?></li>
177
- <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Enable Google Ads conversion tracking","conversios"); ?><span class="tvc-pro"> (PRO)</span></li>
178
  <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Link Google analytics with google ads","conversios"); ?></li>
179
  </ul>
180
  <?php
181
  } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  </div>
183
  <?php
184
  if (isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != '') { ?>
@@ -203,5 +270,34 @@ class GoogleAds {
203
  </div>
204
  <?php
205
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
  ?>
9
  public function __construct($theURL = '') {
10
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
11
  $this->customApiObj = new CustomApi();
12
+ $this->current_customer_id = $this->TVC_Admin_Helper->get_currentCustomerId();
13
+ $this->merchant_id = $this->TVC_Admin_Helper->get_merchantId();
14
  $this->url = $this->TVC_Admin_Helper->get_onboarding_page_url();
15
  $this->subscriptionId = $this->TVC_Admin_Helper->get_subscriptionId();
16
  $this->google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
17
  $this->plan_id = $this->TVC_Admin_Helper->get_plan_id();
18
  $this->create_form();
19
+ $this->current_js();
20
  }
21
 
22
  public function create_form() {
43
  if(isset($_POST['google_ads_conversion_tracking'])){
44
  update_option('google_ads_conversion_tracking', sanitize_text_field($_POST['google_ads_conversion_tracking']) );
45
  $googleDetail_setting->google_ads_conversion_tracking = sanitize_text_field($_POST['google_ads_conversion_tracking']);
 
46
  }else{
47
  update_option('google_ads_conversion_tracking', 0);
48
  $googleDetail_setting->google_ads_conversion_tracking = 0;
49
+ }
50
+ if(isset($_POST['ga_EC'])){
51
+ update_option('ga_EC', sanitize_text_field($_POST['ga_EC']) );
52
+ $googleDetail_setting->ga_EC = sanitize_text_field($_POST['ga_EC']);
53
+ }else{
54
+ update_option('ga_EC', 0);
55
+ $googleDetail_setting->ga_EC = 0;
56
+ }
57
+ if(isset($_POST['ee_conversio_send_to'])){
58
+ update_option('ee_conversio_send_to', sanitize_text_field($_POST['ee_conversio_send_to']) );
59
+ $googleDetail_setting->ee_conversio_send_to = sanitize_text_field($_POST['ee_conversio_send_to']);
60
  }
61
  }
62
  if(isset($_POST['link_google_analytics_with_google_ads'])){
161
  </div>
162
  </div>
163
  </div>
 
 
 
 
 
 
 
 
 
 
164
  <div class="col-md-12">
165
  <div class="form-group">
166
  <div class="tvc-custom-control tvc-custom-checkbox">
177
  <ul>
178
  <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Enable remarketing tags","conversios"); ?></li>
179
  <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Enable dynamic remarketing tags","conversios"); ?></li>
180
+ <!--<li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Enable Google Ads conversion tracking","conversios"); ?><span class="tvc-pro"> (PRO)</span></li>-->
181
  <li><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/config-success.svg'); ?>" alt="configuration success" class="config-success"><?php esc_html_e("Link Google analytics with google ads","conversios"); ?></li>
182
  </ul>
183
  <?php
184
  } ?>
185
+ <?php if($this->plan_id != 1 && isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != ''){ ?>
186
+ <div class="row">
187
+ <div class="col-md-12">
188
+ <div class="form-group">
189
+ <div class="tvc-custom-control tvc-custom-checkbox">
190
+ <input type="checkbox" class="tvc-custom-control-input" id="google_ads_conversion_tracking" class="google_ads_conversion_tracking" name="google_ads_conversion_tracking" value="1" <?php echo (esc_attr($googleDetail->google_ads_conversion_tracking) == 1) ? 'checked="checked"' : ''; ?>>
191
+ <label for="google_ads_conversion_tracking"><?php esc_html_e("Enable Google Ads conversion tracking","conversios"); ?></label>
192
+ </div>
193
+ </div>
194
+ </div>
195
+ <div class="form-group google_ads_conversion_sec <?php echo ($googleDetail->google_ads_conversion_tracking!=1)?"google_ads_conversion_sec_hide":""; ?>" id="google_ads_conversion_sec">
196
+ <div class="col-md-12">
197
+ <div class="form-group">
198
+ <div class="tvc-custom-control tvc-custom-checkbox">
199
+ <input type="checkbox" class="tvc-custom-control-input" id="ga_EC" name="ga_EC" value="1"<?php if(!empty($googleDetail->ga_EC)){ echo (esc_attr($googleDetail->ga_EC) == 1) ? 'checked="checked"' : '';}?> <?php if($googleDetail->google_ads_conversion_tracking!=1){ echo 'disabled'; } ?>>
200
+ <label for="ga_EC"><?php esc_html_e("Enable Google Ads Enhanced Conversion tracking","conversios"); ?>
201
+ </label>
202
+ </div>
203
+ </div>
204
+ </div>
205
+ <div class="col-md-12">
206
+ <div class="form-group">
207
+ <?php
208
+ if($this->current_customer_id != "" && $this->merchant_id != ""){
209
+ $response = $this->customApiObj->get_conversion_list($this->current_customer_id, $this->merchant_id);
210
+ if(property_exists($response,"error") && $response->error == true){
211
+ echo "<div class='google_conversion_label_message alert alert-danger google_ads_conversion_label_message' role='alert'>No conversion label associated with this google ads id.</div>";
212
+ }
213
+ if(property_exists($response,"error") && $response->error == false){
214
+ if(property_exists($response,"data") && $response->data != "" && !empty($response->data)){
215
+ $selected_conversio_send_to = get_option('ee_conversio_send_to');?>
216
+ <select name='ee_conversio_send_to' id='google_ads_conversion_label' <?php if($googleDetail->google_ads_conversion_tracking!=1){ echo 'disabled'; } ?>>
217
+ <?php $selected = "";
218
+ foreach ($response->data as $key => $value) {
219
+ $con_string=strip_tags($value->tagSnippets);
220
+ $conversion_label = $this->TVC_Admin_Helper->get_conversion_label($con_string);
221
+ if($selected_conversio_send_to==$conversion_label){
222
+ $selected = "selected";
223
+ }else{
224
+ $selected = "";
225
+ }
226
+ ?>
227
+ <option <?php echo $selected; ?> value="<?php echo esc_attr($conversion_label); ?>"><?php echo esc_attr($conversion_label); ?>
228
+ </option>;
229
+ <?php }
230
+ echo "</select>";
231
+ }
232
+ }
233
+ }
234
+ ?>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ <?php }else{?>
240
+ <div class="row">
241
+ <div class="col-md-12">
242
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/lock-orange.png'); ?>" class="config-success"><?php esc_html_e("Enable Google Ads conversion tracking","conversios"); ?><span class="tvc-pro"> (PRO)</span>
243
+ </div>
244
+ <div class="col-md-12">
245
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/lock-orange.png'); ?>" class="config-success"><?php esc_html_e("Enable Google Ads Enhanced conversion tracking","conversios"); ?><span class="tvc-pro"> (PRO)</span>
246
+ </div>
247
+ </div>
248
+ <?php } ?>
249
  </div>
250
  <?php
251
  if (isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != '') { ?>
270
  </div>
271
  <?php
272
  }
273
+ public function current_js(){
274
+ ?>
275
+ <script>
276
+ jQuery(function () {
277
+ jQuery("#google_ads_conversion_tracking").click(function () {
278
+ if (jQuery("#google_ads_conversion_tracking").is(":checked")) {
279
+ jQuery('#google_ads_conversion_sec :input').removeAttr('disabled');
280
+ jQuery('#google_ads_conversion_sec :select').removeAttr('disabled');
281
+ } else {
282
+ //To disable all input elements within div use the following code:
283
+ jQuery('#google_ads_conversion_sec :input').attr('disabled', 'disabled');
284
+
285
+ //To disable all select elements within div use the following code:
286
+ jQuery('#google_ads_conversion_sec :select').attr('disabled', 'disabled');
287
+ }
288
+ });
289
+ });
290
+ </script>
291
+ <script>
292
+ jQuery('#google_ads_conversion_tracking').click(function(){
293
+ if(!this.checked){
294
+ jQuery("#ga_EC").prop("checked", false);
295
+ }else{
296
+ jQuery("#ga_EC").prop("checked", true);
297
+ }
298
+ });
299
+ </script>
300
+ <?php
301
+ }
302
  }
303
  ?>
public/class-enhanced-ecommerce-google-analytics-public-pro.php CHANGED
@@ -30,6 +30,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
30
  //set plugin version
31
  protected $plugin_name;
32
  protected $version;
 
33
  //content grouping start
34
  protected $ga_optimize_id;
35
  protected $ga_CG;
@@ -113,6 +114,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
113
  $this->ads_edrt = get_option('ads_edrt'); //Enable dynamic remarketing tags
114
  $this->ads_tracking_id = sanitize_text_field(get_option('ads_tracking_id'));
115
  $this->google_ads_conversion_tracking = get_option('google_ads_conversion_tracking');
 
116
  $this->conversio_send_to = get_option('ee_conversio_send_to');
117
 
118
  $remarketing = unserialize(get_option('ee_remarketing_snippets'));
@@ -160,6 +162,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
160
  "dynamic_remarketing_tags"=>esc_js($this->ads_edrt),
161
  "google_ads_conversion_tracking"=>esc_js($this->google_ads_conversion_tracking),
162
  "conversio_send_to"=>esc_js($this->conversio_send_to),
 
163
  "page_type"=>esc_js($this->add_page_type()),
164
  "user_id"=>esc_js($user_id),
165
  "user_type"=>esc_js($user_type),
@@ -345,6 +348,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
345
  'tvc_eev' => esc_js($this->tvc_eeVer),
346
  'tvc_cnf' => array(
347
  't_cg' => esc_js($this->ga_CG),
 
348
  't_ee' => esc_js($this->ga_eeT),
349
  't_df' => esc_js($this->ga_DF),
350
  't_gUser' => esc_js($this->ga_gUser),
@@ -582,22 +586,153 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
582
  </script>
583
  <?php
584
  }
585
- /*if($this->ga_CG){?>
 
 
 
 
586
  <script>
587
- gtag('set', {'content_group': '<?php echo esc_js($this->add_page_type());?>'});
 
 
 
588
  </script>
589
- <?php } */
590
- //add remarketing snippets
591
- ?>
592
- <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($this->remarketing_snippet_id); ?>">
593
- </script>
594
- <script>
595
- window.dataLayer = window.dataLayer || [];
596
- function gtag(){dataLayer.push(arguments);}
597
- gtag('js', new Date());
598
- gtag('config','<?php echo esc_js($this->remarketing_snippet_id); ?>', {'allow_enhanced_conversions':true});
599
- </script>
600
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
  /* old code
602
  if($this->ads_tracking_id && ($this->ads_ert || $this->ads_edrt)){
603
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
30
  //set plugin version
31
  protected $plugin_name;
32
  protected $version;
33
+ protected $ga_EC;
34
  //content grouping start
35
  protected $ga_optimize_id;
36
  protected $ga_CG;
114
  $this->ads_edrt = get_option('ads_edrt'); //Enable dynamic remarketing tags
115
  $this->ads_tracking_id = sanitize_text_field(get_option('ads_tracking_id'));
116
  $this->google_ads_conversion_tracking = get_option('google_ads_conversion_tracking');
117
+ $this->ga_EC = get_option("ga_EC");
118
  $this->conversio_send_to = get_option('ee_conversio_send_to');
119
 
120
  $remarketing = unserialize(get_option('ee_remarketing_snippets'));
162
  "dynamic_remarketing_tags"=>esc_js($this->ads_edrt),
163
  "google_ads_conversion_tracking"=>esc_js($this->google_ads_conversion_tracking),
164
  "conversio_send_to"=>esc_js($this->conversio_send_to),
165
+ "ga_EC"=>esc_js($this->ga_EC),
166
  "page_type"=>esc_js($this->add_page_type()),
167
  "user_id"=>esc_js($user_id),
168
  "user_type"=>esc_js($user_type),
348
  'tvc_eev' => esc_js($this->tvc_eeVer),
349
  'tvc_cnf' => array(
350
  't_cg' => esc_js($this->ga_CG),
351
+ 't_ec' => esc_js($this->ga_EC),
352
  't_ee' => esc_js($this->ga_eeT),
353
  't_df' => esc_js($this->ga_DF),
354
  't_gUser' => esc_js($this->ga_gUser),
586
  </script>
587
  <?php
588
  }
589
+ //add remarketing snippets
590
+ if($this->ads_tracking_id && ( $this->ads_ert || $this->ads_edrt || $this->ga_EC )){
591
+ ?>
592
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($this->remarketing_snippet_id); ?>">
593
+ </script>
594
  <script>
595
+ window.dataLayer = window.dataLayer || [];
596
+ function gtag(){dataLayer.push(arguments);}
597
+ gtag('js', new Date());
598
+ gtag('config','<?php echo esc_js($this->remarketing_snippet_id); ?>', {'allow_enhanced_conversions':true});
599
  </script>
 
 
 
 
 
 
 
 
 
 
 
600
  <?php
601
+ }
602
+ if($this->ga_EC){
603
+ if ( is_user_logged_in() ) {
604
+ global $current_user;
605
+ wp_get_current_user();
606
+ $enhanced_conversion = array();
607
+ $phone = get_user_meta($current_user->ID,'billing_phone',true);
608
+ if($phone != ""){
609
+ $enhanced_conversion["phone_number"] = $phone;
610
+ }
611
+ $email = esc_js($current_user->user_email);
612
+ if($email != ""){
613
+ $enhanced_conversion["email"] = $email;
614
+ }
615
+ $first_name = esc_js($current_user->user_firstname);
616
+ if($first_name != ""){
617
+ $enhanced_conversion["address"]["first_name"] = esc_js($first_name);
618
+ }
619
+ $last_name = $current_user->user_lastname;
620
+ if($last_name != ""){
621
+ $enhanced_conversion["address"]["last_name"] = esc_js($last_name);
622
+ }
623
+ $billing_address_1 = WC()->customer->get_billing_address_1();
624
+ if($billing_address_1 != ""){
625
+ $enhanced_conversion["address"]["street"] = esc_js($billing_address_1);
626
+ }
627
+ $billing_postcode = WC()->customer->get_billing_postcode();
628
+ if($billing_postcode != ""){
629
+ $enhanced_conversion["address"]["postcode"] = esc_js($billing_postcode);
630
+ }
631
+ $billing_city = WC()->customer->get_billing_city();
632
+ if($billing_city != ""){
633
+ $enhanced_conversion["address"]["city"] = esc_js($billing_city);
634
+ }
635
+ $billing_state = WC()->customer->get_billing_state();
636
+ if($billing_state != ""){
637
+ $enhanced_conversion["address"]["state"] = esc_js($billing_state);
638
+ }
639
+ $billing_country = WC()->customer->get_billing_country();
640
+ if($billing_country != ""){
641
+ $enhanced_conversion["address"]["country"] = esc_js($billing_country);
642
+ }
643
+ if(!empty($enhanced_conversion)){
644
+ ?>
645
+ <script>
646
+ var enhanced_conversion_data = <?php echo json_encode($enhanced_conversion); ?>
647
+ </script>
648
+ <script>
649
+ gtag('set', 'user_data', {
650
+ "email": enhanced_conversion_data.email,
651
+ "phone_number":enhanced_conversion_data.phone_number,
652
+ "first_name":enhanced_conversion_data.address.first_name,
653
+ "last_name":enhanced_conversion_data.address.last_name,
654
+ "street":enhanced_conversion_data.address.street,
655
+ "postcode":enhanced_conversion_data.address.postcode,
656
+ "city":enhanced_conversion_data.address.city,
657
+ "state":enhanced_conversion_data.address.state,
658
+ "country":enhanced_conversion_data.address.country
659
+ });
660
+ </script>
661
+ <?php
662
+ }
663
+ } else {
664
+ global $woocommerce;
665
+ $order = "";
666
+ $order_id = "";
667
+ if($order_id == null && is_order_received_page()){
668
+ $order = $this->tvc_get_order_from_order_received_page();
669
+ $order_id = $order->get_id();
670
+ }else{
671
+ $order = new WC_Order($order_id);
672
+ }
673
+ $enhanced_conversion = array();
674
+ $billing_email = $order->get_billing_email();
675
+ if($billing_email != ""){
676
+ $enhanced_conversion["email"] = esc_js($billing_email);
677
+ }
678
+ $billing_phone = $order->get_billing_phone();
679
+ if($billing_phone != ""){
680
+ $enhanced_conversion["phone"] = esc_js($billing_phone);
681
+ }
682
+ $billing_first_name = $order->get_billing_first_name();
683
+ if($billing_first_name != ""){
684
+ $enhanced_conversion["address"]["first_name"] = esc_js($billing_first_name);
685
+ }
686
+ $billing_last_name = $order->get_billing_last_name();
687
+ if($billing_last_name != ""){
688
+ $enhanced_conversion["address"]["last_name"] = esc_js($billing_last_name);
689
+ }
690
+ $billing_address_1 = $order->get_billing_address_1();
691
+ if($billing_address_1 != ""){
692
+ $enhanced_conversion["address"]["street"] = esc_js($billing_address_1);
693
+ }
694
+ $billing_address_2 = $order->get_billing_address_2();
695
+ if($billing_address_2 != ""){
696
+ $enhanced_conversion["address"]["street_address"] = esc_js($billing_address_2);
697
+ }
698
+ $billing_city = $order->get_billing_city();
699
+ if($billing_city != ""){
700
+ $enhanced_conversion["address"]["city"] = esc_js($billing_city);
701
+ }
702
+ $billing_state = $order->get_billing_state();
703
+ if($billing_state != ""){
704
+ $enhanced_conversion["address"]["state"] = esc_js($billing_state);
705
+ }
706
+ $billing_postcode = $order->get_billing_postcode();
707
+ if($billing_postcode != ""){
708
+ $enhanced_conversion["address"]["postcode"] = esc_js($billing_postcode);
709
+ }
710
+ $billing_country = $order->get_billing_country();
711
+ if($billing_country != ""){
712
+ $enhanced_conversion["address"]["country"] = esc_js($billing_country);
713
+ }
714
+ if(!empty($enhanced_conversion)){
715
+ ?>
716
+ <script>
717
+ var enhanced_conversion_data = <?php echo json_encode($enhanced_conversion); ?>
718
+ </script>
719
+ <script>
720
+ gtag('set', 'user_data', {
721
+ "email": enhanced_conversion_data.email,
722
+ "phone_number":enhanced_conversion_data.phone_number,
723
+ "first_name":enhanced_conversion_data.address.first_name,
724
+ "last_name":enhanced_conversion_data.address.last_name,
725
+ "street":enhanced_conversion_data.address.street,
726
+ "postcode":enhanced_conversion_data.address.postcode,
727
+ "city":enhanced_conversion_data.address.city,
728
+ "state":enhanced_conversion_data.address.state,
729
+ "country":enhanced_conversion_data.address.country
730
+ });
731
+ </script>
732
+ <?php
733
+ }
734
+ }
735
+ }
736
  /* old code
737
  if($this->ads_tracking_id && ($this->ads_ert || $this->ads_edrt)){
738
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
readme.txt CHANGED
@@ -8,8 +8,8 @@ Author: Conversios
8
  Requires at least: 3.5.0
9
  Tested up to: 6.0
10
  Requires PHP: 5.6 or Higher
11
- Stable tag: 4.8.2
12
- Version: 4.8.2
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
@@ -405,8 +405,11 @@ You can resolve the duplication of data by removing the manually implemented GA
405
 
406
 
407
  == Changelog ==
 
 
 
408
  = 4.8.2 - 12/07/2022 =
409
- * NEW: (PRO) You can also track your order refund in Google Analytics GA4 and GA3.
410
 
411
  = 4.8.1 - 21/06/2022 =
412
  * Fix: In this release, optimzation of code in terms of Pmax Campaign.
8
  Requires at least: 3.5.0
9
  Tested up to: 6.0
10
  Requires PHP: 5.6 or Higher
11
+ Stable tag: 4.8.3
12
+ Version: 4.8.3
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
405
 
406
 
407
  == Changelog ==
408
+ = 4.8.3 - 18/07/2022 =
409
+ * New Feature (PRO) - Improve accuracy of ads Conversion tracking by enabling Google ads enhanced conversions. Users can also select the conversion label for specific conversion tracking (if any) in Google ads.
410
+
411
  = 4.8.2 - 12/07/2022 =
412
+ * NEW: (PRO) You can now track your order refund for Google Analytics GA4 and GA3
413
 
414
  = 4.8.1 - 21/06/2022 =
415
  * Fix: In this release, optimzation of code in terms of Pmax Campaign.