How To Add GTM, Google Analytics Or Other Third Party Scripts In Hongo?

When you want to add <script> tag in header, copy below custom code in your child theme functions.php file or parent theme functions.php file.

if ( ! function_exists( 'hongo_child_header_custom_script' ) ) {
	function hongo_child_header_custom_script() {
		?>
		<script src="https://example.script.js"></script>
		<?php
	}
}
add_action( 'wp_head', 'hongo_child_header_custom_script' );

When you want to add <script> tag in footer, copy below custom code in your child theme functions.php file or parent theme functions.php file.

if ( ! function_exists( 'hongo_child_footer_custom_script' ) ) {
	function hongo_child_footer_custom_script() {
		?>
		<script src="https://example.script.js"></script>
		<?php
	}
}
add_action( 'wp_footer', 'hongo_child_footer_custom_script' );

Note : We recommend this code customization with child theme for prevent your customization code when parent theme updates.

When you need to add code in <script> tag, you do not need to write any custom code. For that you just need to use additional JS functionality. before to know more

SCROLL UP