Skip to content

Commit

Permalink
Fix: use custom datalayer variable name if set
Browse files Browse the repository at this point in the history
  • Loading branch information
duracelltomi committed Nov 14, 2021
1 parent e7d7031 commit dfcb872
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions public/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function gtm4wp_enqueue_scripts() {
}

function gtm4wp_wp_footer() {
global $gtm4wp_options;
global $gtm4wp_options, $gtm4wp_datalayer_name;

if ( GTM4WP_PLACEMENT_FOOTER == $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] ) {
gtm4wp_the_gtm_tag();
Expand All @@ -604,8 +604,8 @@ function gtm4wp_wp_footer() {
if ( $user_logged_in ) {
echo "
<script" . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ">
if ( window.dataLayer ) {
window.dataLayer.push({
if ( window." . $gtm4wp_datalayer_name . " ) {
window." . $gtm4wp_datalayer_name . ".push({
'event': 'gtm4wp.userLoggedIn'
});
}
Expand All @@ -623,8 +623,8 @@ function gtm4wp_wp_footer() {
if ( $user_registered ) {
echo "
<script" . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ">
if ( window.dataLayer ) {
window.dataLayer.push({
if ( window." . $gtm4wp_datalayer_name . " ) {
window." . $gtm4wp_datalayer_name . ".push({
'event': 'gtm4wp.userRegistered'
});
}
Expand Down

0 comments on commit dfcb872

Please sign in to comment.