Snippet injection not working?

My sites name is https://beyondthefive.netlify.app/ or https://beyondthefive.org/

I currently have 3 snippets that I’d like to inject into my website, the one I am worried about right now is for Yandex Metrica. The problem that I’m having is that none of these snippets appear to be injected into the website at all.

On my netlify dashboard, I’ve added the Yandex Metrica snippet, but I can’t seem to find it when I visit my website and view the source code. I’ve tried re-adding the snippet and redeploying, but so far nothing seems to work. How can I debug/fix this?

I’ve also recently changed the domain for the site. It might be just a coincidence, but this problem arose basically at the same time I made the switch. I’m not sure if they are related or not.

Thanks in advance!

I don’t see snippets configured on this site:

So no surprise they aren’t working :slight_smile: . That feature is enabled/disabled in realtime without a redeploy.

Every one of the ~5 reports we’ve gotten of snippets not working in the 4 years I’ve worked for Netlify have been because someone says “put this snippet before </body>” and have had no </body> tag in their html, so there was nowhere to put it. Could that be your issue too?

Sorry, I’m a little bit confused. On my end, I see 3 snippets.

I do have body tags in my code, so that shouldn’t the issue. I’ve also deployed a couple of times to try and see if it would fix the issue, but so far it seems that it hasn’t?

When you say:

That feature is enabled/disabled in realtime without a redeploy.

is there like a snippet on/off button I’m just not seeing?

Hey @joshkmartinez,
You’re right about the snippets! Our view of your UI is slightly different, so we weren’t able to see them. But we confirmed in our database that they are there- so apologies for saying otherwise earlier.

What we could not confirm by looking at the page source of your site is that you have <head></head> and <body></body> tags. Without those, our snippets engine doesn’t know where to place your snippets on your site. Can you add those and see if it fixes things for you?

@joshkmartinez You might want to run the final page code through an HTML validator. You’re missing some key tags.

I have same problem try to rebuild the site but still not working here is my site https://reverent-villani-1a164a.netlify.app/ or https://cekongkir.co.id/

FYI try to add a google analytics to Snippet injection
the site is build using next on netlify

Thank you

I believe this is working as intended, @djepri13. You won’t see us injecting anything into your function responses (such as the one you proxy to from “/”; that is treated like a proxy’d connection (see Rewrites and proxies | Netlify Docs) and we do not apply processing directives such as injected snippets to that content.

If you instead fetch an html file directly:

https://cekongkir.co.id/ongkir.html

You can see the injection working.

So, to summarize, for functions (and other proxy’d content), you’ll have to make sure ALL required output is generated directly by the function/remote server, rather than relying on us to modify the outgoing data stream.

1 Like