DuracellTomi's Google Tag Manager for WordPress - Version 0.4

Version Description

  • New: you can now select container code placement. This way you can insert the code snippet after the opening body tag. Please read FAQ for details
  • New: initial support for social event tracking for Facebook and Twitter buttons. Please read FAQ for details
  • Updated: event name on successful WooCommerce transacion: OrderCompleted -> gtm4wp.orderCompleted
  • Fixed: frontend JS codes did not load on some WordPress installs
Download this release

Release Info

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

Code changes from version 0.3 to 0.4

admin/admin.php CHANGED
@@ -4,6 +4,7 @@ define( 'GTM4WP_ADMIN_GROUP', 'gtm4wp-admin-group' );
4
 
5
  define( 'GTM4WP_ADMIN_GROUP_GENERAL', 'gtm4wp-admin-group-general' );
6
  define( 'GTM4WP_ADMIN_GROUP_GTMID', 'gtm4wp-admin-group-gtm-id' );
 
7
  define( 'GTM4WP_ADMIN_GROUP_DATALAYER', 'gtm4wp-admin-group-datalayer-name' );
8
  define( 'GTM4WP_ADMIN_GROUP_INFO', 'gtm4wp-admin-group-datalayer-info' );
9
 
@@ -76,6 +77,10 @@ $GLOBALS["gtm4wp_eventfieldtexts"] = array(
76
  GTM4WP_OPTION_EVENTS_FORMMOVE => array(
77
  "label" => __( "Form fill events (gtm4wp.formElementEnter & gtm4wp.formElementLeave)", GTM4WP_TEXTDOMAIN ),
78
  "description" => __( "Check this option to include a Tag Manager event when a visitor moves between elements of a form (comment, contact, etc).", GTM4WP_TEXTDOMAIN )
 
 
 
 
79
  )
80
  );
81
 
@@ -149,6 +154,13 @@ function gtm4wp_admin_output_field( $args ) {
149
 
150
  break;
151
  }
 
 
 
 
 
 
 
152
 
153
  case GTM4WP_ADMIN_GROUP_DATALAYER: {
154
  echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" value="' . $gtm4wp_options[GTM4WP_OPTION_DATALAYER_NAME] . '" /><br />' . $args["description"];
@@ -223,6 +235,11 @@ function gtm4wp_sanitize_options($options) {
223
  } else {
224
  $output[$optionname] = $newoptionvalue;
225
  }
 
 
 
 
 
226
  } else {
227
  $output[$optionname] = $newoptionvalue;
228
  }
@@ -255,6 +272,18 @@ function gtm4wp_admin_init() {
255
  )
256
  );
257
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  add_settings_section(
259
  GTM4WP_ADMIN_GROUP_INCLUDES,
260
  __( 'Basic data', GTM4WP_TEXTDOMAIN ),
@@ -395,9 +424,9 @@ function gtm4wp_add_admin_js($hook) {
395
  global $gtp4wp_plugin_url;
396
 
397
  if ( $hook == "settings_page_" . GTM4WP_ADMINSLUG ) {
398
- wp_enqueue_script( "admin-tabcreator", $gtp4wp_plugin_url . "/js/admin-tabcreator.js", array( "jquery-core" ), "1.0" );
399
 
400
- wp_enqueue_style( "gtm4wp-validate", $gtp4wp_plugin_url . "/css/admin-gtm4wp.css", array(), "1.0" );
401
  }
402
  }
403
 
4
 
5
  define( 'GTM4WP_ADMIN_GROUP_GENERAL', 'gtm4wp-admin-group-general' );
6
  define( 'GTM4WP_ADMIN_GROUP_GTMID', 'gtm4wp-admin-group-gtm-id' );
7
+ define( 'GTM4WP_ADMIN_GROUP_PLACEMENT', 'gtm4wp-admin-code-placement' );
8
  define( 'GTM4WP_ADMIN_GROUP_DATALAYER', 'gtm4wp-admin-group-datalayer-name' );
9
  define( 'GTM4WP_ADMIN_GROUP_INFO', 'gtm4wp-admin-group-datalayer-info' );
10
 
77
  GTM4WP_OPTION_EVENTS_FORMMOVE => array(
78
  "label" => __( "Form fill events (gtm4wp.formElementEnter & gtm4wp.formElementLeave)", GTM4WP_TEXTDOMAIN ),
79
  "description" => __( "Check this option to include a Tag Manager event when a visitor moves between elements of a form (comment, contact, etc).", GTM4WP_TEXTDOMAIN )
80
+ ),
81
+ GTM4WP_OPTION_EVENTS_SOCIAL => array(
82
+ "label" => __( "Social actions (gtm4wp.socialAction)", GTM4WP_TEXTDOMAIN ),
83
+ "description" => __( "Check this option to include a Tag Manager event when a visitor uses a social button to share/like content on a social network.", GTM4WP_TEXTDOMAIN )
84
  )
85
  );
86
 
154
 
155
  break;
156
  }
157
+
158
+ case GTM4WP_ADMIN_GROUP_PLACEMENT: {
159
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="0" ' . ( $gtm4wp_options[GTM4WP_OPTION_GTM_PLACEMENT] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( "Footer of the page (not recommended by Google, no tweak in your template required)", GTM4WP_TEXTDOMAIN ) . '<br />';
160
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_PLACEMENT . ']" value="1" ' . ( $gtm4wp_options[GTM4WP_OPTION_GTM_PLACEMENT] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( "Custom (needs tweak in your template)", GTM4WP_TEXTDOMAIN ) . '<br />' . $args["description"];
161
+
162
+ break;
163
+ }
164
 
165
  case GTM4WP_ADMIN_GROUP_DATALAYER: {
166
  echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" value="' . $gtm4wp_options[GTM4WP_OPTION_DATALAYER_NAME] . '" /><br />' . $args["description"];
235
  } else {
236
  $output[$optionname] = $newoptionvalue;
237
  }
238
+ } else if ( $optionname == GTM4WP_ADMIN_GROUP_PLACEMENT ) {
239
+ $output[$optionname] = (int) $newoptionvalue;
240
+ if ( ( $output[$optionname] < 0) || ( $output[$optionname] > 1 ) ) {
241
+ $output[$optionname] = 0;
242
+ }
243
  } else {
244
  $output[$optionname] = $newoptionvalue;
245
  }
272
  )
273
  );
274
 
275
+ add_settings_field(
276
+ GTM4WP_ADMIN_GROUP_PLACEMENT,
277
+ __( 'Container code placement', GTM4WP_TEXTDOMAIN ),
278
+ 'gtm4wp_admin_output_field',
279
+ GTM4WP_ADMINSLUG,
280
+ GTM4WP_ADMIN_GROUP_GENERAL,
281
+ array(
282
+ "label_for" => GTM4WP_ADMIN_GROUP_PLACEMENT,
283
+ "description" => __( "Select how your container code should be included in your website.<br />If you select 'Custom' you need to edit your template file and add the following line just after the opening &lt;body&gt; tag:<br /><code>&lt;?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?&gt;</code>", GTM4WP_TEXTDOMAIN )
284
+ )
285
+ );
286
+
287
  add_settings_section(
288
  GTM4WP_ADMIN_GROUP_INCLUDES,
289
  __( 'Basic data', GTM4WP_TEXTDOMAIN ),
424
  global $gtp4wp_plugin_url;
425
 
426
  if ( $hook == "settings_page_" . GTM4WP_ADMINSLUG ) {
427
+ wp_enqueue_script( "admin-tabcreator", $gtp4wp_plugin_url . "js/admin-tabcreator.js", array( "jquery-core" ), "1.0" );
428
 
429
+ wp_enqueue_style( "gtm4wp-validate", $gtp4wp_plugin_url . "css/admin-gtm4wp.css", array(), "1.0" );
430
  }
431
  }
432
 
common/readoptions.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  define( 'GTM4WP_OPTIONS', 'gtm4wp-options' );
3
  define( 'GTM4WP_OPTION_GTM_CODE', 'gtm-code' );
 
4
  define( 'GTM4WP_OPTION_DATALAYER_NAME', 'gtm-datalayer-variable-name' );
5
 
6
  define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
@@ -19,16 +20,21 @@ define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
19
  define( 'GTM4WP_OPTION_EVENTS_DWLEXT', 'event-download-extensions' );
20
  define( 'GTM4WP_OPTION_EVENTS_EMAILCLICKS', 'event-email-clicks' );
21
  define( 'GTM4WP_OPTION_EVENTS_FORMMOVE', 'event-form-move' );
 
22
 
23
  define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
24
  define( 'GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE', 'integrate-woocommerce' );
25
  define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );
26
 
 
 
 
27
  $gtm4wp_options = array();
28
 
29
  $gtm4wp_defaultoptions = array(
30
  GTM4WP_OPTION_GTM_CODE => "",
31
  GTM4WP_OPTION_DATALAYER_NAME => "",
 
32
 
33
  GTM4WP_OPTION_INCLUDE_REMARKETING => false,
34
  GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
@@ -46,6 +52,7 @@ $gtm4wp_defaultoptions = array(
46
  GTM4WP_OPTION_EVENTS_DWLEXT => "pdf,doc,docx,xls,xlsx,ppt,pptx,zip,rar,gz,tar",
47
  GTM4WP_OPTION_EVENTS_EMAILCLICKS => false,
48
  GTM4WP_OPTION_EVENTS_FORMMOVE => true,
 
49
 
50
  GTM4WP_OPTION_INTEGRATE_WPCF7 => true,
51
  GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE => false,
1
  <?php
2
  define( 'GTM4WP_OPTIONS', 'gtm4wp-options' );
3
  define( 'GTM4WP_OPTION_GTM_CODE', 'gtm-code' );
4
+ define( 'GTM4WP_OPTION_GTM_PLACEMENT', 'gtm-code-placement' );
5
  define( 'GTM4WP_OPTION_DATALAYER_NAME', 'gtm-datalayer-variable-name' );
6
 
7
  define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
20
  define( 'GTM4WP_OPTION_EVENTS_DWLEXT', 'event-download-extensions' );
21
  define( 'GTM4WP_OPTION_EVENTS_EMAILCLICKS', 'event-email-clicks' );
22
  define( 'GTM4WP_OPTION_EVENTS_FORMMOVE', 'event-form-move' );
23
+ define( 'GTM4WP_OPTION_EVENTS_SOCIAL', 'event-social' );
24
 
25
  define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
26
  define( 'GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE', 'integrate-woocommerce' );
27
  define( 'GTM4WP_OPTION_INTEGRATE_WPECOMMERCE', 'integrate-wp-e-commerce' );
28
 
29
+ define( 'GTM4WP_PLACEMENT_FOOTER', 0 );
30
+ define( 'GTM4WP_PLACEMENT_BODYOPEN', 1 );
31
+
32
  $gtm4wp_options = array();
33
 
34
  $gtm4wp_defaultoptions = array(
35
  GTM4WP_OPTION_GTM_CODE => "",
36
  GTM4WP_OPTION_DATALAYER_NAME => "",
37
+ GTM4WP_OPTION_GTM_PLACEMENT => GTM4WP_PLACEMENT_FOOTER,
38
 
39
  GTM4WP_OPTION_INCLUDE_REMARKETING => false,
40
  GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
52
  GTM4WP_OPTION_EVENTS_DWLEXT => "pdf,doc,docx,xls,xlsx,ppt,pptx,zip,rar,gz,tar",
53
  GTM4WP_OPTION_EVENTS_EMAILCLICKS => false,
54
  GTM4WP_OPTION_EVENTS_FORMMOVE => true,
55
+ GTM4WP_OPTION_EVENTS_FORMMOVE => false,
56
 
57
  GTM4WP_OPTION_INTEGRATE_WPCF7 => true,
58
  GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE => false,
duracelltomi-google-tag-manager-for-wordpress.php CHANGED
@@ -1,18 +1,18 @@
1
  <?php
2
  /*
3
- Plugin Name: DuracellTomi's Google Tag Manager for Wordpress
4
- Version: 0.3
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.3' );
12
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
13
  define( 'GTM4WP_TEXTDOMAIN', 'gtm4wp-lang' );
14
 
15
- $gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
16
  $gtp4wp_plugin_basename = plugin_basename( __FILE__ );
17
  require_once( GTM4WP_PATH."/common/readoptions.php" );
18
 
1
  <?php
2
  /*
3
+ Plugin Name: Google Tag Manager for Wordpress
4
+ Version: 0.4
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.4' );
12
  define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
13
  define( 'GTM4WP_TEXTDOMAIN', 'gtm4wp-lang' );
14
 
15
+ $gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
16
  $gtp4wp_plugin_basename = plugin_basename( __FILE__ );
17
  require_once( GTM4WP_PATH."/common/readoptions.php" );
18
 
integration/woocommerce.php CHANGED
@@ -55,13 +55,13 @@ function gtm4wp_woocommerce_datalayer_filter_order( $dataLayer ) {
55
  "quantity" => $item['qty']
56
  );
57
 
58
- $_sumprice += $item['qty'] * $_prodprice;
59
  $_product_ids[] = "'" . $_product->id . "'";
60
  }
61
  }
62
 
63
  $dataLayer["transactionProducts"] = $_products;
64
- $dataLayer["event"] = "OrderCompleted";
65
 
66
  $dataLayer["ecomm_prodid"] = '[' . implode(", ", $_product_ids) . ']';
67
  $dataLayer["ecomm_pagetype"] = "purchase";
55
  "quantity" => $item['qty']
56
  );
57
 
58
+ $_sumprice += $_prodprice;
59
  $_product_ids[] = "'" . $_product->id . "'";
60
  }
61
  }
62
 
63
  $dataLayer["transactionProducts"] = $_products;
64
+ $dataLayer["event"] = "gtm4wp.orderCompleted";
65
 
66
  $dataLayer["ecomm_prodid"] = '[' . implode(", ", $_product_ids) . ']';
67
  $dataLayer["ecomm_pagetype"] = "purchase";
js/gtm4wp-download-tracker.js CHANGED
@@ -1,4 +1,4 @@
1
- function track_downloads(track_extensions) {
2
  var gtm4wp_extensions_to_track = track_extensions.split(",");
3
 
4
  for ( var i = 0; i < gtm4wp_extensions_to_track.length; i++ ) {
1
+ function gtm4wp_track_downloads(track_extensions) {
2
  var gtm4wp_extensions_to_track = track_extensions.split(",");
3
 
4
  for ( var i = 0; i < gtm4wp_extensions_to_track.length; i++ ) {
js/gtm4wp-social-tracker.js ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function() {
2
+ if ( typeof FB != "undefined" ) {
3
+ FB.Event.subscribe( 'edge.create', function( href, widget ) {
4
+ window[ gtm4wp_datalayer_name ].push({
5
+ 'event': 'gtm4wp.socialAction',
6
+ 'network': 'facebook',
7
+ 'socialAction': 'like',
8
+ 'opt_target': href,
9
+ 'opt_pagePath': window.location.href
10
+ });
11
+ });
12
+
13
+ FB.Event.subscribe( 'edge.remove', function( href, widget ) {
14
+ window[ gtm4wp_datalayer_name ].push({
15
+ 'event': 'gtm4wp.socialAction',
16
+ 'network': 'facebook',
17
+ 'socialAction': 'unlike',
18
+ 'opt_target': href,
19
+ 'opt_pagePath': window.location.href
20
+ });
21
+ });
22
+
23
+ FB.Event.subscribe( 'comment.create', function( href, commentID ) {
24
+ window[ gtm4wp_datalayer_name ].push({
25
+ 'event': 'gtm4wp.socialAction',
26
+ 'network': 'facebook',
27
+ 'socialAction': 'comment',
28
+ 'opt_target': href,
29
+ 'opt_pagePath': window.location.href
30
+ });
31
+ });
32
+
33
+ FB.Event.subscribe( 'comment.remove', function( href, commentID ) {
34
+ window[ gtm4wp_datalayer_name ].push({
35
+ 'event': 'gtm4wp.socialAction',
36
+ 'network': 'facebook',
37
+ 'socialAction': 'uncomment',
38
+ 'opt_target': href,
39
+ 'opt_pagePath': window.location.href
40
+ });
41
+ });
42
+
43
+ FB.Event.subscribe( 'message.send', function( response ) {
44
+ window[ gtm4wp_datalayer_name ].push({
45
+ 'event': 'gtm4wp.socialAction',
46
+ 'network': 'facebook',
47
+ 'socialAction': 'send',
48
+ 'opt_target': response,
49
+ 'opt_pagePath': window.location.href
50
+ });
51
+ });
52
+ } // end of Facebook social events
53
+
54
+ if ( typeof twttr == "undefined" ) {
55
+ window.twttr = (function ( d, s, id ) {
56
+ var t, js, fjs = d.getElementsByTagName(s)[0];
57
+ if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
58
+ js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
59
+ return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
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;
67
+ if ( typeof label == "label" ) {
68
+ label = window.location.href;
69
+ }
70
+
71
+ window[ gtm4wp_datalayer_name ].push({
72
+ 'event': 'gtm4wp.socialAction',
73
+ 'network': 'twitter',
74
+ 'socialAction': 'tweet',
75
+ 'opt_target': label,
76
+ 'opt_pagePath': window.location.href
77
+ });
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
+ });
92
+ }
93
+ });
94
+ });
95
+ });
languages/en.pot CHANGED
@@ -329,3 +329,29 @@ msgstr ""
329
 
330
  msgid "In October 2013 Google released a new feature called <a href=\"https://support.google.com/tagmanager/answer/3415369?hl=en\" target=\"_blank\">auto event tracking</a>. It is up to you how you use click events either using Google's solution or the settings below."
331
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
 
330
  msgid "In October 2013 Google released a new feature called <a href=\"https://support.google.com/tagmanager/answer/3415369?hl=en\" target=\"_blank\">auto event tracking</a>. It is up to you how you use click events either using Google's solution or the settings below."
331
  msgstr ""
332
+
333
+ msgid ""
334
+ "Footer of the page (not recommended by Google, no tweak in your template "
335
+ "required)"
336
+ msgstr ""
337
+
338
+ msgid "Custom (needs tweak in your template)"
339
+ msgstr ""
340
+
341
+ msgid "Container code placement"
342
+ msgstr ""
343
+
344
+ msgid ""
345
+ "Select how your container code should be included in your website.<br />If "
346
+ "you select 'Custom' you need to edit your template file and add the "
347
+ "following line just after the opening &lt;body&gt; tag:<br /><code>&lt;?php "
348
+ "if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?&gt;</code>"
349
+ msgstr ""
350
+
351
+ msgid "Social actions (gtm4wp.socialAction)"
352
+ msgstr ""
353
+
354
+ msgid ""
355
+ "Check this option to include a Tag Manager event when a visitor uses a "
356
+ "social button to share/like content on a social network."
357
+ msgstr ""
languages/gtm4wp-lang-hu_HU.mo CHANGED
Binary file
languages/gtm4wp-lang-hu_HU.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Google Tag Manager for WordPress\n"
4
  "POT-Creation-Date: 2013-09-19 11:27+0100\n"
5
- "PO-Revision-Date: 2013-10-13 12:53+0100\n"
6
  "Last-Translator: Thomas Geiger <duracelltomi@gmail.com>\n"
7
  "Language-Team: JabJab Online Marketing\n"
8
  "Language: English\n"
@@ -407,3 +407,39 @@ msgstr ""
407
  "com/tagmanager/answer/3415369?hl=en\" target=\"_blank\">automatikus esemény "
408
  "követés</a> funkciót. Választhat, melyiket esemény követést használja, a "
409
  "Google megoldását vagy az alábbi beállításokat."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  msgstr ""
3
  "Project-Id-Version: Google Tag Manager for WordPress\n"
4
  "POT-Creation-Date: 2013-09-19 11:27+0100\n"
5
+ "PO-Revision-Date: 2013-11-17 15:56+0100\n"
6
  "Last-Translator: Thomas Geiger <duracelltomi@gmail.com>\n"
7
  "Language-Team: JabJab Online Marketing\n"
8
  "Language: English\n"
407
  "com/tagmanager/answer/3415369?hl=en\" target=\"_blank\">automatikus esemény "
408
  "követés</a> funkciót. Választhat, melyiket esemény követést használja, a "
409
  "Google megoldását vagy az alábbi beállításokat."
410
+
411
+ msgid ""
412
+ "Footer of the page (not recommended by Google, no tweak in your template "
413
+ "required)"
414
+ msgstr ""
415
+ "Az oldal aljában (a Google nem ajánlja, de nem kell bütykölni hozzá az oldal "
416
+ "sablonját)"
417
+
418
+ msgid "Custom (needs tweak in your template)"
419
+ msgstr "Egyéni (módosítani kell az oldal sablonján)"
420
+
421
+ msgid "Container code placement"
422
+ msgstr "Tároló kód helye"
423
+
424
+ msgid ""
425
+ "Select how your container code should be included in your website.<br />If "
426
+ "you select 'Custom' you need to edit your template file and add the "
427
+ "following line just after the opening &lt;body&gt; tag:<br /><code>&lt;?php "
428
+ "if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?"
429
+ "&gt;</code>"
430
+ msgstr ""
431
+ "Válassza ki, hogyan kerüljön be az oldalba a tároló kódja.<br />Ha az "
432
+ "'Egyéni'-t választja, módosítania kell az oldal sablonját, a következő sort "
433
+ "kell elhelyezni rögtön a nyitó &lt;body&gt; elem után:<br /><code>&lt;?php "
434
+ "if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?"
435
+ "&gt;</code>"
436
+
437
+ msgid "Social actions (gtm4wp.socialAction)"
438
+ msgstr "Közösségi műveletek (gtm4wp.socialAction)"
439
+
440
+ msgid ""
441
+ "Check this option to include a Tag Manager event when a visitor uses a "
442
+ "social button to share/like content on a social network."
443
+ msgstr ""
444
+ "Kapcsolja be ezt a beállítást, ha szeretne Tag Manager eseményt kiváltani, "
445
+ "amikor egy látogató egy közösségi gomb segítségével megoszt/lájkol tartalmat."
public/frontend.php CHANGED
@@ -2,6 +2,12 @@
2
  define( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtp4wp_compile_datalayer");
3
  define( GTM4WP_WPFILTER_COMPILE_REMARKTING, "gtp4wp_compile_remarkering");
4
 
 
 
 
 
 
 
5
  function gtm4wp_is_assoc($arr) {
6
  // borrowed from
7
  // http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential
@@ -145,16 +151,10 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
145
  }
146
 
147
  function gtm4wp_get_the_gtm_tag() {
148
- global $gtm4wp_options;
149
 
150
  $_gtm_tag = '';
151
 
152
- if ( $gtm4wp_options[GTM4WP_OPTION_DATALAYER_NAME] == "" ) {
153
- $gtm4wp_datalayer_name = "dataLayer";
154
- } else {
155
- $gtm4wp_datalayer_name = $gtm4wp_options[GTM4WP_OPTION_DATALAYER_NAME];
156
- }
157
-
158
  if ( $gtm4wp_options[GTM4WP_OPTION_GTM_CODE] != "" ) {
159
  $_gtm_tag .= '
160
  <!-- Google Tag Manager for WordPress by DuracellTomi -->
@@ -174,35 +174,34 @@ function gtm4wp_get_the_gtm_tag() {
174
  $gtm4wp_datalayer_data["google_tag_params"] = "-~-window.google_tag_params-~-";
175
  }
176
 
177
- $_gtm_tag .= '
178
- var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";';
179
-
180
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_DOWNLOADS] ) {
181
  $_gtm_tag .= '
182
  jQuery( function() {
183
- track_downloads( "'.str_replace('"', '', $gtm4wp_options[GTM4WP_OPTION_EVENTS_DWLEXT]).'" );
184
  });';
185
  }
186
 
187
  $_gtm_tag .= '
188
- var ' . $gtm4wp_datalayer_name . ' = [' . str_replace(
189
  array( '"-~-', '-~-"' ),
190
  array( "", "" ),
191
  json_encode( $gtm4wp_datalayer_data )
192
- ) . '];
 
 
193
  </script>';
194
 
195
  $_gtm_tag .= '
196
- <noscript><iframe src="//www.googletagmanager.com/ns.html?id='.$gtm4wp_options[GTM4WP_OPTION_GTM_CODE].'"
197
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
198
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
199
  new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
200
- j=d.createElement(s),dl=l!=\''.$gtm4wp_datalayer_name.'\'?\'&l=\'+l:\'\';j.async=true;j.src=
201
  \'//www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f);
202
- })(window,document,\'script\',\''.$gtm4wp_datalayer_name.'\',\''.$gtm4wp_options[GTM4WP_OPTION_GTM_CODE].'\');</script>
203
  <!-- End Google Tag Manager -->';
204
  }
205
-
206
  return $_gtm_tag;
207
  }
208
 
@@ -214,35 +213,69 @@ function gtm4wp_enqueue_scripts() {
214
  global $gtm4wp_options, $gtp4wp_plugin_url;
215
 
216
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_OUTBOUND] ) {
217
- wp_enqueue_script( "gtm4wp-outbound-click-tracker", $gtp4wp_plugin_url . "/js/gtm4wp-outbound-click-tracker.js", array( "jquery-core" ), "1.0", false );
218
  }
219
 
220
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_DOWNLOADS] ) {
221
- wp_enqueue_script( "gtm4wp-download-tracker", $gtp4wp_plugin_url . "/js/gtm4wp-download-tracker.js", array( "jquery-core" ), "1.0", false );
222
  }
223
 
224
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_EMAILCLICKS] ) {
225
- wp_enqueue_script( "gtm4wp-email-link-tracker", $gtp4wp_plugin_url . "/js/gtm4wp-email-link-tracker.js", array( "jquery-core" ), "1.0", false );
226
  }
227
 
228
  if ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WPCF7] ) {
229
- wp_enqueue_script( "gtm4wp-contact-form-7-tracker", $gtp4wp_plugin_url . "/js/gtm4wp-contact-form-7-tracker.js", array( "jquery-core" ), "1.0", false );
230
  }
231
 
232
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_FORMMOVE] ) {
233
- wp_enqueue_script( "gtm4wp-form-move-tracker", $gtp4wp_plugin_url . "/js/gtm4wp-form-move-tracker.js", array( "jquery-core" ), "1.0", false );
 
 
 
 
234
  }
235
 
236
  if ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE] ) {
237
  require_once( dirname( __FILE__ ) . "/../integration/woocommerce.php" );
238
- wp_enqueue_script( "gtm4wp-woocommerce-tracker", $gtp4wp_plugin_url . "/js/gtm4wp-woocommerce-tracker.js", array( "jquery-core" ), "1.0", false );
239
  }
240
  }
241
 
242
  function gtm4wp_wp_footer() {
243
- gtm4wp_the_gtm_tag();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
 
246
  add_action( "wp_enqueue_scripts", "gtm4wp_enqueue_scripts" );
 
247
  add_action( "wp_footer", "gtm4wp_wp_footer" );
248
  add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtm4wp_add_basic_datalayer_data" );
 
 
 
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";
7
+ } else {
8
+ $GLOBALS["gtm4wp_datalayer_name"] = $GLOBALS["gtm4wp_options"][GTM4WP_OPTION_DATALAYER_NAME];
9
+ }
10
+
11
  function gtm4wp_is_assoc($arr) {
12
  // borrowed from
13
  // http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential
151
  }
152
 
153
  function gtm4wp_get_the_gtm_tag() {
154
+ global $gtm4wp_options, $gtm4wp_datalayer_name;
155
 
156
  $_gtm_tag = '';
157
 
 
 
 
 
 
 
158
  if ( $gtm4wp_options[GTM4WP_OPTION_GTM_CODE] != "" ) {
159
  $_gtm_tag .= '
160
  <!-- Google Tag Manager for WordPress by DuracellTomi -->
174
  $gtm4wp_datalayer_data["google_tag_params"] = "-~-window.google_tag_params-~-";
175
  }
176
 
 
 
 
177
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_DOWNLOADS] ) {
178
  $_gtm_tag .= '
179
  jQuery( function() {
180
+ gtm4wp_track_downloads( "' . str_replace( '"', '', $gtm4wp_options[ GTM4WP_OPTION_EVENTS_DWLEXT ] ) . '" );
181
  });';
182
  }
183
 
184
  $_gtm_tag .= '
185
+ ' . $gtm4wp_datalayer_name . '.push(' . str_replace(
186
  array( '"-~-', '-~-"' ),
187
  array( "", "" ),
188
  json_encode( $gtm4wp_datalayer_data )
189
+ ) . ');';
190
+
191
+ $_gtm_tag .= '
192
  </script>';
193
 
194
  $_gtm_tag .= '
195
+ <noscript><iframe src="//www.googletagmanager.com/ns.html?id=' . $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] . '"
196
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
197
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
198
  new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
199
+ j=d.createElement(s),dl=l!=\'' . $gtm4wp_datalayer_name . '\'?\'&l=\'+l:\'\';j.async=true;j.src=
200
  \'//www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f);
201
+ })(window,document,\'script\',\'' . $gtm4wp_datalayer_name . '\',\'' . $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] . '\');</script>
202
  <!-- End Google Tag Manager -->';
203
  }
204
+
205
  return $_gtm_tag;
206
  }
207
 
213
  global $gtm4wp_options, $gtp4wp_plugin_url;
214
 
215
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_OUTBOUND] ) {
216
+ wp_enqueue_script( "gtm4wp-outbound-click-tracker", $gtp4wp_plugin_url . "js/gtm4wp-outbound-click-tracker.js", array( "jquery" ), "1.0", false );
217
  }
218
 
219
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_DOWNLOADS] ) {
220
+ wp_enqueue_script( "gtm4wp-download-tracker", $gtp4wp_plugin_url . "js/gtm4wp-download-tracker.js", array( "jquery" ), "1.0", false );
221
  }
222
 
223
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_EMAILCLICKS] ) {
224
+ wp_enqueue_script( "gtm4wp-email-link-tracker", $gtp4wp_plugin_url . "js/gtm4wp-email-link-tracker.js", array( "jquery" ), "1.0", false );
225
  }
226
 
227
  if ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WPCF7] ) {
228
+ wp_enqueue_script( "gtm4wp-contact-form-7-tracker", $gtp4wp_plugin_url . "js/gtm4wp-contact-form-7-tracker.js", array( "jquery" ), "1.0", false );
229
  }
230
 
231
  if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_FORMMOVE] ) {
232
+ wp_enqueue_script( "gtm4wp-form-move-tracker", $gtp4wp_plugin_url . "js/gtm4wp-form-move-tracker.js", array( "jquery" ), "1.0", false );
233
+ }
234
+
235
+ if ( $gtm4wp_options[GTM4WP_OPTION_EVENTS_SOCIAL] ) {
236
+ wp_enqueue_script( "gtm4wp-social-actions", $gtp4wp_plugin_url . "js/gtm4wp-social-tracker.js", array( "jquery" ), "1.0", false );
237
  }
238
 
239
  if ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE] ) {
240
  require_once( dirname( __FILE__ ) . "/../integration/woocommerce.php" );
241
+ wp_enqueue_script( "gtm4wp-woocommerce-tracker", $gtp4wp_plugin_url . "js/gtm4wp-woocommerce-tracker.js", array( "jquery" ), "1.0", false );
242
  }
243
  }
244
 
245
  function gtm4wp_wp_footer() {
246
+ global $gtm4wp_options;
247
+
248
+ if ( $gtm4wp_options[GTM4WP_OPTION_GTM_PLACEMENT] == GTM4WP_PLACEMENT_FOOTER ) {
249
+ gtm4wp_the_gtm_tag();
250
+ }
251
+ }
252
+
253
+ function gtm4wp_wp_body_open() {
254
+ global $gtm4wp_options;
255
+
256
+ if ( $gtm4wp_options[GTM4WP_OPTION_GTM_PLACEMENT] == GTM4WP_PLACEMENT_CUSTOM ) {
257
+ gtm4wp_the_gtm_tag();
258
+ }
259
+ }
260
+
261
+ function gtm4wp_wp_header() {
262
+ global $gtm4wp_datalayer_name;
263
+
264
+ $_gtm_header_content = '
265
+ <!-- Google Tag Manager for WordPress by DuracellTomi -->
266
+ <script type="text/javascript">
267
+ var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
268
+ ' . $gtm4wp_datalayer_name . ' = new Array();
269
+ </script>
270
+ <!-- End Google Tag Manager -->';
271
+
272
+ echo $_gtm_header_content;
273
  }
274
 
275
  add_action( "wp_enqueue_scripts", "gtm4wp_enqueue_scripts" );
276
+ add_action( "wp_head", "gtm4wp_wp_header", 1 );
277
  add_action( "wp_footer", "gtm4wp_wp_footer" );
278
  add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtm4wp_add_basic_datalayer_data" );
279
+
280
+ // to be able to easily migrate from other Google Tag Manager plugins
281
+ add_action( "body_open", "gtm4wp_wp_body_open" );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://duracelltomi.com/
4
  Tags: google tag manager, tag manager, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics
5
  Requires at least: 3.0.1
6
  Tested up to: 3.7.1
7
- Stable tag: 0.3
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -30,6 +30,7 @@ very easily since you can fire them using rules that include
30
  * post types
31
  * logged in status
32
  * logged in user role
 
33
 
34
  = Tag Manager Events =
35
 
@@ -39,6 +40,7 @@ This plugin can fire several Tag Manager events so that you can include special
39
  * the visitor clicks on a download link
40
  * the visitor clicks on an email link
41
  * the visitor moves between elements of a form (comment, contact, etc.)
 
42
 
43
  Link URLs are included in the Tag Manager event so that you can use them for example in a Google Analytics event tag.
44
 
@@ -73,12 +75,45 @@ Google Tag Manager is not just about visitor tracking.
73
  The ability to include a Google/Universal Analytics tag is only one feature
74
  you can manage.
75
 
76
- Therefor there is no need to have an option to exclude the container code snippet
77
  on certain cases.
78
 
79
  If you want to exclude logged in users or certain user roles, use the corresponting dataLayer variable (visitorType)
80
  and an exclude filter in Google Tag Manager.
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  == Screenshots ==
83
 
84
  1. Admin panel
@@ -89,6 +124,12 @@ and an exclude filter in Google Tag Manager.
89
 
90
  == Changelog ==
91
 
 
 
 
 
 
 
92
  = 0.3 =
93
  * Updated: admin page does not show an alert box if Tag Manager ID or dataLayer variable name is incorrect. Instead it shows a warning line below the input field.
94
  * Updated: rewritten the code for WooCommerce dynamic remarketing. Added tag for homepage and order completed page.
@@ -113,6 +154,10 @@ and an exclude filter in Google Tag Manager.
113
 
114
  == Upgrade Notice ==
115
 
 
 
 
 
116
  = 0.3 =
117
  This is a minor release. If you are using WooCommerce you should update to include more accurate adwords dynamic remarketing feature.
118
 
4
  Tags: google tag manager, tag manager, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics
5
  Requires at least: 3.0.1
6
  Tested up to: 3.7.1
7
+ Stable tag: 0.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
30
  * post types
31
  * logged in status
32
  * logged in user role
33
+ * search data
34
 
35
  = Tag Manager Events =
36
 
40
  * the visitor clicks on a download link
41
  * the visitor clicks on an email link
42
  * the visitor moves between elements of a form (comment, contact, etc.)
43
+ * the visitor clicks on a Facebook like/share (limited feature) or Twitter button
44
 
45
  Link URLs are included in the Tag Manager event so that you can use them for example in a Google Analytics event tag.
46
 
75
  The ability to include a Google/Universal Analytics tag is only one feature
76
  you can manage.
77
 
78
+ Therefore there is no need to have an option to exclude the container code snippet
79
  on certain cases.
80
 
81
  If you want to exclude logged in users or certain user roles, use the corresponting dataLayer variable (visitorType)
82
  and an exclude filter in Google Tag Manager.
83
 
84
+ = How do I put the Google Tag Manager container code next to the opening body tag? =
85
+
86
+ Go to the admin section of the plugin and select "Custom" from the placement settings.
87
+ This way my plugin does not put the code snippet into the footer of the page.
88
+
89
+ In this case you have to edit your template files.
90
+ Go to `wp-content/plugins/themes/<your theme dir>` and edit `header.php`.
91
+ In most cases you will find the opening `<body>` tag here.
92
+
93
+ If you can not find it, contact the author of the theme and ask for instructions.
94
+
95
+ In case you found the opening `<body>` tag, open a new line just after it and insert this line of code:
96
+ `<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>`
97
+
98
+ Be carefull not to include this line inside any `<div>`, `<p>`, `<header>`, `<article>` and so on.
99
+ It can break you theme.
100
+
101
+ = Why can not this plugin insert the container snippet after the opening body tag automatically? =
102
+
103
+ Currently WordPress has two 'commands' or 'hooks' that a programmer can use: one for the `<head>` section and
104
+ one for the bottom of `<body>`. There is no way to inject any content after the opening body tag.
105
+
106
+ Fortunately some theme authors already resolved this so in some cases you do not need to edit your template files.
107
+ I suggest first to select the Custom placement and use Google Tag Assistant Chrome browser extension to check
108
+ whether the container code is placed as expected.
109
+
110
+ If it shows an error, go and edit your theme manually.
111
+
112
+ = Facebook like/share/send button events do not fire for me, why? =
113
+
114
+ It is a limitation of Facebook. Click event tracking is only available for html5/xfbml buttons.
115
+ If you or your social plugin inserts the Facebook buttons using IFRAME-s (like Sociable), it is not possible to track clicks.
116
+
117
  == Screenshots ==
118
 
119
  1. Admin panel
124
 
125
  == Changelog ==
126
 
127
+ = 0.4 =
128
+ * New: you can now select container code placement. This way you can insert the code snippet after the opening body tag. Please read FAQ for details
129
+ * New: initial support for social event tracking for Facebook and Twitter buttons. Please read FAQ for details
130
+ * Updated: event name on successful WooCommerce transacion: OrderCompleted -> gtm4wp.orderCompleted
131
+ * Fixed: frontend JS codes did not load on some WordPress installs
132
+
133
  = 0.3 =
134
  * Updated: admin page does not show an alert box if Tag Manager ID or dataLayer variable name is incorrect. Instead it shows a warning line below the input field.
135
  * Updated: rewritten the code for WooCommerce dynamic remarketing. Added tag for homepage and order completed page.
154
 
155
  == Upgrade Notice ==
156
 
157
+ = 0.4 =
158
+ Important change: Tag Manager event name of a WooCommerce successful order has been changed.
159
+ See changelog for details.
160
+
161
  = 0.3 =
162
  This is a minor release. If you are using WooCommerce you should update to include more accurate adwords dynamic remarketing feature.
163