Created
April 7, 2022 13:17
-
-
Save kimcoleman/1210a551bcdb3d4f53d49cfb58f75212 to your computer and use it in GitHub Desktop.
Add a session variable so we only push the ecommerce data to GTM on the first checkout, not any subsequent visit to the confirmation page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a session variable so we only push the ecommerce data to GTM on the first checkout. | |
* Not any subsequent visit to the confirmation page. | |
* | |
*/ | |
function pmpro_gtag_ecommerce_set_session( $user_id, $morder ) { | |
pmpro_set_session_var( 'pmpro_gtag_order', $morder->id ); | |
} | |
add_action( 'pmpro_after_checkout', 'pmpro_gtag_ecommerce_set_session', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment