DuracellTomi's Google Tag Manager for WordPress - Version 0.9

Version Description

  • Added: visitorId dataLayer variable with the ID of the currently logged in user to track userID in Google Analytics
  • Added: WordPress filter hook so that other templates and plugins can get access to the GTM container code before outputting it
  • Fixed: 'variation incorrect' issue by Sharken03
  • Fixed: error messages in WooCommerce integration when product has no categories
  • Fixed: add_inline_js errors in newer versions of WooCommerce
  • Fixed: error message when some device/browser/OS data could not be set
  • Fixed: tracking Twitter events was broken
Download this release

Release Info

Developer duracelltomi
Plugin Icon 128x128 DuracellTomi's Google Tag Manager for WordPress
Version 0.9
Comparing to
See all releases

Code changes from version 0.8.2 to 0.9

admin/admin.php CHANGED
@@ -66,6 +66,10 @@ $GLOBALS["gtm4wp_includefieldtexts"] = array(
66
  "label" => __( "Logged in user role", GTM4WP_TEXTDOMAIN ),
67
  "description" => __( "Check this option to include the role of the logged in user.", GTM4WP_TEXTDOMAIN )
68
  ),
 
 
 
 
69
  GTM4WP_OPTION_INCLUDE_REMARKETING => array(
70
  "label" => __( "Remarketing variable", GTM4WP_TEXTDOMAIN ),
71
  "description" => __( "Check this option to include a dataLayer variable where all dataLayer values are stored to be included in your AdWords remarketing tag as a custom variable field", GTM4WP_TEXTDOMAIN )
@@ -142,7 +146,7 @@ $GLOBALS["gtm4wp_scrollerfieldtexts"] = array(
142
  ),
143
  GTM4WP_OPTION_SCROLLER_READERTIME => array(
144
  "label" => __( "Scroller time", GTM4WP_TEXTDOMAIN ),
145
- "description" => __( "Enter the number of milliseconds after the the scroller user is being treated as a reader, someone who really reads the content, not just scrolls through it.", GTM4WP_TEXTDOMAIN )
146
  )
147
  );
148
 
66
  "label" => __( "Logged in user role", GTM4WP_TEXTDOMAIN ),
67
  "description" => __( "Check this option to include the role of the logged in user.", GTM4WP_TEXTDOMAIN )
68
  ),
69
+ GTM4WP_OPTION_INCLUDE_USERID => array(
70
+ "label" => __( "Logged in user ID", GTM4WP_TEXTDOMAIN ),
71
+ "description" => __( "Check this option to include the ID of the logged in user.", GTM4WP_TEXTDOMAIN )
72
+ ),
73
  GTM4WP_OPTION_INCLUDE_REMARKETING => array(
74
  "label" => __( "Remarketing variable", GTM4WP_TEXTDOMAIN ),
75
  "description" => __( "Check this option to include a dataLayer variable where all dataLayer values are stored to be included in your AdWords remarketing tag as a custom variable field", GTM4WP_TEXTDOMAIN )
146
  ),
147
  GTM4WP_OPTION_SCROLLER_READERTIME => array(
148
  "label" => __( "Scroller time", GTM4WP_TEXTDOMAIN ),
149
+ "description" => __( "Enter the number of seconds after the the scroller user is being treated as a reader, someone who really reads the content, not just scrolls through it.", GTM4WP_TEXTDOMAIN )
150
  )
151
  );
152
 
common/readoptions.php CHANGED
@@ -7,6 +7,7 @@ define( 'GTM4WP_OPTION_DATALAYER_NAME', 'gtm-datalayer-variable-name' );
7
  define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
8
  define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN', 'include-loggedin' );
9
  define( 'GTM4WP_OPTION_INCLUDE_USERROLE', 'include-userrole' );
 
10
  define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE', 'include-posttype' );
11
  define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES', 'include-categories' );
12
  define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
@@ -90,6 +91,7 @@ $gtm4wp_defaultoptions = array(
90
  GTM4WP_OPTION_INCLUDE_REMARKETING => false,
91
  GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
92
  GTM4WP_OPTION_INCLUDE_USERROLE => false,
 
93
  GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
94
  GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
95
  GTM4WP_OPTION_INCLUDE_TAGS => true,
7
  define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
8
  define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN', 'include-loggedin' );
9
  define( 'GTM4WP_OPTION_INCLUDE_USERROLE', 'include-userrole' );
10
+ define( 'GTM4WP_OPTION_INCLUDE_USERID', 'include-userid' );
11
  define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE', 'include-posttype' );
12
  define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES', 'include-categories' );
13
  define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
91
  GTM4WP_OPTION_INCLUDE_REMARKETING => false,
92
  GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
93
  GTM4WP_OPTION_INCLUDE_USERROLE => false,
94
+ GTM4WP_OPTION_INCLUDE_USERID => false,
95
  GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
96
  GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
97
  GTM4WP_OPTION_INCLUDE_TAGS => true,
duracelltomi-google-tag-manager-for-wordpress.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /*
3
  Plugin Name: Google Tag Manager for Wordpress
4
- Version: 0.8.2
5
  Plugin URI: http://www.duracelltomi.com/google-tag-manager-for-wordpress/
6
  Description: The first Google Tag Manager plugin for WordPress with business goals in mind
7
  Author: Thomas Geiger
8
  Author URI: http://www.duracelltomi.com/
9
  */
10
 
11
- define( 'GTM4WP_VERSION', '0.8.2' );
12
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
13
  define( 'GTM4WP_TEXTDOMAIN', 'gtm4wp-lang' );
14
 
1
  <?php
2
  /*
3
  Plugin Name: Google Tag Manager for Wordpress
4
+ Version: 0.9
5
  Plugin URI: http://www.duracelltomi.com/google-tag-manager-for-wordpress/
6
  Description: The first Google Tag Manager plugin for WordPress with business goals in mind
7
  Author: Thomas Geiger
8
  Author URI: http://www.duracelltomi.com/
9
  */
10
 
11
+ define( 'GTM4WP_VERSION', '0.9' );
12
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
13
  define( 'GTM4WP_TEXTDOMAIN', 'gtm4wp-lang' );
14
 
integration/woocommerce.php CHANGED
@@ -1,6 +1,16 @@
1
  <?php
2
  $gtm4wp_product_counter = 0;
3
 
 
 
 
 
 
 
 
 
 
 
4
  function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
5
  global $woocommerce, $gtm4wp_options, $wp_query, $gtm4wp_datalayer_name, $gtm4wp_product_counter;
6
 
@@ -30,7 +40,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
30
 
31
  $product_price = $product->get_price();
32
  $_product_cats = get_the_terms($product->id, 'product_cat');
33
- if ( count( $_product_cats ) > 0 ) {
34
  $product_cat = array_pop( $_product_cats );
35
  $product_cat = $product_cat->name;
36
  } else {
@@ -64,7 +74,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
64
  $product = get_product( $prodid );
65
  $product_price = $product->get_price();
66
  $_product_cats = get_the_terms($product->id, 'product_cat');
67
- if ( count( $_product_cats ) > 0 ) {
68
  $product_cat = array_pop( $_product_cats );
69
  $product_cat = $product_cat->name;
70
  } else {
@@ -83,7 +93,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
83
  }
84
  } else if ( is_cart() ) {
85
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
86
- $woocommerce->add_inline_js("
87
  $('.product-remove').click(function() {
88
  var productdata = $( this )
89
  .parent()
@@ -139,7 +149,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
139
  $dataLayer["transactionType"] = "sale";
140
  $dataLayer["transactionAffiliation"] = get_bloginfo( 'name' );
141
  $dataLayer["transactionTotal"] = $order->get_total();
142
- $dataLayer["transactionShipping"] = $order->get_shipping();
143
  $dataLayer["transactionTax"] = $order->get_total_tax();
144
  $dataLayer["transactionPaymentType"] = $order->payment_method_title;
145
  $dataLayer["transactionCurrency"] = get_woocommerce_currency();
@@ -159,7 +169,12 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
159
  foreach ( $order->get_items() as $item ) {
160
  $_product = $order->get_product_from_item( $item );
161
 
162
- if ( isset( $_product->variation_data ) ) {
 
 
 
 
 
163
 
164
  $_category = woocommerce_get_formatted_variation( $_product->variation_data, true );
165
 
@@ -214,7 +229,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
214
  foreach( $woocommerce->cart->get_cart() as $cart_item_id => $cart_item_data) {
215
  $product = $cart_item_data["data"];
216
  $_product_cats = get_the_terms($product->id, 'product_cat');
217
- if ( count( $_product_cats ) > 0 ) {
218
  $product_cat = array_pop( $_product_cats );
219
  $product_cat = $product_cat->name;
220
  } else {
@@ -243,7 +258,7 @@ function gtm4wp_woocommerce_single_add_to_cart_tracking() {
243
  global $product, $woocommerce, $gtm4wp_datalayer_name, $gtm4wp_options;
244
 
245
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
246
- $woocommerce->add_inline_js("
247
  $('.single_add_to_cart_button').click(function() {
248
  ". $gtm4wp_datalayer_name .".push({
249
  'event': 'gtm4wp.addProductToCart',
@@ -257,14 +272,14 @@ function gtm4wp_woocommerce_single_add_to_cart_tracking() {
257
 
258
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
259
  $_product_cats = get_the_terms($product->id, 'product_cat');
260
- if ( count( $_product_cats ) > 0 ) {
261
  $product_cat = array_pop( $_product_cats );
262
  $product_cat = $product_cat->name;
263
  } else {
264
  $product_cat = "";
265
  }
266
 
267
- $woocommerce->add_inline_js("
268
  $('.single_add_to_cart_button').click(function() {
269
  ". $gtm4wp_datalayer_name .".push({
270
  'event': 'gtm4wp.addProductToCart',
@@ -286,11 +301,11 @@ function gtm4wp_woocommerce_single_add_to_cart_tracking() {
286
  }
287
  }
288
 
289
- function gtm4wp_woocommerce_loop_add_to_cart_tracking() {
290
  global $woocommerce, $gtm4wp_options, $gtm4wp_datalayer_name;
291
 
292
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
293
- $woocommerce->add_inline_js("
294
  $('.add_to_cart_button:not(.product_type_variable, .product_type_grouped)').click(function() {
295
  ". $gtm4wp_datalayer_name .".push({
296
  'event': 'gtm4wp.addProductToCart',
@@ -303,7 +318,7 @@ function gtm4wp_woocommerce_loop_add_to_cart_tracking() {
303
  }
304
 
305
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
306
- $woocommerce->add_inline_js("
307
  $('.add_to_cart_button:not(.product_type_variable, .product_type_grouped)').click(function() {
308
  var productdata = $( this ).parent().find( 'a .gtm4wp_productdata' );
309
 
@@ -330,7 +345,7 @@ function gtm4wp_woocommerce_loop_add_to_cart_tracking() {
330
  function gtm4wp_woocommerce_enhanced_ecom_product_click() {
331
  global $woocommerce, $gtm4wp_datalayer_name;
332
 
333
- $woocommerce->add_inline_js("
334
  $('.products li a:not(.add_to_cart_button)').click(function() {
335
  var productdata = $( this ).find( '.gtm4wp_productdata' );
336
 
@@ -365,7 +380,7 @@ function gtm4wp_woocommerce_enhanced_ecom_add_prod_data() {
365
 
366
  $product_price = $product->get_price();
367
  $_product_cats = get_the_terms($product->id, 'product_cat');
368
- if ( count( $_product_cats ) > 0 ) {
369
  $product_cat = array_pop( $_product_cats );
370
  $product_cat = $product_cat->name;
371
  } else {
@@ -380,7 +395,7 @@ $GLOBALS["gtm4wp_cart_item_proddata"] = '';
380
  function gtm4wp_woocommerce_cart_item_product_filter($product) {
381
  $product_price = $product->get_price();
382
  $_product_cats = get_the_terms($product->id, 'product_cat');
383
- if ( count( $_product_cats ) > 0 ) {
384
  $product_cat = array_pop( $_product_cats );
385
  $product_cat = $product_cat->name;
386
  } else {
@@ -405,7 +420,7 @@ if ( isset ( $GLOBALS["woocommerce"] ) ) {
405
  add_filter( "woocommerce_cart_item_remove_link", "gtm4wp_woocommerce_cart_item_remove_link_filter" );
406
 
407
  add_action( 'woocommerce_after_add_to_cart_button', "gtm4wp_woocommerce_single_add_to_cart_tracking" );
408
- add_action( 'wp_footer', "gtm4wp_woocommerce_loop_add_to_cart_tracking" );
409
 
410
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
411
  add_action( 'wp_footer', 'gtm4wp_woocommerce_enhanced_ecom_product_click' );
1
  <?php
2
  $gtm4wp_product_counter = 0;
3
 
4
+ function gtm4wp_woocommerce_addjs( $js ) {
5
+ global $woocommerce;
6
+
7
+ if ( version_compare( $woocommerce->version, "2.1", ">=" ) ) {
8
+ wc_enqueue_js( $js );
9
+ } else {
10
+ $woocommerce->add_inline_js( $js );
11
+ }
12
+ }
13
+
14
  function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
15
  global $woocommerce, $gtm4wp_options, $wp_query, $gtm4wp_datalayer_name, $gtm4wp_product_counter;
16
 
40
 
41
  $product_price = $product->get_price();
42
  $_product_cats = get_the_terms($product->id, 'product_cat');
43
+ if ( ( is_array($_product_cats) ) && ( count( $_product_cats ) > 0 ) ) {
44
  $product_cat = array_pop( $_product_cats );
45
  $product_cat = $product_cat->name;
46
  } else {
74
  $product = get_product( $prodid );
75
  $product_price = $product->get_price();
76
  $_product_cats = get_the_terms($product->id, 'product_cat');
77
+ if ( ( is_array($_product_cats) ) && ( count( $_product_cats ) > 0 ) ) {
78
  $product_cat = array_pop( $_product_cats );
79
  $product_cat = $product_cat->name;
80
  } else {
93
  }
94
  } else if ( is_cart() ) {
95
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
96
+ gtm4wp_woocommerce_addjs("
97
  $('.product-remove').click(function() {
98
  var productdata = $( this )
99
  .parent()
149
  $dataLayer["transactionType"] = "sale";
150
  $dataLayer["transactionAffiliation"] = get_bloginfo( 'name' );
151
  $dataLayer["transactionTotal"] = $order->get_total();
152
+ $dataLayer["transactionShipping"] = $order->get_total_shipping();
153
  $dataLayer["transactionTax"] = $order->get_total_tax();
154
  $dataLayer["transactionPaymentType"] = $order->payment_method_title;
155
  $dataLayer["transactionCurrency"] = get_woocommerce_currency();
169
  foreach ( $order->get_items() as $item ) {
170
  $_product = $order->get_product_from_item( $item );
171
 
172
+ $variation_data = null;
173
+ if (get_class($_product) == "WC_Product_Variation") {
174
+ $variation_data = $_product->get_variation_attributes();
175
+ }
176
+
177
+ if ( isset( $variation_data ) ) {
178
 
179
  $_category = woocommerce_get_formatted_variation( $_product->variation_data, true );
180
 
229
  foreach( $woocommerce->cart->get_cart() as $cart_item_id => $cart_item_data) {
230
  $product = $cart_item_data["data"];
231
  $_product_cats = get_the_terms($product->id, 'product_cat');
232
+ if ( ( is_array($_product_cats) ) && ( count( $_product_cats ) > 0 ) ) {
233
  $product_cat = array_pop( $_product_cats );
234
  $product_cat = $product_cat->name;
235
  } else {
258
  global $product, $woocommerce, $gtm4wp_datalayer_name, $gtm4wp_options;
259
 
260
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
261
+ gtm4wp_woocommerce_addjs("
262
  $('.single_add_to_cart_button').click(function() {
263
  ". $gtm4wp_datalayer_name .".push({
264
  'event': 'gtm4wp.addProductToCart',
272
 
273
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
274
  $_product_cats = get_the_terms($product->id, 'product_cat');
275
+ if ( ( is_array($_product_cats) ) && ( count( $_product_cats ) > 0 ) ) {
276
  $product_cat = array_pop( $_product_cats );
277
  $product_cat = $product_cat->name;
278
  } else {
279
  $product_cat = "";
280
  }
281
 
282
+ gtm4wp_woocommerce_addjs("
283
  $('.single_add_to_cart_button').click(function() {
284
  ". $gtm4wp_datalayer_name .".push({
285
  'event': 'gtm4wp.addProductToCart',
301
  }
302
  }
303
 
304
+ function gtm4wp_woocommerce_wp_footer() {
305
  global $woocommerce, $gtm4wp_options, $gtm4wp_datalayer_name;
306
 
307
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ) {
308
+ gtm4wp_woocommerce_addjs("
309
  $('.add_to_cart_button:not(.product_type_variable, .product_type_grouped)').click(function() {
310
  ". $gtm4wp_datalayer_name .".push({
311
  'event': 'gtm4wp.addProductToCart',
318
  }
319
 
320
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
321
+ gtm4wp_woocommerce_addjs("
322
  $('.add_to_cart_button:not(.product_type_variable, .product_type_grouped)').click(function() {
323
  var productdata = $( this ).parent().find( 'a .gtm4wp_productdata' );
324
 
345
  function gtm4wp_woocommerce_enhanced_ecom_product_click() {
346
  global $woocommerce, $gtm4wp_datalayer_name;
347
 
348
+ gtm4wp_woocommerce_addjs("
349
  $('.products li a:not(.add_to_cart_button)').click(function() {
350
  var productdata = $( this ).find( '.gtm4wp_productdata' );
351
 
380
 
381
  $product_price = $product->get_price();
382
  $_product_cats = get_the_terms($product->id, 'product_cat');
383
+ if ( ( is_array($_product_cats) ) && ( count( $_product_cats ) > 0 ) ) {
384
  $product_cat = array_pop( $_product_cats );
385
  $product_cat = $product_cat->name;
386
  } else {
395
  function gtm4wp_woocommerce_cart_item_product_filter($product) {
396
  $product_price = $product->get_price();
397
  $_product_cats = get_the_terms($product->id, 'product_cat');
398
+ if ( ( is_array( $_product_cats ) ) && ( count( $_product_cats ) > 0 ) ) {
399
  $product_cat = array_pop( $_product_cats );
400
  $product_cat = $product_cat->name;
401
  } else {
420
  add_filter( "woocommerce_cart_item_remove_link", "gtm4wp_woocommerce_cart_item_remove_link_filter" );
421
 
422
  add_action( 'woocommerce_after_add_to_cart_button', "gtm4wp_woocommerce_single_add_to_cart_tracking" );
423
+ add_action( 'wp_footer', "gtm4wp_woocommerce_wp_footer" );
424
 
425
  if ( true === $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
426
  add_action( 'wp_footer', 'gtm4wp_woocommerce_enhanced_ecom_product_click' );
js/admin-subtabs.js CHANGED
@@ -12,7 +12,7 @@ var adminsubtabs = {
12
  },
13
  "visitor": {
14
  tabtext: gtm4wp.visitortabtitle,
15
- numitems: 2
16
  },
17
  "adwords": {
18
  tabtext: gtm4wp.adwordstabtitle,
12
  },
13
  "visitor": {
14
  tabtext: gtm4wp.visitortabtitle,
15
+ numitems: 3
16
  },
17
  "adwords": {
18
  tabtext: gtm4wp.adwordstabtitle,
js/gtm4wp-social-tracker.js CHANGED
@@ -60,7 +60,7 @@ jQuery( function() {
60
  } (document, "script", "twitter-wjs"));
61
  } // end of loading Twitter JS
62
 
63
- twttr.ready(function ( twttr ) {
64
  twttr.events.bind( 'tweet', function ( intent_event ) {
65
  if ( intent_event ) {
66
  var label = intent_event.data.tweet_id;
@@ -78,14 +78,14 @@ jQuery( function() {
78
  }
79
  });
80
 
81
- twttr.events.bind( 'follow', function ( intent_event ) {
82
  if ( intent_event ) {
83
  var label = intent_event.data.user_id + " (" + intent_event.data.screen_name + ")";
84
 
85
  window[ gtm4wp_datalayer_name ].push({
86
  'event': 'gtm4wp.socialAction',
87
  'network': 'twitter',
88
- 'socialAction': 'tweet',
89
  'opt_target': label,
90
  'opt_pagePath': window.location.href
91
  });
60
  } (document, "script", "twitter-wjs"));
61
  } // end of loading Twitter JS
62
 
63
+ window.twttr.ready(function ( twttr ) {
64
  twttr.events.bind( 'tweet', function ( intent_event ) {
65
  if ( intent_event ) {
66
  var label = intent_event.data.tweet_id;
78
  }
79
  });
80
 
81
+ window.twttr.events.bind( 'follow', function ( intent_event ) {
82
  if ( intent_event ) {
83
  var label = intent_event.data.user_id + " (" + intent_event.data.screen_name + ")";
84
 
85
  window[ gtm4wp_datalayer_name ].push({
86
  'event': 'gtm4wp.socialAction',
87
  'network': 'twitter',
88
+ 'socialAction': 'follow',
89
  'opt_target': label,
90
  'opt_pagePath': window.location.href
91
  });
languages/en.pot CHANGED
@@ -393,7 +393,7 @@ msgid "Scroller time"
393
  msgstr ""
394
 
395
  msgid ""
396
- "Enter the number of milliseconds after the the scroller user is being "
397
  "treated as a reader, someone who really reads the content, not just scrolls "
398
  "through it."
399
  msgstr ""
@@ -660,3 +660,9 @@ msgstr ""
660
 
661
  msgid "Select which temperature units you would like to use."
662
  msgstr ""
 
 
 
 
 
 
393
  msgstr ""
394
 
395
  msgid ""
396
+ "Enter the number of seconds after the the scroller user is being "
397
  "treated as a reader, someone who really reads the content, not just scrolls "
398
  "through it."
399
  msgstr ""
660
 
661
  msgid "Select which temperature units you would like to use."
662
  msgstr ""
663
+
664
+ msgid "Logged in user ID"
665
+ msgstr ""
666
+
667
+ msgid "Check this option to include the ID of the logged in user."
668
+ msgstr ""
languages/gtm4wp-lang-hu_HU.mo CHANGED
Binary file
languages/gtm4wp-lang-hu_HU.po CHANGED
@@ -3,12 +3,13 @@ msgstr ""
3
  "Project-Id-Version: \n"
4
  "POT-Creation-Date: \n"
5
  "PO-Revision-Date: \n"
6
- "Last-Translator: Thomas Geiger <duracelltomi@gmail.com>\n"
7
  "Language-Team: JabJab Online Marketing\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.5.7\n"
 
12
 
13
  #: ../admin/admin.php:18
14
  msgid "Remarketing variable"
@@ -486,12 +487,11 @@ msgid "Scroller time"
486
  msgstr "Görgető felhasználó"
487
 
488
  msgid ""
489
- "Enter the number of milliseconds after the the scroller user is being "
490
- "treated as a reader, someone who really reads the content, not just scrolls "
491
- "through it."
492
  msgstr ""
493
- "Adja meg, hány milliszekundum után számít a látogató olvasónak, aki tényleg "
494
- "el is olvassa a tartalmat, nem csak átfutja."
495
 
496
  msgid "Fire tags based on how the visitor scrolls through your page."
497
  msgstr "Címkék aktiválása, ahogy a felhasználó görget az oldalon belül."
@@ -817,3 +817,11 @@ msgstr ""
817
 
818
  msgid "Select which temperature units you would like to use."
819
  msgstr "Válassza ki, milyen hőmérsékleti egységet szeretne használni."
 
 
 
 
 
 
 
 
3
  "Project-Id-Version: \n"
4
  "POT-Creation-Date: \n"
5
  "PO-Revision-Date: \n"
6
+ "Last-Translator: Thomas Geiger <tomi@jabjab.hu>\n"
7
  "Language-Team: JabJab Online Marketing\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.7.3\n"
12
+ "Language: hu_HU\n"
13
 
14
  #: ../admin/admin.php:18
15
  msgid "Remarketing variable"
487
  msgstr "Görgető felhasználó"
488
 
489
  msgid ""
490
+ "Enter the number of seconds after the the scroller user is being treated as "
491
+ "a reader, someone who really reads the content, not just scrolls through it."
 
492
  msgstr ""
493
+ "Adja meg, hány másodperc után számít a látogató olvasónak, aki tényleg el is "
494
+ "olvassa a tartalmat, nem csak átfutja."
495
 
496
  msgid "Fire tags based on how the visitor scrolls through your page."
497
  msgstr "Címkék aktiválása, ahogy a felhasználó görget az oldalon belül."
817
 
818
  msgid "Select which temperature units you would like to use."
819
  msgstr "Válassza ki, milyen hőmérsékleti egységet szeretne használni."
820
+
821
+ msgid "Logged in user ID"
822
+ msgstr "Felhasználó azonosítója"
823
+
824
+ msgid "Check this option to include the ID of the logged in user."
825
+ msgstr ""
826
+ "Kapcsolja be ezt a beállítást, ha szeretné látni a bejelentkezett "
827
+ "felhasználó egyedi azonosítóját."
public/frontend.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
- define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER', 'gtp4wp_compile_datalayer');
3
- define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtp4wp_compile_remarkering');
 
4
 
5
  if ( $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_DATALAYER_NAME ] == "" ) {
6
  $GLOBALS[ "gtm4wp_datalayer_name" ] = "dataLayer";
@@ -43,6 +44,10 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
43
  $dataLayer["visitorType"] = ( $current_user->roles[0] == NULL ? "visitor-logged-out" : $current_user->roles[0] );
44
  }
45
 
 
 
 
 
46
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
47
  $dataLayer["pageTitle"] = strip_tags( wp_title( "|", false, "right" ) );
48
  }
@@ -169,22 +174,22 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
169
  $detected = new WhichBrowser( array( "headers" => getallheaders() ) );
170
 
171
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] ) {
172
- $dataLayer["browserName"] = $detected->browser->name;
173
- $dataLayer["browserVersion"] = $detected->browser->version->value;
174
 
175
- $dataLayer["browserEngineName"] = $detected->engine->name;
176
- $dataLayer["browserEngineVersion"] = $detected->engine->version->value;
177
  }
178
 
179
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] ) {
180
- $dataLayer["osName"] = $detected->os->name;
181
- $dataLayer["osVersion"] = $detected->os->version->value;
182
  }
183
 
184
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
185
- $dataLayer["deviceType"] = $detected->device->type;
186
- $dataLayer["deviceManufacturer"] = $detected->device->manufacturer;
187
- $dataLayer["deviceModel"] = $detected->device->model;
188
  }
189
  }
190
 
@@ -390,7 +395,7 @@ j=d.createElement(s),dl=l!=\'' . $gtm4wp_datalayer_name . '\'?\'&l=\'+l:\'\';j.a
390
  <!-- End Google Tag Manager -->';
391
  }
392
 
393
- return $_gtm_tag;
394
  }
395
 
396
  function gtm4wp_the_gtm_tag() {
@@ -456,9 +461,7 @@ function gtm4wp_wp_header_begin() {
456
  <!-- Google Tag Manager for WordPress by DuracellTomi - http://duracelltomi.com -->
457
  <script type="text/javascript">
458
  var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
459
- if ( "undefined" == typeof '.$gtm4wp_datalayer_name.' ) {
460
- ' . $gtm4wp_datalayer_name . ' = new Array();
461
- }';
462
 
463
  if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
464
  $_gtm_header_content .= '
1
  <?php
2
+ define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER', 'gtm4wp_compile_datalayer' );
3
+ define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtm4wp_compile_remarkering' );
4
+ define( 'GTM4WP_WPFILTER_GETTHEGTMTAG', 'gtm4wp_get_the_gtm_tag' );
5
 
6
  if ( $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_DATALAYER_NAME ] == "" ) {
7
  $GLOBALS[ "gtm4wp_datalayer_name" ] = "dataLayer";
44
  $dataLayer["visitorType"] = ( $current_user->roles[0] == NULL ? "visitor-logged-out" : $current_user->roles[0] );
45
  }
46
 
47
+ if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_USERID ] ) {
48
+ $dataLayer["visitorId"] = get_current_user_id();
49
+ }
50
+
51
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
52
  $dataLayer["pageTitle"] = strip_tags( wp_title( "|", false, "right" ) );
53
  }
174
  $detected = new WhichBrowser( array( "headers" => getallheaders() ) );
175
 
176
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] ) {
177
+ $dataLayer["browserName"] = isset( $detected->browser->name ) ? $detected->browser->name : "";
178
+ $dataLayer["browserVersion"] = isset( $detected->browser->version->value ) ? $detected->browser->version->value : "";
179
 
180
+ $dataLayer["browserEngineName"] = isset( $detected->engine->name ) ? $detected->engine->name : "";
181
+ $dataLayer["browserEngineVersion"] = isset( $detected->engine->version->value ) ? $detected->engine->version->value : "";
182
  }
183
 
184
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] ) {
185
+ $dataLayer["osName"] = isset( $detected->os->name ) ? $detected->os->name : "";
186
+ $dataLayer["osVersion"] = isset( $detected->os->version->value ) ? $detected->os->version->value : "";
187
  }
188
 
189
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
190
+ $dataLayer["deviceType"] = isset( $detected->device->type ) ? $detected->device->type : "";
191
+ $dataLayer["deviceManufacturer"] = isset( $detected->device->manufacturer ) ? $detected->device->manufacturer : "";
192
+ $dataLayer["deviceModel"] = isset( $detected->device->model ) ? $detected->device->model : "";
193
  }
194
  }
195
 
395
  <!-- End Google Tag Manager -->';
396
  }
397
 
398
+ return apply_filters( GTM4WP_WPFILTER_GETTHEGTMTAG, $_gtm_tag );
399
  }
400
 
401
  function gtm4wp_the_gtm_tag() {
461
  <!-- Google Tag Manager for WordPress by DuracellTomi - http://duracelltomi.com -->
462
  <script type="text/javascript">
463
  var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
464
+ var ' . $gtm4wp_datalayer_name . ' = ' . $gtm4wp_datalayer_name . ' || []';
 
 
465
 
466
  if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
467
  $_gtm_header_content .= '
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://duracelltomi.com/
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics
5
  Requires at least: 3.0.1
6
  Tested up to: 4.1
7
- Stable tag: 0.8.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -31,6 +31,7 @@ very easily since you can fire them using rules that include
31
  * post count on the current page + in the current category/tag/taxonomy
32
  * logged in status
33
  * logged in user role
 
34
  * search data
35
 
36
  Use search data to generate Analytics events when an empty search result is being shown.
@@ -140,23 +141,24 @@ More integration to come!
140
 
141
  = How can I implement enhanced e-commerce in Google Tag Manager =
142
 
143
- First of all please remember that this feature of this plugin is still experimental and the feature of Google Analytics
144
- is still in beta. Therefore it is recommended to create a separate web property to be used with enhanced e-commerce
145
- in paralel to you current "classic" e-commerce tracking.
146
 
147
- To be able to implement the necessary tags just follow the instructions shown on the official documentation of Google:
148
- https://developers.google.com/tag-manager/enhanced-ecommerce
149
 
150
- There is only one thing you have to change: event names:
 
 
151
 
152
- * productClick -> gtm4wp.productClick
153
- * addToCart -> gtm4wp.addProductToCart
154
- * removeFromCart -> gtm4wp.removeProductFromCart
155
- * promotionClick -> gtm4wp.promotionClick
156
 
157
- = Why isn't there an option do blacklist tag/macro classes =
 
 
158
 
159
- Although Google recommends to blacklist tags and macros using classes, I found it complicated for people to understand
 
 
160
  what tags and macros are being blacklisted/whitelisted automatically using classses. Therefore I decided to include
161
  individual tags and macros on the blacklist tabs.
162
 
@@ -165,7 +167,7 @@ with any macro in your container.
165
 
166
  = How can I track add-to-cart events in WooCommerce =
167
 
168
- To track add-to-cart events you have to catch the dataLayer event gtm4wp.addProductToCart
169
 
170
  There are 3 additional dataLayer variables that can be accessed during the event using classic ecommerce tracking:
171
 
@@ -244,6 +246,16 @@ If you or your social plugin inserts the Facebook buttons using IFRAME-s (like S
244
 
245
  == Changelog ==
246
 
 
 
 
 
 
 
 
 
 
 
247
  = 0.8.2 =
248
 
249
  * Fixed: broken links when listing subcategories instead of products (thanks Jon)
@@ -320,6 +332,10 @@ If you or your social plugin inserts the Facebook buttons using IFRAME-s (like S
320
 
321
  == Upgrade Notice ==
322
 
 
 
 
 
323
  = 0.8.2 =
324
 
325
  Another bugfix release for WooCommerce users with Enhanced Ecommerce enabled
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics
5
  Requires at least: 3.0.1
6
  Tested up to: 4.1
7
+ Stable tag: 0.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
31
  * post count on the current page + in the current category/tag/taxonomy
32
  * logged in status
33
  * logged in user role
34
+ * logged in user ID (to track cross device behavior in Google Analytics)
35
  * search data
36
 
37
  Use search data to generate Analytics events when an empty search result is being shown.
141
 
142
  = How can I implement enhanced e-commerce in Google Tag Manager =
143
 
144
+ I created a step-by-step guide for this:
145
+ http://duracelltomi.com/google-tag-manager-for-wordpress/how-to-articles/setup-enhanced-ecommerce-tracking
 
146
 
147
+ = PayPal transactions in WooCommerce are not being tracked in Google Analyics =
 
148
 
149
+ PayPal does not redirect the user back to your website by default.
150
+ It offers the route back for your customer but it can happen that users simply close the browser
151
+ before they get back to your thankyou page (aka. order received page)
152
 
153
+ This means that neither Google Analyics tags or any other tags are being fired.
 
 
 
154
 
155
+ Enable auto return in your PayPal settings. This will instruct PayPal to show a quick
156
+ info page after payment and then redirect the user back to your site. This will
157
+ increase the number of tracked transactions.
158
 
159
+ = Why isn't there an option to blacklist tag/macro classes =
160
+
161
+ Although Google recommends to blacklist tags and macros using classes, I found it is complicated for people to understand
162
  what tags and macros are being blacklisted/whitelisted automatically using classses. Therefore I decided to include
163
  individual tags and macros on the blacklist tabs.
164
 
167
 
168
  = How can I track add-to-cart events in WooCommerce =
169
 
170
+ To track add-to-cart events using classic transactions you have to catch the dataLayer event gtm4wp.addProductToCart
171
 
172
  There are 3 additional dataLayer variables that can be accessed during the event using classic ecommerce tracking:
173
 
246
 
247
  == Changelog ==
248
 
249
+ = 0.9 =
250
+
251
+ * Added: visitorId dataLayer variable with the ID of the currently logged in user to track userID in Google Analytics
252
+ * Added: WordPress filter hook so that other templates and plugins can get access to the GTM container code before outputting it
253
+ * Fixed: 'variation incorrect' issue by Sharken03
254
+ * Fixed: error messages in WooCommerce integration when product has no categories
255
+ * Fixed: add_inline_js errors in newer versions of WooCommerce
256
+ * Fixed: error message when some device/browser/OS data could not be set
257
+ * Fixed: tracking Twitter events was broken
258
+
259
  = 0.8.2 =
260
 
261
  * Fixed: broken links when listing subcategories instead of products (thanks Jon)
332
 
333
  == Upgrade Notice ==
334
 
335
+ = 0.9 =
336
+
337
+ Many bug fixes, important fixes for WooCommerce users
338
+
339
  = 0.8.2 =
340
 
341
  Another bugfix release for WooCommerce users with Enhanced Ecommerce enabled