Skip to content

Commit

Permalink
Added sending _ga_* cookies to webhook for a new order
Browse files Browse the repository at this point in the history
  • Loading branch information
plance committed Jul 21, 2024
1 parent 0cfd4af commit d8911ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: gtmserver,bukashk0zzz
Tags: google tag manager, google tag manager server side, gtm, gtm server side, tag manager, tagmanager, analytics, google, serverside, server-side, gtag
Requires at least: 5.2.0
Tested up to: 6.6.0
Stable tag: 2.1.17
Stable tag: 2.1.18
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -67,6 +67,9 @@ Yes. <a href="https://stape.io/blog/how-to-set-up-facebook-conversion-api">How t

== Changelog ==

= 2.1.18 =
* Added sending _ga_* cookies to webhook for a new order

= 2.1.17 =
* Tested up to WordPress 6.6

Expand Down
2 changes: 1 addition & 1 deletion gtm-server-side.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: GTM Server Side
* Plugin URI: https://wordpress.org/plugins/gtm-server-side/
* Description: Enhance conversion tracking by implementing server-side tagging using server Google Tag Manager container. Effortlessly configure data layer events in web GTM, send webhooks, set up custom loader, and extend cookie lifetime.
* Version: 2.1.17
* Version: 2.1.18
* Author: Stape
* Author URI: https://stape.io
* License: GPL-2.0+
Expand Down
13 changes: 13 additions & 0 deletions includes/class-gtm-server-side-webhook-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ public function woocommerce_new_order( $order_id, $order ) {
'FPID' => filter_input( INPUT_COOKIE, 'FPID', FILTER_DEFAULT ),
'FPLC' => filter_input( INPUT_COOKIE, 'FPLC', FILTER_DEFAULT ),
);

if ( ! empty( $_COOKIE ) ) {
$filtered_cookies = array_filter(
$_COOKIE,
function( $key ) {
return preg_match( '/^_ga_.+/', $key );
},
ARRAY_FILTER_USE_KEY
);

$request_cookies = array_merge( $request_cookies, $filtered_cookies );
}

$request_cookies = array_filter( $request_cookies );

if ( ! empty( $request_cookies ) ) {
Expand Down

0 comments on commit d8911ea

Please sign in to comment.