Add HubSpot Javascript to global script

Hi there!

I know that we shouldn’t add the script tags to the gloabl script area, because they’re automatically added; however, I don’t know how to structure HubSpot’s code to work within the autoscripted areas. Code below:

<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/2967179.js"></script>

EDIT I’ve just discovered that HubSpot has a plug-in that enables an easy way to add it to Wordpress sites.

Hi There,

If you don’t want to that plugin, you can add the following code under functions.php file locates in your child theme:

function add_custom_code(){
	?>
	<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/2967179.js"></script>
	<?php
}
add_action( 'wp_head', 'add_custom_code' );

Hope it helps :slight_smile: