Filter Request
-
Hi! This is my problem: the code contained inside the
scripttag returned bygtm4wp_get_the_gtm_tagis automatically executed when the browser gets there. I know this is the default behavior (that’s Google’s code). However, I’d like to call that code when I want. In order to do so, I thought I could simply surround that script with a named function, and then call that function when I need to.Could you please update the plugin and add a new filter there? This way, right before the variable
$_gtm_tagis returned, one can hook edit the return value:- return $_gtm_tag; + return apply_filters( 'gtm4wp_get_the_gtm_tag', $_gtm_tag );Then, I could do something like this:
add_filter( 'gtm4wp_get_the_gtm_tag', 'nelio_tweak_gtm_tag' ); function nelio_tweak_gtm_tag( $script ) { $script = str_replace( '<script>', '<script>nelioWrapperFunc() {', $script ); $script = str_replace( '</script>', '}</script>', $script ); return $script; }Please, let me know if this is possible. Thank you very much for your time and help!
https://ww.wp.xz.cn/plugins/duracelltomi-google-tag-manager/
The topic ‘Filter Request’ is closed to new replies.