Yandex Metrica - Version 1.8.1

Version Description

  • an option added for the dispatching e-commerce data
Download this release

Release Info

Developer m_uysl
Plugin Icon 128x128 Yandex Metrica
Version 1.8.1
Comparing to
See all releases

Code changes from version 1.8 to 1.8.1

README.md CHANGED
@@ -4,7 +4,7 @@ Contributors: m_uysl, ildarkhasanshin
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
  Tested up to: 5.1
7
- Stable tag: 1.8
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -72,6 +72,9 @@ Extract the zip file and just drop the contents in the `wp-content/plugins/` dir
72
 
73
  ## Changelog ##
74
 
 
 
 
75
  ### 1.8 ###
76
  - Authorization method changed, URL parameters no longer acccepted
77
  - use wp_head instead wp_footer for the tracking code
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
  Tested up to: 5.1
7
+ Stable tag: 1.8.1
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
72
 
73
  ## Changelog ##
74
 
75
+ ### 1.8.1 ###
76
+ - an option added for the dispatching e-commerce data
77
+
78
  ### 1.8 ###
79
  - Authorization method changed, URL parameters no longer acccepted
80
  - use wp_head instead wp_footer for the tracking code
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: m_uysl, ildarkhasanshin
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
  Tested up to: 5.1
7
- Stable tag: 1.8
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -65,6 +65,9 @@ Yandex Metrica plugin uses wp_head hook for the adds necessary tracking code. Pl
65
 
66
  == Changelog ==
67
 
 
 
 
68
  = 1.8 =
69
  - Authorization method changed, URL parameters no longer acccepted
70
  - use wp_head instead wp_footer for the tracking code
4
  Tags: yandex,metrica,stats,statistics,tools,analytics,analytics tool,metrika
5
  Requires at least: 3.8
6
  Tested up to: 5.1
7
+ Stable tag: 1.8.1
8
  License: GPLv2 (or later)
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
65
 
66
  == Changelog ==
67
 
68
+ = 1.8.1 =
69
+ - an option added for the dispatching e-commerce data
70
+
71
  = 1.8 =
72
  - Authorization method changed, URL parameters no longer acccepted
73
  - use wp_head instead wp_footer for the tracking code
templates/settings.php CHANGED
@@ -35,6 +35,8 @@ if ( isset( $_POST["yandex-metrica-save"] ) ) {
35
  $this->options["untrack-roles"] = ! empty( $_POST["tracker_role"] ) ? array_map( 'esc_attr', $_POST["tracker_role"] ) : "";
36
  $this->options["widget-access-roles"] = ! empty( $_POST["widget_access"] ) ? array_map( 'esc_attr', $_POST["widget_access"] ) : "";
37
  $this->options['new_yandex_code'] = empty( $_POST['new_yandex_code'] ) ? false : true;
 
 
38
  $this->options["tracker-address"] = ! empty( $_POST["tracker-address"] ) ? esc_url_raw( $_POST['tracker-address'] ) : "";
39
 
40
  $default_trackers[] = 'https://mc.yandex.ru/metrika/watch.js';
@@ -133,6 +135,18 @@ if ( isset( $_POST["reset"] ) ) {
133
  </label><br>
134
  <label><input type="checkbox" <?php checked( $this->options['new_yandex_code'] ); ?> name="new_yandex_code" value="1"> <?php _e( "Use new counter code", 'yandex-metrica' ); ?>
135
  </label>(<a href="https://yandex.com/support/metrika/code/counter-initialize.html" target="_blank">?</a>)<br>
 
 
 
 
 
 
 
 
 
 
 
 
136
  </td>
137
  </tr>
138
 
@@ -209,4 +223,14 @@ if ( isset( $_POST["reset"] ) ) {
209
 
210
  <?php endif; ?>
211
  </form>
212
- </div>
 
 
 
 
 
 
 
 
 
 
35
  $this->options["untrack-roles"] = ! empty( $_POST["tracker_role"] ) ? array_map( 'esc_attr', $_POST["tracker_role"] ) : "";
36
  $this->options["widget-access-roles"] = ! empty( $_POST["widget_access"] ) ? array_map( 'esc_attr', $_POST["widget_access"] ) : "";
37
  $this->options['new_yandex_code'] = empty( $_POST['new_yandex_code'] ) ? false : true;
38
+ $this->options['dispatch_ecommerce'] = empty( $_POST['dispatch_ecommerce'] ) ? false : true;
39
+ $this->options["ecommerce_container_name"] = ! empty( $_POST["ecommerce_container_name"] ) ? sanitize_text_field( $_POST['ecommerce_container_name'] ) : "dataLayer";
40
  $this->options["tracker-address"] = ! empty( $_POST["tracker-address"] ) ? esc_url_raw( $_POST['tracker-address'] ) : "";
41
 
42
  $default_trackers[] = 'https://mc.yandex.ru/metrika/watch.js';
135
  </label><br>
136
  <label><input type="checkbox" <?php checked( $this->options['new_yandex_code'] ); ?> name="new_yandex_code" value="1"> <?php _e( "Use new counter code", 'yandex-metrica' ); ?>
137
  </label>(<a href="https://yandex.com/support/metrika/code/counter-initialize.html" target="_blank">?</a>)<br>
138
+ <label><input type="checkbox" <?php checked( $this->options['dispatch_ecommerce'] ); ?> id="dispatch_ecommerce" name="dispatch_ecommerce" value="1"> <?php _e( "Dispatch ecommerce data to Metrica", 'yandex-metrica' ); ?>
139
+ </label><br>
140
+ </td>
141
+ </tr>
142
+
143
+ <tr id="ecommerce-container-row" valign="top" style="display:<?php echo ( $this->options['dispatch_ecommerce'] ) ? 'table-row' : 'none' ?>;">
144
+ <th>
145
+ <label><?php _e( 'Ecommerce Container', 'yandex-metrica' ); ?></label>
146
+ </th>
147
+ <td>
148
+ <input type="text" style="min-width: 300px;" name="ecommerce_container_name" value="<?php echo $this->options["ecommerce_container_name"]; ?>">
149
+ <p class="setting-description"><?php _e( 'Data container name for the collecting data from', 'yandex-metrica' ); ?></p>
150
  </td>
151
  </tr>
152
 
223
 
224
  <?php endif; ?>
225
  </form>
226
+ </div>
227
+
228
+ <script>
229
+ jQuery('#dispatch_ecommerce').on('change', function () {
230
+ if (jQuery(this).is(':checked')) {
231
+ jQuery("#ecommerce-container-row").css("display", "table-row");
232
+ } else {
233
+ jQuery("#ecommerce-container-row").css("display", "none");
234
+ }
235
+ });
236
+ </script>
templates/tracker-js-new.php CHANGED
@@ -10,7 +10,10 @@
10
  clickmap:<?php echo $this->options["clickmap"]?"true":"false";?>,
11
  trackLinks:<?php echo $this->options["tracklinks"]?"true":"false";?>,
12
  accurateTrackBounce:<?php echo $this->options["accurate_track"]?"true":"false";?>,
13
- webvisor:<?php echo $this->options["webvisor"]?"true":"false";?>
 
 
 
14
  });
15
  </script>
16
  <noscript><div><img src="<?php printf( "%s%s", apply_filters( 'yandex_metrica_noscript_img_base', "https://mc.yandex.ru/watch/" ), $this->options["counter_id"] ); ?>" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
10
  clickmap:<?php echo $this->options["clickmap"]?"true":"false";?>,
11
  trackLinks:<?php echo $this->options["tracklinks"]?"true":"false";?>,
12
  accurateTrackBounce:<?php echo $this->options["accurate_track"]?"true":"false";?>,
13
+ webvisor:<?php echo $this->options["webvisor"] ? "true" : "false";?>,
14
+ <?php if($this->options['dispatch_ecommerce']):?>
15
+ ecommerce: "<?php echo apply_filters( 'yandex_metrica_ecommerce_container_name', $this->options['ecommerce_container_name'] )?>"
16
+ <?php endif;?>
17
  });
18
  </script>
19
  <noscript><div><img src="<?php printf( "%s%s", apply_filters( 'yandex_metrica_noscript_img_base', "https://mc.yandex.ru/watch/" ), $this->options["counter_id"] ); ?>" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
templates/tracker-js.php CHANGED
@@ -9,7 +9,11 @@
9
  clickmap:<?php echo $this->options["clickmap"]?"true":"false";?>,
10
  trackLinks:<?php echo $this->options["tracklinks"]?"true":"false";?>,
11
  accurateTrackBounce:<?php echo $this->options["accurate_track"]?"true":"false";?>,
12
- trackHash:<?php echo $this->options["track_hash"]?"true":"false";?>});
 
 
 
 
13
  } catch(e) { }
14
  });
15
 
9
  clickmap:<?php echo $this->options["clickmap"]?"true":"false";?>,
10
  trackLinks:<?php echo $this->options["tracklinks"]?"true":"false";?>,
11
  accurateTrackBounce:<?php echo $this->options["accurate_track"]?"true":"false";?>,
12
+ trackHash:<?php echo $this->options["track_hash"]?"true":"false";?>,
13
+ <?php if($this->options['dispatch_ecommerce']):?>
14
+ ecommerce: "<?php echo apply_filters( 'yandex_metrica_ecommerce_container_name', $this->options['ecommerce_container_name'] )?>"
15
+ <?php endif;?>
16
+ });
17
  } catch(e) { }
18
  });
19
 
yandex-metrica.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Yandex Metrica
4
  Plugin URI: http://uysalmustafa.com/plugins/yandex-metrica
5
  Description: Best metrica plugin for the use Yandex Metrica in your WordPress site.
6
  Author: Mustafa Uysal
7
- Version: 1.8
8
  Text Domain: yandex-metrica
9
  Domain Path: /languages/
10
  Author URI: http://uysalmustafa.com
@@ -68,18 +68,20 @@ class WP_Yandex_Metrica extends WP_Stack_Plugin {
68
  private function get_options() {
69
  // default options
70
  $defaults = array(
71
- 'counter_id' => "",
72
- 'webvisor' => true,
73
- 'clickmap' => true,
74
- 'tracklinks' => true,
75
- 'accurate_track' => false,
76
- 'track_hash' => false,
77
- 'track-logged-in' => true,
78
- 'untrack-roles' => array( "administrator" ),
79
- 'widget-access-roles' => array( "administrator" ),
80
- 'backward' => false,
81
- 'new_yandex_code' => true, // @since 1.7,
82
- 'tracker-address' => ""
 
 
83
  );
84
  return wp_parse_args( get_option( self::OPTION ), $defaults );
85
  }
@@ -125,6 +127,7 @@ class WP_Yandex_Metrica extends WP_Stack_Plugin {
125
  if ( ! current_user_can( 'manage_options' ) ) {
126
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yandex-metrica' ) );
127
  }
 
128
  include( dirname( __FILE__ ) . '/templates/settings.php' );
129
  }
130
 
4
  Plugin URI: http://uysalmustafa.com/plugins/yandex-metrica
5
  Description: Best metrica plugin for the use Yandex Metrica in your WordPress site.
6
  Author: Mustafa Uysal
7
+ Version: 1.8.1
8
  Text Domain: yandex-metrica
9
  Domain Path: /languages/
10
  Author URI: http://uysalmustafa.com
68
  private function get_options() {
69
  // default options
70
  $defaults = array(
71
+ 'counter_id' => "",
72
+ 'webvisor' => true,
73
+ 'clickmap' => true,
74
+ 'tracklinks' => true,
75
+ 'accurate_track' => false,
76
+ 'track_hash' => false,
77
+ 'track-logged-in' => true,
78
+ 'untrack-roles' => array( "administrator" ),
79
+ 'widget-access-roles' => array( "administrator" ),
80
+ 'backward' => false,
81
+ 'new_yandex_code' => true, // @since 1.7,
82
+ 'dispatch_ecommerce' => false, // @since 1.8.1
83
+ 'ecommerce_container_name' => 'dataLayer', // @since 1.8.1
84
+ 'tracker-address' => ""
85
  );
86
  return wp_parse_args( get_option( self::OPTION ), $defaults );
87
  }
127
  if ( ! current_user_can( 'manage_options' ) ) {
128
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'yandex-metrica' ) );
129
  }
130
+ wp_enqueue_script( 'jquery' );
131
  include( dirname( __FILE__ ) . '/templates/settings.php' );
132
  }
133