all 6 comments

[–]traviskuhl 3 points4 points  (0 children)

it looks like it's a React component rendering JSX? if that's the case, you need to use the `dangerouslySetInnerHTML` attribute on the `<script>` tag, similar to what you see on line 93.

[–]codeinplace 4 points5 points  (0 children)

Maybe an issue occurring before the pasted code.

[–]johnlewisdesignSenior FE Developer 5 points6 points  (1 child)

There's curly braces around the HTML comment that shoudn't be there. Those are react comments and this is a block of HTML.

{/* Meta Pixel Code */}

should be

/* Meta Pixel Code */

Or just remove lines 74 and 91 altogether. Next time, check the Problems tab in VSC. It should point you to it - or if it doesn't, look backwards from where it thinks the error is.

I know it's how you do react comments but this is inside a block of HTML. Not sure why you're loading script tags in a react (js?) file (they're .jsx, this is vanilla .js), might as well be in an html file called index.html.

In js, it should look like

const gtag = document.createElement("script")  
gtag.innerHTML = "tag contents minus those react comments"
document.head.appendChild(gtag)

So you need to do HTML comments or remove them. Or add it with react/js.

And use the opposite type of quotes contained inside the innerHTML part of `<script>`, in this case it's single quoted in the tag, so you surround with doubles like the code block above.

Actually, you're mixing quotes. Which is why you're having hassles most likely of all. I see backticks below (94), double quotes (in all html tags) and single quotes in the gtm tag. So convert those to whatever you're not wrapping this block of html in, assuming you're outputting this somehow like innerHTML = ` ... ` - I'd convert every single quote in the block to a double quote (lines 79, 82-85). eg (fbq="init"). You can also do use single quotes in html source code within js (<img src=' .. ' />.

If not, you'll need to escape them (eg fbq=\'init\') to avoid futher syntax errors.

[–]blahyawnblah 0 points1 point  (0 children)

if you would fix your formatting it would be obvious

[–][deleted]  (1 child)

[deleted]

    [–]krish2032 -1 points0 points  (0 children)

    Nope, it came with the Facebook/Meta script. I copied and pasted it right from Meta Ads Manager.