Version Description
- Added: new visitorIP data layer variable to support post-GDPR implementations where for example internal traffic exclusion has to be made inside the browser
- Fixed: JavaScript error around the variable gtm4wp_use_sku_instead
- Fixed: added _ as a valid character for gtm_auth GTM environment variable
- Fixed: corrected typo - gtm4wp.checkoutStepE*E*C
- Fixed: two strings were not recognized by WordPress Translate on the admin page
- Fixed: some other plugins call found_variation event of WooCommerce without product variation data being included
- Fixed: product name included variation name on order received page which broke GA product reports
- Fixed: in some cases, no contact form 7 data was being passed to the gtm4wp.contactForm7Submitted event
- Updated: added CDATA markup around container code for better DOM compatibility
- Updated: removed 'SKU:' prefix text from classic ecommerce dimension as it broke some enhanced ecommerce reports
Download this release
Release Info
Developer | duracelltomi |
Plugin | DuracellTomi's Google Tag Manager for WordPress |
Version | 1.8.1 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.8.1
- admin/admin.php +10 -5
- common/readoptions.php +2 -0
- duracelltomi-google-tag-manager-for-wordpress.php +3 -3
- integration/woocommerce.php +17 -11
- js/admin-subtabs.js +1 -1
- js/gtm4wp-contact-form-7-tracker.js +4 -0
- js/gtm4wp-woocommerce-enhanced.js +5 -0
- public/frontend.php +36 -11
- readme.txt +19 -2
admin/admin.php
CHANGED
@@ -118,6 +118,11 @@ $GLOBALS["gtm4wp_includefieldtexts"] = array(
|
|
118 |
"description" => __( "Check this option to include the date of creation (registration) of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
119 |
"phase" => GTM4WP_PHASE_STABLE
|
120 |
),
|
|
|
|
|
|
|
|
|
|
|
121 |
GTM4WP_OPTION_INCLUDE_REMARKETING => array(
|
122 |
"label" => __( "Remarketing variable", 'duracelltomi-google-tag-manager' ),
|
123 |
"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", 'duracelltomi-google-tag-manager' ),
|
@@ -421,13 +426,13 @@ $GLOBALS["gtm4wp_integratefieldtexts"] = array(
|
|
421 |
),
|
422 |
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => array(
|
423 |
"label" => __( "Track classic e-commerce", 'duracelltomi-google-tag-manager' ),
|
424 |
-
"description" =>
|
425 |
"phase" => GTM4WP_PHASE_STABLE,
|
426 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
427 |
),
|
428 |
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => array(
|
429 |
"label" => __( "Track enhanced e-commerce", 'duracelltomi-google-tag-manager' ),
|
430 |
-
"description" =>
|
431 |
"phase" => GTM4WP_PHASE_BETA,
|
432 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
433 |
),
|
@@ -766,8 +771,8 @@ function gtm4wp_sanitize_options($options) {
|
|
766 |
} else if ( ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^[a-zA-Z][a-zA-Z0-9_-]*$/", $newoptionvalue ) ) ) {
|
767 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']', __( "Invalid dataLayer variable name. Please start with a character from a-z or A-Z followed by characters from a-z, A-Z, 0-9 or '_' or '-'!", 'duracelltomi-google-tag-manager' ) );
|
768 |
|
769 |
-
} else if ( ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^[a-zA-Z0-9-]+$/", $newoptionvalue ) ) ) {
|
770 |
-
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']', __( "Invalid gtm_auth environment parameter value. It should only contain letters,
|
771 |
|
772 |
} else if ( ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^env-[0-9]+$/", $newoptionvalue ) ) ) {
|
773 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']', __( "Invalid gtm_preview environment parameter value. It should have the format 'env-NN' where NN is an integer number.", 'duracelltomi-google-tag-manager' ) );
|
@@ -1184,7 +1189,7 @@ function gtm4wp_admin_head() {
|
|
1184 |
.hide();
|
1185 |
|
1186 |
if ( currentval != "" ) {
|
1187 |
-
var gtmauth_regex = /^[a-zA-Z0-9-]+$/;
|
1188 |
if ( ! gtmauth_regex.test( currentval ) ) {
|
1189 |
jQuery( ".gtmauth_validation_error" )
|
1190 |
.show();
|
118 |
"description" => __( "Check this option to include the date of creation (registration) of the logged in user.", 'duracelltomi-google-tag-manager' ),
|
119 |
"phase" => GTM4WP_PHASE_STABLE
|
120 |
),
|
121 |
+
GTM4WP_OPTION_INCLUDE_VISITOR_IP => array(
|
122 |
+
"label" => __( "Visitor IP", 'duracelltomi-google-tag-manager' ),
|
123 |
+
"description" => __( "Check this option to include the IP address of the visitor. You might use this to filter internal traffic inside your GTM container. Please be aware that per GDPR its not allowed to transmit this full IP address to Google Analytics or to any other measurement system without explicit consent from the visitor.", 'duracelltomi-google-tag-manager' ),
|
124 |
+
"phase" => GTM4WP_PHASE_STABLE
|
125 |
+
),
|
126 |
GTM4WP_OPTION_INCLUDE_REMARKETING => array(
|
127 |
"label" => __( "Remarketing variable", 'duracelltomi-google-tag-manager' ),
|
128 |
"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", 'duracelltomi-google-tag-manager' ),
|
426 |
),
|
427 |
GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => array(
|
428 |
"label" => __( "Track classic e-commerce", 'duracelltomi-google-tag-manager' ),
|
429 |
+
"description" => sprintf( __( "Choose this option if you would like to track e-commerce data using <a href=\"%s\" target=\"_blank\">classic transaction data</a>.", 'duracelltomi-google-tag-manager' ) , 'https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce' ),
|
430 |
"phase" => GTM4WP_PHASE_STABLE,
|
431 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
432 |
),
|
433 |
GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => array(
|
434 |
"label" => __( "Track enhanced e-commerce", 'duracelltomi-google-tag-manager' ),
|
435 |
+
"description" => sprintf( __( "Choose this option if you would like to track e-commerce data using <a href=\"%s\" target=\"_blank\">enhanced ecommerce tracking</a>.", 'duracelltomi-google-tag-manager' ) , 'https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce' ),
|
436 |
"phase" => GTM4WP_PHASE_BETA,
|
437 |
"plugintocheck" => "woocommerce/woocommerce.php"
|
438 |
),
|
771 |
} else if ( ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^[a-zA-Z][a-zA-Z0-9_-]*$/", $newoptionvalue ) ) ) {
|
772 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']', __( "Invalid dataLayer variable name. Please start with a character from a-z or A-Z followed by characters from a-z, A-Z, 0-9 or '_' or '-'!", 'duracelltomi-google-tag-manager' ) );
|
773 |
|
774 |
+
} else if ( ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^[a-zA-Z0-9-_]+$/", $newoptionvalue ) ) ) {
|
775 |
+
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']', __( "Invalid gtm_auth environment parameter value. It should only contain letters, numbers or the '-' and '_' characters.", 'duracelltomi-google-tag-manager' ) );
|
776 |
|
777 |
} else if ( ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) && ( $newoptionvalue != "" ) && ( ! preg_match( "/^env-[0-9]+$/", $newoptionvalue ) ) ) {
|
778 |
add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']', __( "Invalid gtm_preview environment parameter value. It should have the format 'env-NN' where NN is an integer number.", 'duracelltomi-google-tag-manager' ) );
|
1189 |
.hide();
|
1190 |
|
1191 |
if ( currentval != "" ) {
|
1192 |
+
var gtmauth_regex = /^[a-zA-Z0-9-_]+$/;
|
1193 |
if ( ! gtmauth_regex.test( currentval ) ) {
|
1194 |
jQuery( ".gtmauth_validation_error" )
|
1195 |
.show();
|
common/readoptions.php
CHANGED
@@ -13,6 +13,7 @@ define( 'GTM4WP_OPTION_INCLUDE_USERID', 'include-userid' );
|
|
13 |
define( 'GTM4WP_OPTION_INCLUDE_USEREMAIL', 'include-useremail' );
|
14 |
define( 'GTM4WP_OPTION_INCLUDE_USERREGDATE', 'include-userregdate' );
|
15 |
define( 'GTM4WP_OPTION_INCLUDE_USERNAME', 'include-username' );
|
|
|
16 |
define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE', 'include-posttype' );
|
17 |
define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES', 'include-categories' );
|
18 |
define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
|
@@ -123,6 +124,7 @@ $gtm4wp_defaultoptions = array(
|
|
123 |
GTM4WP_OPTION_INCLUDE_USEREMAIL => false,
|
124 |
GTM4WP_OPTION_INCLUDE_USERREGDATE => false,
|
125 |
GTM4WP_OPTION_INCLUDE_USERNAME => false,
|
|
|
126 |
GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
|
127 |
GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
|
128 |
GTM4WP_OPTION_INCLUDE_TAGS => true,
|
13 |
define( 'GTM4WP_OPTION_INCLUDE_USEREMAIL', 'include-useremail' );
|
14 |
define( 'GTM4WP_OPTION_INCLUDE_USERREGDATE', 'include-userregdate' );
|
15 |
define( 'GTM4WP_OPTION_INCLUDE_USERNAME', 'include-username' );
|
16 |
+
define( 'GTM4WP_OPTION_INCLUDE_VISITOR_IP', 'include-visitor-ip' );
|
17 |
define( 'GTM4WP_OPTION_INCLUDE_POSTTYPE', 'include-posttype' );
|
18 |
define( 'GTM4WP_OPTION_INCLUDE_CATEGORIES', 'include-categories' );
|
19 |
define( 'GTM4WP_OPTION_INCLUDE_TAGS', 'include-tags' );
|
124 |
GTM4WP_OPTION_INCLUDE_USEREMAIL => false,
|
125 |
GTM4WP_OPTION_INCLUDE_USERREGDATE => false,
|
126 |
GTM4WP_OPTION_INCLUDE_USERNAME => false,
|
127 |
+
GTM4WP_OPTION_INCLUDE_VISITOR_IP => false,
|
128 |
GTM4WP_OPTION_INCLUDE_POSTTYPE => true,
|
129 |
GTM4WP_OPTION_INCLUDE_CATEGORIES => true,
|
130 |
GTM4WP_OPTION_INCLUDE_TAGS => true,
|
duracelltomi-google-tag-manager-for-wordpress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Google Tag Manager for Wordpress
|
4 |
-
Version: 1.8
|
5 |
Plugin URI: https://gtm4wp.com/
|
6 |
Description: The first Google Tag Manager plugin for WordPress with business goals in mind
|
7 |
Author: Thomas Geiger
|
@@ -10,10 +10,10 @@ Text Domain: duracelltomi-google-tag-manager
|
|
10 |
Domain Path: /languages
|
11 |
|
12 |
WC requires at least: 2.6
|
13 |
-
WC tested up to: 3.
|
14 |
*/
|
15 |
|
16 |
-
define( 'GTM4WP_VERSION', '1.8' );
|
17 |
define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
|
18 |
|
19 |
$gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Google Tag Manager for Wordpress
|
4 |
+
Version: 1.8.1
|
5 |
Plugin URI: https://gtm4wp.com/
|
6 |
Description: The first Google Tag Manager plugin for WordPress with business goals in mind
|
7 |
Author: Thomas Geiger
|
10 |
Domain Path: /languages
|
11 |
|
12 |
WC requires at least: 2.6
|
13 |
+
WC tested up to: 3.4.0
|
14 |
*/
|
15 |
|
16 |
+
define( 'GTM4WP_VERSION', '1.8.1' );
|
17 |
define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
|
18 |
|
19 |
$gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
|
integration/woocommerce.php
CHANGED
@@ -75,15 +75,19 @@ function gtm4wp_get_product_category( $product_id, $fullpath = false) {
|
|
75 |
return $product_cat;
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
79 |
global $gtm4wp_options, $wp_query, $gtm4wp_datalayer_name, $gtm4wp_product_counter, $gtm4wp_is_woocommerce3;
|
80 |
|
81 |
$woo = WC();
|
82 |
|
83 |
-
gtm4wp_woocommerce_addjs("
|
84 |
-
window[ 'gtm4wp_use_sku_instead' ] = " . (int)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ]) . ";
|
85 |
-
window[ 'gtm4wp_id_prefix' ] = '" . esc_js( gtm4wp_prefix_productid("") ) . "';");
|
86 |
-
|
87 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA ] && $gtm4wp_is_woocommerce3 ) {
|
88 |
// we need to use this instead of $woo->customer as this will load proper total order number and value from the database instead of the session
|
89 |
$woo_customer = new WC_Customer( $woo->customer->get_id() );
|
@@ -391,8 +395,8 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
391 |
$product_price = $order->get_item_total( $item );
|
392 |
$_temp_productdata = array(
|
393 |
"id" => $remarketing_id,
|
394 |
-
"name" => $
|
395 |
-
"sku" => $product_sku ?
|
396 |
"category" => $product_cat,
|
397 |
"price" => $product_price,
|
398 |
"currency" => get_woocommerce_currency(),
|
@@ -597,7 +601,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
597 |
var _shipping_el = $( '#shipping_method input:checked' );
|
598 |
if ( _shipping_el.length > 0 ) {
|
599 |
". $gtm4wp_datalayer_name .".push({
|
600 |
-
'event': 'gtm4wp.
|
601 |
'ecommerce': {
|
602 |
'checkout_option': {
|
603 |
'actionField': {
|
@@ -612,7 +616,7 @@ function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
|
612 |
var _payment_el = $( '.payment_methods input:checked' );
|
613 |
if ( _payment_el.length > 0 ) {
|
614 |
". $gtm4wp_datalayer_name .".push({
|
615 |
-
'event': 'gtm4wp.
|
616 |
'ecommerce': {
|
617 |
'checkout_option': {
|
618 |
'actionField': {
|
@@ -737,15 +741,15 @@ function gtm4wp_woocommerce_single_add_to_cart_tracking() {
|
|
737 |
$_temp_productdata = array(
|
738 |
"id" => $remarketing_id,
|
739 |
"name" => $product->get_title(),
|
740 |
-
"sku" => $product_sku ?
|
741 |
"category" => $product_cat,
|
742 |
"price" => $product->get_price(),
|
743 |
"currency" => get_woocommerce_currency()
|
744 |
);
|
745 |
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "addtocartsingle" );
|
746 |
|
747 |
-
foreach( $eec_product_array as $
|
748 |
-
echo '<input type="hidden" name="gtm4wp_' . esc_attr( $
|
749 |
}
|
750 |
}
|
751 |
|
@@ -1271,6 +1275,8 @@ if ( function_exists ( "WC" ) ) {
|
|
1271 |
|
1272 |
add_action( "wp_footer", "gtm4wp_woocommerce_wp_footer" );
|
1273 |
add_action( "wp_enqueue_scripts", "gtm4wp_woocommerce_enqueue_scripts" );
|
|
|
|
|
1274 |
|
1275 |
if ( true === $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1276 |
add_action( 'wp_footer', 'gtm4wp_woocommerce_enhanced_ecom_product_click' );
|
75 |
return $product_cat;
|
76 |
}
|
77 |
|
78 |
+
function gtm4wp_woocommerce_addglobalvars() {
|
79 |
+
global $gtm4wp_options;
|
80 |
+
|
81 |
+
echo "
|
82 |
+
var gtm4wp_use_sku_instead = " . (int)($gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCUSESKU ]) . ";
|
83 |
+
var gtm4wp_id_prefix = '" . esc_js( gtm4wp_prefix_productid("") ) . "';";
|
84 |
+
}
|
85 |
+
|
86 |
function gtm4wp_woocommerce_datalayer_filter_items( $dataLayer ) {
|
87 |
global $gtm4wp_options, $wp_query, $gtm4wp_datalayer_name, $gtm4wp_product_counter, $gtm4wp_is_woocommerce3;
|
88 |
|
89 |
$woo = WC();
|
90 |
|
|
|
|
|
|
|
|
|
91 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA ] && $gtm4wp_is_woocommerce3 ) {
|
92 |
// we need to use this instead of $woo->customer as this will load proper total order number and value from the database instead of the session
|
93 |
$woo_customer = new WC_Customer( $woo->customer->get_id() );
|
395 |
$product_price = $order->get_item_total( $item );
|
396 |
$_temp_productdata = array(
|
397 |
"id" => $remarketing_id,
|
398 |
+
"name" => $product->get_title(),
|
399 |
+
"sku" => $product_sku ? $product_sku : $product_id,
|
400 |
"category" => $product_cat,
|
401 |
"price" => $product_price,
|
402 |
"currency" => get_woocommerce_currency(),
|
601 |
var _shipping_el = $( '#shipping_method input:checked' );
|
602 |
if ( _shipping_el.length > 0 ) {
|
603 |
". $gtm4wp_datalayer_name .".push({
|
604 |
+
'event': 'gtm4wp.checkoutOptionEEC',
|
605 |
'ecommerce': {
|
606 |
'checkout_option': {
|
607 |
'actionField': {
|
616 |
var _payment_el = $( '.payment_methods input:checked' );
|
617 |
if ( _payment_el.length > 0 ) {
|
618 |
". $gtm4wp_datalayer_name .".push({
|
619 |
+
'event': 'gtm4wp.checkoutOptionEEC',
|
620 |
'ecommerce': {
|
621 |
'checkout_option': {
|
622 |
'actionField': {
|
741 |
$_temp_productdata = array(
|
742 |
"id" => $remarketing_id,
|
743 |
"name" => $product->get_title(),
|
744 |
+
"sku" => $product_sku ? $product_sku : $product_id,
|
745 |
"category" => $product_cat,
|
746 |
"price" => $product->get_price(),
|
747 |
"currency" => get_woocommerce_currency()
|
748 |
);
|
749 |
$eec_product_array = apply_filters( GTM4WP_WPFILTER_EEC_PRODUCT_ARRAY, $_temp_productdata, "addtocartsingle" );
|
750 |
|
751 |
+
foreach( $eec_product_array as $eec_product_array_key => $eec_product_array_value ) {
|
752 |
+
echo '<input type="hidden" name="gtm4wp_' . esc_attr( $eec_product_array_key ). '" value="' . esc_attr( $eec_product_array_value ). '" />'."\n";
|
753 |
}
|
754 |
}
|
755 |
|
1275 |
|
1276 |
add_action( "wp_footer", "gtm4wp_woocommerce_wp_footer" );
|
1277 |
add_action( "wp_enqueue_scripts", "gtm4wp_woocommerce_enqueue_scripts" );
|
1278 |
+
|
1279 |
+
add_action( GTM4WP_WPACTION_ADDGLOBALVARS, "gtm4wp_woocommerce_addglobalvars" );
|
1280 |
|
1281 |
if ( true === $GLOBALS[ "gtm4wp_options" ][ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ) {
|
1282 |
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:
|
16 |
},
|
17 |
"adwords": {
|
18 |
tabtext: gtm4wp.adwordstabtitle,
|
12 |
},
|
13 |
"visitor": {
|
14 |
tabtext: gtm4wp.visitortabtitle,
|
15 |
+
numitems: 7
|
16 |
},
|
17 |
"adwords": {
|
18 |
tabtext: gtm4wp.adwordstabtitle,
|
js/gtm4wp-contact-form-7-tracker.js
CHANGED
@@ -4,11 +4,15 @@ jQuery( function() {
|
|
4 |
var gtm4wp_cf7formid = '(not set)';
|
5 |
if ( e && e.detail && e.detail.contactFormId ) {
|
6 |
gtm4wp_cf7formid = e.detail.contactFormId;
|
|
|
|
|
7 |
}
|
8 |
|
9 |
var gtm4wp_cf7forminputs = [];
|
10 |
if ( e && e.detail && e.detail.inputs ) {
|
11 |
gtm4wp_cf7forminputs = e.detail.inputs;
|
|
|
|
|
12 |
}
|
13 |
|
14 |
window[ gtm4wp_datalayer_name ].push({
|
4 |
var gtm4wp_cf7formid = '(not set)';
|
5 |
if ( e && e.detail && e.detail.contactFormId ) {
|
6 |
gtm4wp_cf7formid = e.detail.contactFormId;
|
7 |
+
} else if ( e && e.originalEvent && e.originalEvent.detail && e.originalEvent.detail.contactFormId ) {
|
8 |
+
gtm4wp_cf7formid = e.originalEvent.detail.contactFormId;
|
9 |
}
|
10 |
|
11 |
var gtm4wp_cf7forminputs = [];
|
12 |
if ( e && e.detail && e.detail.inputs ) {
|
13 |
gtm4wp_cf7forminputs = e.detail.inputs;
|
14 |
+
} else if ( e && e.originalEvent && e.originalEvent.detail && e.originalEvent.detail.inputs ) {
|
15 |
+
gtm4wp_cf7forminputs = e.originalEvent.detail.inputs;
|
16 |
}
|
17 |
|
18 |
window[ gtm4wp_datalayer_name ].push({
|
js/gtm4wp-woocommerce-enhanced.js
CHANGED
@@ -64,6 +64,11 @@
|
|
64 |
});
|
65 |
|
66 |
jQuery(document).on( 'found_variation', function( event, product_variation ) {
|
|
|
|
|
|
|
|
|
|
|
67 |
var _product_form = event.target;
|
68 |
var _product_var_id = jQuery( '[name=variation_id]', _product_form );
|
69 |
var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val();
|
64 |
});
|
65 |
|
66 |
jQuery(document).on( 'found_variation', function( event, product_variation ) {
|
67 |
+
if ( "undefined" == typeof product_variation ) {
|
68 |
+
// some ither plugins trigger this event without variation data
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
var _product_form = event.target;
|
73 |
var _product_var_id = jQuery( '[name=variation_id]', _product_form );
|
74 |
var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val();
|
public/frontend.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
2 |
-
define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER',
|
3 |
define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtm4wp_compile_remarkering' );
|
4 |
-
define( 'GTM4WP_WPFILTER_GETTHEGTMTAG',
|
|
|
5 |
|
6 |
$GLOBALS[ "gtm4wp_container_code_written" ] = false;
|
7 |
|
@@ -82,6 +83,20 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
|
|
82 |
}
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
|
86 |
$dataLayer["pageTitle"] = strip_tags( wp_title( "|", false, "right" ) );
|
87 |
}
|
@@ -627,19 +642,23 @@ function gtm4wp_wp_header_top() {
|
|
627 |
|
628 |
echo '
|
629 |
<!-- Google Tag Manager for WordPress by DuracellTomi -->
|
630 |
-
<script data-cfasync="false" type="text/javascript"
|
631 |
var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
|
632 |
-
var ' . $gtm4wp_datalayer_name . ' = ' . $gtm4wp_datalayer_name . ' || [];
|
|
|
|
|
|
|
|
|
633 |
</script>
|
634 |
<!-- End Google Tag Manager for WordPress by DuracellTomi -->';
|
635 |
}
|
636 |
|
637 |
-
function gtm4wp_wp_header_begin() {
|
638 |
global $gtm4wp_datalayer_name, $gtm4wp_options;
|
639 |
|
640 |
$_gtm_header_content = '
|
641 |
<!-- Google Tag Manager for WordPress by DuracellTomi -->
|
642 |
-
<script data-cfasync="false" type="text/javascript"
|
643 |
|
644 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
645 |
$_gtm_header_content .= '
|
@@ -688,7 +707,7 @@ function gtm4wp_wp_header_begin() {
|
|
688 |
) . ');';
|
689 |
}
|
690 |
|
691 |
-
$_gtm_header_content .= '
|
692 |
</script>';
|
693 |
|
694 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != "" ) && ( GTM4WP_PLACEMENT_OFF != $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) ) {
|
@@ -703,11 +722,13 @@ function gtm4wp_wp_header_begin() {
|
|
703 |
}
|
704 |
|
705 |
$_gtm_tag .= '
|
706 |
-
<script data-cfasync="false"
|
|
|
707 |
new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
|
708 |
j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
709 |
\'//www.googletagmanager.com/gtm.\''.'+\'js?id=\'+i+dl' . $_gtm_env . ';f.parentNode.insertBefore(j,f);
|
710 |
-
})(window,document,\'script\',\'' . $gtm4wp_datalayer_name . '\',\'' . $one_gtm_code . '\')
|
|
|
711 |
}
|
712 |
|
713 |
$_gtm_tag .= '
|
@@ -720,7 +741,11 @@ j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
|
720 |
$_gtm_header_content .= '
|
721 |
<!-- End Google Tag Manager for WordPress by DuracellTomi -->';
|
722 |
|
723 |
-
|
|
|
|
|
|
|
|
|
724 |
}
|
725 |
|
726 |
function gtm4wp_body_class( $classes ) {
|
@@ -736,7 +761,7 @@ function gtm4wp_body_class( $classes ) {
|
|
736 |
}
|
737 |
|
738 |
add_action( "wp_enqueue_scripts", "gtm4wp_enqueue_scripts" );
|
739 |
-
add_action( "wp_head", "gtm4wp_wp_header_begin" );
|
740 |
add_action( "wp_head", "gtm4wp_wp_header_top", 1 );
|
741 |
add_action( "wp_footer", "gtm4wp_wp_footer" );
|
742 |
add_action( "wp_loaded", "gtm4wp_wp_loaded" );
|
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 |
+
define( 'GTM4WP_WPACTION_ADDGLOBALVARS', 'gtm4wp_add_global_vars' );
|
6 |
|
7 |
$GLOBALS[ "gtm4wp_container_code_written" ] = false;
|
8 |
|
83 |
}
|
84 |
}
|
85 |
|
86 |
+
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_VISITOR_IP ] ) {
|
87 |
+
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
|
88 |
+
//check ip from shared internet
|
89 |
+
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
90 |
+
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
91 |
+
//to check ip is passed from proxy
|
92 |
+
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
93 |
+
} else {
|
94 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
95 |
+
}
|
96 |
+
|
97 |
+
$dataLayer["visitorIP"] = $ip;
|
98 |
+
}
|
99 |
+
|
100 |
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_POSTTITLE ] ) {
|
101 |
$dataLayer["pageTitle"] = strip_tags( wp_title( "|", false, "right" ) );
|
102 |
}
|
642 |
|
643 |
echo '
|
644 |
<!-- Google Tag Manager for WordPress by DuracellTomi -->
|
645 |
+
<script data-cfasync="false" type="text/javascript">//<![CDATA[
|
646 |
var gtm4wp_datalayer_name = "' . $gtm4wp_datalayer_name . '";
|
647 |
+
var ' . $gtm4wp_datalayer_name . ' = ' . $gtm4wp_datalayer_name . ' || [];//]]>';
|
648 |
+
|
649 |
+
do_action( GTM4WP_WPACTION_ADDGLOBALVARS );
|
650 |
+
|
651 |
+
echo '
|
652 |
</script>
|
653 |
<!-- End Google Tag Manager for WordPress by DuracellTomi -->';
|
654 |
}
|
655 |
|
656 |
+
function gtm4wp_wp_header_begin( $echo = true ) {
|
657 |
global $gtm4wp_datalayer_name, $gtm4wp_options;
|
658 |
|
659 |
$_gtm_header_content = '
|
660 |
<!-- Google Tag Manager for WordPress by DuracellTomi -->
|
661 |
+
<script data-cfasync="false" type="text/javascript">//<![CDATA[';
|
662 |
|
663 |
if ( $gtm4wp_options[ GTM4WP_OPTION_SCROLLER_ENABLED ] ) {
|
664 |
$_gtm_header_content .= '
|
707 |
) . ');';
|
708 |
}
|
709 |
|
710 |
+
$_gtm_header_content .= '//]]>
|
711 |
</script>';
|
712 |
|
713 |
if ( ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != "" ) && ( GTM4WP_PLACEMENT_OFF != $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) ) {
|
722 |
}
|
723 |
|
724 |
$_gtm_tag .= '
|
725 |
+
<script data-cfasync="false">//<![CDATA[
|
726 |
+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
|
727 |
new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
|
728 |
j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
|
729 |
\'//www.googletagmanager.com/gtm.\''.'+\'js?id=\'+i+dl' . $_gtm_env . ';f.parentNode.insertBefore(j,f);
|
730 |
+
})(window,document,\'script\',\'' . $gtm4wp_datalayer_name . '\',\'' . $one_gtm_code . '\');//]]>
|
731 |
+
</script>';
|
732 |
}
|
733 |
|
734 |
$_gtm_tag .= '
|
741 |
$_gtm_header_content .= '
|
742 |
<!-- End Google Tag Manager for WordPress by DuracellTomi -->';
|
743 |
|
744 |
+
if ( $echo ) {
|
745 |
+
echo $_gtm_header_content;
|
746 |
+
} else {
|
747 |
+
return $_gtm_header_content;
|
748 |
+
}
|
749 |
}
|
750 |
|
751 |
function gtm4wp_body_class( $classes ) {
|
761 |
}
|
762 |
|
763 |
add_action( "wp_enqueue_scripts", "gtm4wp_enqueue_scripts" );
|
764 |
+
add_action( "wp_head", "gtm4wp_wp_header_begin", 10, 0 );
|
765 |
add_action( "wp_head", "gtm4wp_wp_header_top", 1 );
|
766 |
add_action( "wp_footer", "gtm4wp_wp_footer" );
|
767 |
add_action( "wp_loaded", "gtm4wp_wp_loaded" );
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://gtm4wp.com/
|
|
4 |
Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel
|
5 |
Requires at least: 3.4.0
|
6 |
Requires PHP: 5.3
|
7 |
-
Tested up to: 4.9.
|
8 |
-
Stable tag: 1.8
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl.html
|
11 |
|
@@ -255,6 +255,19 @@ If you or your social plugin inserts the Facebook buttons using IFRAMEs (like So
|
|
255 |
|
256 |
== Changelog ==
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
= 1.8 =
|
259 |
|
260 |
* Fixed: weather data tracking codes could result in fatal PHP error
|
@@ -521,6 +534,10 @@ Please report all bugs found in my plugin using the [contact form on my website]
|
|
521 |
|
522 |
== Upgrade Notice ==
|
523 |
|
|
|
|
|
|
|
|
|
524 |
= 1.8 =
|
525 |
|
526 |
Lots of new features and some important changes, please read the changelog to ensure your measurement does not break
|
4 |
Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, adwords remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel
|
5 |
Requires at least: 3.4.0
|
6 |
Requires PHP: 5.3
|
7 |
+
Tested up to: 4.9.6
|
8 |
+
Stable tag: 1.8.1
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl.html
|
11 |
|
255 |
|
256 |
== Changelog ==
|
257 |
|
258 |
+
= 1.8.1 =
|
259 |
+
|
260 |
+
* Added: new visitorIP data layer variable to support post-GDPR implementations where for example internal traffic exclusion has to be made inside the browser
|
261 |
+
* Fixed: JavaScript error around the variable gtm4wp_use_sku_instead
|
262 |
+
* Fixed: added _ as a valid character for gtm_auth GTM environment variable
|
263 |
+
* Fixed: corrected typo - gtm4wp.checkoutStepE**E**C
|
264 |
+
* Fixed: two strings were not recognized by WordPress Translate on the admin page
|
265 |
+
* Fixed: some other plugins call found_variation event of WooCommerce without product variation data being included
|
266 |
+
* Fixed: product name included variation name on order received page which broke GA product reports
|
267 |
+
* Fixed: in some cases, no contact form 7 data was being passed to the gtm4wp.contactForm7Submitted event
|
268 |
+
* Updated: added CDATA markup around container code for better DOM compatibility
|
269 |
+
* Updated: removed 'SKU:' prefix text from classic ecommerce dimension as it broke some enhanced ecommerce reports
|
270 |
+
|
271 |
= 1.8 =
|
272 |
|
273 |
* Fixed: weather data tracking codes could result in fatal PHP error
|
534 |
|
535 |
== Upgrade Notice ==
|
536 |
|
537 |
+
= 1.8.1 =
|
538 |
+
|
539 |
+
Bugfix version fixing some issues around WooCommerce tracking and GTM environments. Also adds IP address into the data layer.
|
540 |
+
|
541 |
= 1.8 =
|
542 |
|
543 |
Lots of new features and some important changes, please read the changelog to ensure your measurement does not break
|