Example 1
<?php
//* Do NOT include the opening php tag
function ee_add_javascript_thank_you() {
if ( is_page( 'thank-you' ) ) {
?>
<script type="text/javascript" src="http://example.com/js"></script>
<?php
}
}
add_action( 'wp_footer', 'ee_add_javascript_thank_you' );
The example above can be added to your child theme's functions.php file or a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/). By default the slug for the thank you page for Event Espresso 4 is set to thank-you
. The slug thank-you should be changed to your actual page slug for the thank you page.
Need it to run in the header? Change wp_footer
to wp_head
and then save changes.
Example 2
<?php
//* Do NOT include the opening php tag
function ee_add_javascript_thank_you_footer() {
?>
<script type="text/javascript" src="http://example.com/js"></script>
<?php
}
add_action( 'AHEE__thank_you_page_overview_template__bottom', 'ee_add_javascript_thank_you_footer' );
The example above can be added to your child theme's functions.php file or a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/). It will add the JavaScript to the end of the overview section of the thank you page for Event Espresso.
References:
https://eventespresso.com/topic/ee4-google-pixel-code-on-thank-you-page/
Related:
https://gist.github.com/lorenzocaum/397b6ca09bc1d1ab96b7