Version Description
- Updated: better add-to-cart events for WooCommerce, it includes now product name, SKU and ID
- Added: browser, OS and device data to dataLayer variables
- Added: postCountOnPage and postCountTotal dataLayer variables to track empty categories/tags/taxonomies
Download this release
Release Info
Developer | duracelltomi |
Plugin | DuracellTomi's Google Tag Manager for WordPress |
Version | 0.6 |
Comparing to | |
See all releases |
Code changes from version 0.5.1 to 0.6
- admin/admin.php +18 -0
- common/readoptions.php +8 -0
- duracelltomi-google-tag-manager-for-wordpress.php +2 -2
- integration/woocommerce.php +36 -0
- languages/en.pot +37 -0
- languages/gtm4wp-lang-hu_HU.mo +0 -0
- languages/gtm4wp-lang-hu_HU.po +49 -1
- public/frontend.php +46 -3
- readme.txt +34 -2
admin/admin.php
CHANGED
@@ -52,9 +52,25 @@ $GLOBALS["gtm4wp_includefieldtexts"] = array(
|
|
52 |
"label" => __( "Post title", GTM4WP_TEXTDOMAIN ),
|
53 |
"description" => __( "Check this option to include the title of the current post.", GTM4WP_TEXTDOMAIN )
|
54 |
),
|
|
|
|
|
|
|
|
|
55 |
GTM4WP_OPTION_INCLUDE_SEARCHDATA => array(
|
56 |
"label" => __( "Search data", GTM4WP_TEXTDOMAIN ),
|
57 |
"description" => __( "Check this option to include the search term, referring page URL and number of results on the search page.", GTM4WP_TEXTDOMAIN )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
)
|
59 |
);
|
60 |
|
@@ -137,6 +153,8 @@ function gtm4wp_admin_output_section( $args ) {
|
|
137 |
|
138 |
case GTM4WP_ADMIN_GROUP_INCLUDES: {
|
139 |
_e( "Here you can check what data is needed to be included in the dataLayer to be able to access them in Google Tag Manager", GTM4WP_TEXTDOMAIN );
|
|
|
|
|
140 |
|
141 |
break;
|
142 |
}
|
52 |
"label" => __( "Post title", GTM4WP_TEXTDOMAIN ),
|
53 |
"description" => __( "Check this option to include the title of the current post.", GTM4WP_TEXTDOMAIN )
|
54 |
),
|
55 |
+
GTM4WP_OPTION_INCLUDE_POSTCOUNT => array(
|
56 |
+
"label" => __( "Post count", GTM4WP_TEXTDOMAIN ),
|
57 |
+
"description" => __( "Check this option to include the count of the posts currently shown on the page and the total number of posts in the category/tag/any taxonomy.", GTM4WP_TEXTDOMAIN )
|
58 |
+
),
|
59 |
GTM4WP_OPTION_INCLUDE_SEARCHDATA => array(
|
60 |
"label" => __( "Search data", GTM4WP_TEXTDOMAIN ),
|
61 |
"description" => __( "Check this option to include the search term, referring page URL and number of results on the search page.", GTM4WP_TEXTDOMAIN )
|
62 |
+
),
|
63 |
+
GTM4WP_OPTION_INCLUDE_BROWSERDATA => array(
|
64 |
+
"label" => __( "Browser data *", GTM4WP_TEXTDOMAIN ),
|
65 |
+
"description" => __( "Check this option to include the name, version and engine data of the browser the visitor uses.", GTM4WP_TEXTDOMAIN )
|
66 |
+
),
|
67 |
+
GTM4WP_OPTION_INCLUDE_OSDATA => array(
|
68 |
+
"label" => __( "OS data *", GTM4WP_TEXTDOMAIN ),
|
69 |
+
"description" => __( "Check this option to include the name and version of the operating system the visitor uses.", GTM4WP_TEXTDOMAIN )
|
70 |
+
),
|
71 |
+
GTM4WP_OPTION_INCLUDE_DEVICEDATA => array(
|
72 |
+
"label" => __( "Device data *", GTM4WP_TEXTDOMAIN ),
|
73 |
+
"description" => __( "Check this option to include the type of device the user is currently using (desktop, tablet or mobile) including manufacturer and model data.", GTM4WP_TEXTDOMAIN )
|
74 |
)
|
75 |
);
|
76 |
|
153 |
|
154 |
case GTM4WP_ADMIN_GROUP_INCLUDES: {
|
155 |
_e( "Here you can check what data is needed to be included in the dataLayer to be able to access them in Google Tag Manager", GTM4WP_TEXTDOMAIN );
|
156 |
+
echo "<br />";
|
157 |
+
printf( __( '* Browser, OS and Device data is provided using <a href="%s">WhichBrowser</a> library.', GTM4WP_TEXTDOMAIN ), "http://whichbrowser.net/" );
|
158 |
|
159 |
break;
|
160 |
}
|
common/readoptions.php
CHANGED
@@ -13,7 +13,11 @@ define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
|
|
13 |
define( 'GTM4WP_OPTION_INCLUDE_AUTHOR', 'include-author' );
|
14 |
define( 'GTM4WP_OPTION_INCLUDE_POSTDATE', 'include-postdate' );
|
15 |
define( 'GTM4WP_OPTION_INCLUDE_POSTTITLE', 'include-posttitle' );
|
|
|
16 |
define( 'GTM4WP_OPTION_INCLUDE_SEARCHDATA', 'include-searchdata' );
|
|
|
|
|
|
|
17 |
|
18 |
define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
|
19 |
define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
|
@@ -52,7 +56,11 @@ $gtm4wp_defaultoptions = array(
|
|
52 |
GTM4WP_OPTION_INCLUDE_AUTHOR => true,
|
53 |
GTM4WP_OPTION_INCLUDE_POSTDATE => false,
|
54 |
GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
|
|
|
55 |
GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
|
|
|
|
|
|
|
56 |
|
57 |
GTM4WP_OPTION_EVENTS_OUTBOUND => false,
|
58 |
GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
|
13 |
define( 'GTM4WP_OPTION_INCLUDE_AUTHOR', 'include-author' );
|
14 |
define( 'GTM4WP_OPTION_INCLUDE_POSTDATE', 'include-postdate' );
|
15 |
define( 'GTM4WP_OPTION_INCLUDE_POSTTITLE', 'include-posttitle' );
|
16 |
+
define( 'GTM4WP_OPTION_INCLUDE_POSTCOUNT', 'include-postcount' );
|
17 |
define( 'GTM4WP_OPTION_INCLUDE_SEARCHDATA', 'include-searchdata' );
|
18 |
+
define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
|
19 |
+
define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
|
20 |
+
define( 'GTM4WP_OPTION_INCLUDE_DEVICEDATA', 'include-devicedata' );
|
21 |
|
22 |
define( 'GTM4WP_OPTION_EVENTS_OUTBOUND', 'event-outbound' );
|
23 |
define( 'GTM4WP_OPTION_EVENTS_DOWNLOADS', 'event-downloads' );
|
56 |
GTM4WP_OPTION_INCLUDE_AUTHOR => true,
|
57 |
GTM4WP_OPTION_INCLUDE_POSTDATE => false,
|
58 |
GTM4WP_OPTION_INCLUDE_POSTTITLE => false,
|
59 |
+
GTM4WP_OPTION_INCLUDE_POSTCOUNT => false,
|
60 |
GTM4WP_OPTION_INCLUDE_SEARCHDATA => false,
|
61 |
+
GTM4WP_OPTION_INCLUDE_BROWSERDATA => false,
|
62 |
+
GTM4WP_OPTION_INCLUDE_OSDATA => false,
|
63 |
+
GTM4WP_OPTION_INCLUDE_DEVICEDATA => false,
|
64 |
|
65 |
GTM4WP_OPTION_EVENTS_OUTBOUND => false,
|
66 |
GTM4WP_OPTION_EVENTS_DOWNLOADS => false,
|
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.
|
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.
|
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.6
|
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.6' );
|
12 |
define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
|
13 |
define( 'GTM4WP_TEXTDOMAIN', 'gtm4wp-lang' );
|
14 |
|
integration/woocommerce.php
CHANGED
@@ -119,7 +119,43 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
119 |
return $dataLayer;
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
// do not add filter if someone enabled WooCommerce integration without an activated WooCommerce plugin
|
123 |
if ( isset ( $GLOBALS["woocommerce"] ) ) {
|
124 |
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtm4wp_woocommerce_datalayer_filter_items" );
|
|
|
|
|
125 |
}
|
119 |
return $dataLayer;
|
120 |
}
|
121 |
|
122 |
+
function gtm4wp_woocommerce_single_add_to_cart_tracking() {
|
123 |
+
if ( ! is_single() ) {
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
|
127 |
+
global $product, $woocommerce, $gtm4wp_datalayer_name;
|
128 |
+
|
129 |
+
$woocommerce->add_inline_js("
|
130 |
+
$('.single_add_to_cart_button').click(function() {
|
131 |
+
". $gtm4wp_datalayer_name .".push({
|
132 |
+
'event': 'gtm4wp.addProductToCart',
|
133 |
+
'productName': '". esc_js( $product->post->post_title ) ."',
|
134 |
+
'productSKU': '". esc_js( $product->get_sku() ) ."',
|
135 |
+
'productID': '". esc_js( $product->id ) ."'
|
136 |
+
});
|
137 |
+
});
|
138 |
+
");
|
139 |
+
}
|
140 |
+
|
141 |
+
function gtm4wp_woocommerce_loop_add_to_cart_tracking() {
|
142 |
+
global $woocommerce, $gtm4wp_datalayer_name;
|
143 |
+
|
144 |
+
$woocommerce->add_inline_js("
|
145 |
+
$('.add_to_cart_button:not(.product_type_variable, .product_type_grouped)').click(function() {
|
146 |
+
". $gtm4wp_datalayer_name .".push({
|
147 |
+
'event': 'gtm4wp.addProductToCart',
|
148 |
+
'productName': $( this ).parent().find('h3').text(),
|
149 |
+
'productSKU': $( this ).data( 'product_sku' ),
|
150 |
+
'productID': $( this ).data( 'product_id' ),
|
151 |
+
});
|
152 |
+
});
|
153 |
+
");
|
154 |
+
}
|
155 |
+
|
156 |
// do not add filter if someone enabled WooCommerce integration without an activated WooCommerce plugin
|
157 |
if ( isset ( $GLOBALS["woocommerce"] ) ) {
|
158 |
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "gtm4wp_woocommerce_datalayer_filter_items" );
|
159 |
+
add_action( 'woocommerce_after_add_to_cart_button', "gtm4wp_woocommerce_single_add_to_cart_tracking" );
|
160 |
+
add_action( 'wp_footer', "gtm4wp_woocommerce_loop_add_to_cart_tracking" );
|
161 |
}
|
languages/en.pot
CHANGED
@@ -407,3 +407,40 @@ msgstr ""
|
|
407 |
|
408 |
msgid "Scroll tracking"
|
409 |
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
msgid "Scroll tracking"
|
409 |
msgstr ""
|
410 |
+
|
411 |
+
msgid "Browser data *"
|
412 |
+
msgstr ""
|
413 |
+
|
414 |
+
msgid ""
|
415 |
+
"Check this option to include the name, version and engine data of the "
|
416 |
+
"browser the visitor uses."
|
417 |
+
msgstr ""
|
418 |
+
|
419 |
+
msgid "OS data *"
|
420 |
+
msgstr ""
|
421 |
+
|
422 |
+
msgid ""
|
423 |
+
"Check this option to include the name and version of the operating system "
|
424 |
+
"the visitor uses."
|
425 |
+
msgstr ""
|
426 |
+
|
427 |
+
msgid "Device data *"
|
428 |
+
msgstr ""
|
429 |
+
|
430 |
+
msgid ""
|
431 |
+
"Check this option to include the type of device the user is currently using "
|
432 |
+
"(desktop, tablet or mobile) including manufacturer and model data."
|
433 |
+
msgstr ""
|
434 |
+
|
435 |
+
msgid ""
|
436 |
+
"* Browser, OS and Device data is provided using <a href=\"%s\">WhichBrowser</"
|
437 |
+
"a> library."
|
438 |
+
msgstr ""
|
439 |
+
|
440 |
+
msgid "Post count"
|
441 |
+
msgstr ""
|
442 |
+
|
443 |
+
msgid ""
|
444 |
+
"Check this option to include the count of the posts currently shown on the "
|
445 |
+
"page and the total number of posts in the category/tag/any taxonomy."
|
446 |
+
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:
|
6 |
"Last-Translator: Thomas Geiger <duracelltomi@gmail.com>\n"
|
7 |
"Language-Team: JabJab Online Marketing\n"
|
8 |
"Language: English\n"
|
@@ -507,3 +507,51 @@ msgstr "Az <a href=\"%s\">Analytics Talk</a> scriptje alapján."
|
|
507 |
|
508 |
msgid "Scroll tracking"
|
509 |
msgstr "Görgetés figyelés"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 2014-01-11 13:11+0100\n"
|
6 |
"Last-Translator: Thomas Geiger <duracelltomi@gmail.com>\n"
|
7 |
"Language-Team: JabJab Online Marketing\n"
|
8 |
"Language: English\n"
|
507 |
|
508 |
msgid "Scroll tracking"
|
509 |
msgstr "Görgetés figyelés"
|
510 |
+
|
511 |
+
msgid "Browser data *"
|
512 |
+
msgstr "Böngésző adatok *"
|
513 |
+
|
514 |
+
msgid ""
|
515 |
+
"Check this option to include the name, version and engine data of the "
|
516 |
+
"browser the visitor uses."
|
517 |
+
msgstr ""
|
518 |
+
"Kapcsolja be ezt a beállítást, ha szeretné látni a látogató által használt "
|
519 |
+
"böngésző nevét, verzióját, a megjelenítő motor adatait."
|
520 |
+
|
521 |
+
msgid "OS data *"
|
522 |
+
msgstr "Operációs rendszer adatok *"
|
523 |
+
|
524 |
+
msgid ""
|
525 |
+
"Check this option to include the name and version of the operating system "
|
526 |
+
"the visitor uses."
|
527 |
+
msgstr ""
|
528 |
+
"Kapcsolja be ezt a beállítást, ha szeretné látni a látogató által használt "
|
529 |
+
"operációs rendszer nevét és verzióját."
|
530 |
+
|
531 |
+
msgid "Device data *"
|
532 |
+
msgstr "Eszköz adatok *"
|
533 |
+
|
534 |
+
msgid ""
|
535 |
+
"Check this option to include the type of device the user is currently using "
|
536 |
+
"(desktop, tablet or mobile) including manufacturer and model data."
|
537 |
+
msgstr ""
|
538 |
+
"Kapcsolja be ezt a beállítást, ha szeretné látni a látogató által használt "
|
539 |
+
"eszközt (dekstop, tablet vagy moblie), a gyártó és model nevét."
|
540 |
+
|
541 |
+
msgid ""
|
542 |
+
"* Browser, OS and Device data is provided using <a href=\"%s\">WhichBrowser</"
|
543 |
+
"a> library."
|
544 |
+
msgstr ""
|
545 |
+
"A böngésző, operációs rendszer és eszköz adatokat a <a href=\"%s"
|
546 |
+
"\">WhichBrowser</a> eszköz szolgáltatja."
|
547 |
+
|
548 |
+
msgid "Post count"
|
549 |
+
msgstr "Bejegyzések száma"
|
550 |
+
|
551 |
+
msgid ""
|
552 |
+
"Check this option to include the count of the posts currently shown on the "
|
553 |
+
"page and the total number of posts in the category/tag/any taxonomy."
|
554 |
+
msgstr ""
|
555 |
+
"Kapcsolja be ezt a beállítást, ha szeretné látni a bejegyzések számát az "
|
556 |
+
"aktuális oldalon és az összes bejegyzés számát az aktuális kategóriában/"
|
557 |
+
"címkénél/taxanómián."
|
public/frontend.php
CHANGED
@@ -14,6 +14,19 @@ function gtm4wp_is_assoc($arr) {
|
|
14 |
return array_keys($arr) !== range(0, count($arr) - 1);
|
15 |
}
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
18 |
global $current_user, $wp_query, $gtm4wp_options;
|
19 |
|
@@ -139,14 +152,44 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
139 |
$dataLayer["siteSearchResults"] = $wp_query->post_count;
|
140 |
}
|
141 |
|
142 |
-
if ( is_front_page() && $gtm4wp_options[GTM4WP_OPTION_INCLUDE_POSTTYPE] ) {
|
143 |
$dataLayer["pagePostType"] = "frontpage";
|
144 |
}
|
145 |
|
146 |
-
if ( !is_front_page() && is_home() && $gtm4wp_options[GTM4WP_OPTION_INCLUDE_POSTTYPE] ) {
|
147 |
$dataLayer["pagePostType"] = "bloghome";
|
148 |
}
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
return $dataLayer;
|
151 |
}
|
152 |
|
@@ -238,7 +281,7 @@ function gtm4wp_enqueue_scripts() {
|
|
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 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
14 |
return array_keys($arr) !== range(0, count($arr) - 1);
|
15 |
}
|
16 |
|
17 |
+
if ( !function_exists( "getallheaders") ) {
|
18 |
+
function getallheaders() {
|
19 |
+
$headers = "";
|
20 |
+
foreach ( $_SERVER as $name => $value ) {
|
21 |
+
if ( substr($name, 0, 5) == "HTTP_" ) {
|
22 |
+
$headers[ str_replace(' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
return $headers;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
31 |
global $current_user, $wp_query, $gtm4wp_options;
|
32 |
|
152 |
$dataLayer["siteSearchResults"] = $wp_query->post_count;
|
153 |
}
|
154 |
|
155 |
+
if ( is_front_page() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
156 |
$dataLayer["pagePostType"] = "frontpage";
|
157 |
}
|
158 |
|
159 |
+
if ( !is_front_page() && is_home() && $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTYPE ] ) {
|
160 |
$dataLayer["pagePostType"] = "bloghome";
|
161 |
}
|
162 |
|
163 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
164 |
+
require_once( dirname( __FILE__ ) . "/../js/whichbrowser/libraries/whichbrowser.php" );
|
165 |
+
|
166 |
+
$detected = new WhichBrowser( array( "headers" => getallheaders() ) );
|
167 |
+
|
168 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_BROWSERDATA ] ) {
|
169 |
+
$dataLayer["browserName"] = $detected->browser->name;
|
170 |
+
$dataLayer["browserVersion"] = $detected->browser->version->value;
|
171 |
+
|
172 |
+
$dataLayer["browserEngineName"] = $detected->engine->name;
|
173 |
+
$dataLayer["browserEngineVersion"] = $detected->engine->version->value;
|
174 |
+
}
|
175 |
+
|
176 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_OSDATA ] ) {
|
177 |
+
$dataLayer["osName"] = $detected->os->name;
|
178 |
+
$dataLayer["osVersion"] = $detected->os->version->value;
|
179 |
+
}
|
180 |
+
|
181 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_DEVICEDATA ] ) {
|
182 |
+
$dataLayer["deviceType"] = $detected->device->type;
|
183 |
+
$dataLayer["deviceManufacturer"] = $detected->device->manufacturer;
|
184 |
+
$dataLayer["deviceModel"] = $detected->device->model;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTCOUNT ] ) {
|
189 |
+
$dataLayer["postCountOnPage"] = (int) $wp_query->post_count;
|
190 |
+
$dataLayer["postCountTotal"] = (int) $wp_query->found_posts;
|
191 |
+
}
|
192 |
+
|
193 |
return $dataLayer;
|
194 |
}
|
195 |
|
281 |
|
282 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WOOCOMMERCE ] ) {
|
283 |
require_once( dirname( __FILE__ ) . "/../integration/woocommerce.php" );
|
284 |
+
// wp_enqueue_script( "gtm4wp-woocommerce-tracker", $gtp4wp_plugin_url . "js/gtm4wp-woocommerce-tracker.js", array( "jquery" ), "1.0", false );
|
285 |
}
|
286 |
|
287 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
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.8
|
7 |
-
Stable tag: 0.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
@@ -28,9 +28,21 @@ very easily since you can fire them using rules that include
|
|
28 |
* post/page tag names
|
29 |
* post/page author names
|
30 |
* post types
|
|
|
31 |
* logged in status
|
32 |
* logged in user role
|
33 |
* search data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
= Tag Manager Events =
|
36 |
|
@@ -87,6 +99,16 @@ More integration to come!
|
|
87 |
|
88 |
== Frequently Asked Questions ==
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
= How can I track scroll events in Google Tag Manager? =
|
91 |
|
92 |
To track scrolling of your visitor you need to setup some tag in Google Tag Manager.
|
@@ -158,6 +180,12 @@ If you or your social plugin inserts the Facebook buttons using IFRAME-s (like S
|
|
158 |
|
159 |
== Changelog ==
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
= 0.5.1 =
|
162 |
|
163 |
* Fixed: WooCommerce integration did not work on some environments
|
@@ -199,9 +227,13 @@ If you or your social plugin inserts the Facebook buttons using IFRAME-s (like S
|
|
199 |
|
200 |
== Upgrade Notice ==
|
201 |
|
|
|
|
|
|
|
|
|
202 |
= 0.5.1 =
|
203 |
|
204 |
-
Bug fix release for WooCommerce users
|
205 |
|
206 |
= 0.5 =
|
207 |
Besides of some fixes this version includes scroll tracking events for Google Tag Manager.
|
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.8
|
7 |
+
Stable tag: 0.6
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
28 |
* post/page tag names
|
29 |
* post/page author names
|
30 |
* post types
|
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 |
+
* browser data (name, version, engine) (!)
|
36 |
+
* OS data (name, version) (!)
|
37 |
+
* device data (type, manufacturer, model) (!)
|
38 |
+
|
39 |
+
(!) Data is provided using the WhichBrowser library: http://whichbrowser.net/
|
40 |
+
|
41 |
+
Use search data to generate Analytics events when an empty search result is being shown.
|
42 |
+
This is useful to see what people are searching for that is not available on your site (for example a product).
|
43 |
+
|
44 |
+
Use post count to generate Analytics events when an empty result is being shown.
|
45 |
+
This can be useful to catch empty (product) categories.
|
46 |
|
47 |
= Tag Manager Events =
|
48 |
|
99 |
|
100 |
== Frequently Asked Questions ==
|
101 |
|
102 |
+
= How can I track add-to-cart events in WooCommerce =
|
103 |
+
|
104 |
+
To track add-to-cart events you have to catch the dataLayer event gtm4wp.addToCart
|
105 |
+
|
106 |
+
There are 3 additional dataLayer variables that can be accessed during the event:
|
107 |
+
|
108 |
+
* productName: the name of the product where the cart button has been pressed
|
109 |
+
* productSKU: the SKU you entered in your product settings
|
110 |
+
* productID: the ID of the WordPress post that holds your product data
|
111 |
+
|
112 |
= How can I track scroll events in Google Tag Manager? =
|
113 |
|
114 |
To track scrolling of your visitor you need to setup some tag in Google Tag Manager.
|
180 |
|
181 |
== Changelog ==
|
182 |
|
183 |
+
= 0.6 =
|
184 |
+
|
185 |
+
* Updated: better add-to-cart events for WooCommerce, it includes now product name, SKU and ID
|
186 |
+
* Added: browser, OS and device data to dataLayer variables
|
187 |
+
* Added: postCountOnPage and postCountTotal dataLayer variables to track empty categories/tags/taxonomies
|
188 |
+
|
189 |
= 0.5.1 =
|
190 |
|
191 |
* Fixed: WooCommerce integration did not work on some environments
|
227 |
|
228 |
== Upgrade Notice ==
|
229 |
|
230 |
+
= 0.6 =
|
231 |
+
|
232 |
+
Improved add-to-cart events for WooCommerce, added browser/OS/device infos and post count infos.
|
233 |
+
|
234 |
= 0.5.1 =
|
235 |
|
236 |
+
Bug fix release for WooCommerce users.
|
237 |
|
238 |
= 0.5 =
|
239 |
Besides of some fixes this version includes scroll tracking events for Google Tag Manager.
|