I am using react-helmet to push elements in the head. The code snippet that needs to be used is of GTM and e-commerce tracking. But, I'm not able to find a way to insert script in head anyway. The documentation shows for loading from external source. The code snippet has dynamic values that are being used.
The documentation is from tthis url : react-helmet
<Helmet script={[
{src: "http://include.com/pathtojs.js", type: "text/javascript"},
{type: "application/ld+json", innerHTML: `{ "@context": "http://schema.org" }`}
]}
/>
The documentation is correct. This works
<Helmet
script={[{
type: 'text/javascript',
innerHTML: 'console.log("It works!")'
}]} />
Check your version of Helmet - the innerHTML
attribute was introduced in Helmet 3.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With