Conditionally enable/disable Hubspot based on a state variable for a React app


#1

I have a question with regards to adding the Hubspot script tag in the HTML for a React app. Is there a way use webpack.config.js to change the src content of the script tag in the HTML using a state variable already set up in the Redux store?
The state variable is setup to either be the Hubspot_URL or to an empty string "", and that can go in src for the script tag in HTML:

<script type=“text/javascript” src={variable} ></script>

This allows to conditionally enable/disable Hubspot based on a state variable.

Thanks,
Al


#3

Welcome, @al61!

In theory, I think this would work, but I haven't heard or seen this exact thing done before. (I'd love to hear from other community members, though!) What have your tests revealed?