Skip to content

Commit

Permalink
Add/ecommerce clear
Browse files Browse the repository at this point in the history
  • Loading branch information
duracelltomi authored Sep 19, 2023
2 parents 1cc4e67 + f330588 commit 5005c1b
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 139 deletions.
18 changes: 18 additions & 0 deletions admin/admin-tab-integrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@
),
'phase' => GTM4WP_PHASE_STABLE,
),
GTM4WP_OPTION_INTEGRATE_WCCLEARECOMMERCEDL => array(
'label' => esc_html__( 'Clear ecommerce object before new event', 'duracelltomi-google-tag-manager' ),
'description' => sprintf(
gtm4wp_safe_admin_html(
// translators: 1: anchor element linking to the official GA4 doc about clearing the ecommerce object. 2: closing anchor element.
__(
'Clear the ecommerce object before any new event being pushed into the data layer.<br /><br />
Althought it is %1$srecommended by Google%2$s, it is not mandatory to activate this feature as
the GA4 event tag reads only the last pushed ecommerce data on any new event.<br />
Use it if you encounter issues with your GTM implementation.',
'duracelltomi-google-tag-manager'
)
),
'<a href="https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm#clear_the_ecommerce_object" target="_blank" rel="noopener">',
'</a>'
),
'phase' => GTM4WP_PHASE_STABLE,
),

GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => array(
'label' => esc_html__( 'Google Optimize container ID list', 'duracelltomi-google-tag-manager' ),
Expand Down
2 changes: 2 additions & 0 deletions common/readoptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
define( 'GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX', 'integrate-woocommerce-exclude-tax' );
define( 'GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING', 'integrate-woocommerce-exclude-shipping' );
define( 'GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG', 'integrate-woocommerce-do-not-use-order-tracked-flag' );
define( 'GTM4WP_OPTION_INTEGRATE_WCCLEARECOMMERCEDL', 'integrate-woocommerce-clear-ecommerce-datalayer' );

define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS', 'integrate-google-optimize-idlist' );
define( 'GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT', 'integrate-google-optimize-timeout' );
Expand Down Expand Up @@ -225,6 +226,7 @@
GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => false,
GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => false,
GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => false,
GTM4WP_OPTION_INTEGRATE_WCCLEARECOMMERCEDL => false,

GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => '',
GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => 4000,
Expand Down
1 change: 1 addition & 0 deletions integration/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ function gtm4wp_woocommerce_addglobalvars( $return ) {
$return['gtm4wp_needs_shipping_address'] = (bool) $gtm4wp_needs_shipping_address;
$return['gtm4wp_business_vertical'] = esc_js( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ] );
$return['gtm4wp_business_vertical_id'] = gtm4wp_get_gads_product_id_variable_name( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ] );
$return['gtm4wp_clear_ecommerce'] = (bool) ( $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCCLEARECOMMERCEDL ] );

return $return;
}
Expand Down
Loading

0 comments on commit 5005c1b

Please sign in to comment.