Snippet injection wishlist

It would be great to be able to specify on which environments the snippet injection should take place.
I for example don’t want/need analytics on my test deploys.

1 Like

I’m using Cloudflare as DNS right now, and I have managed to set up TLSA, and extend DS and DNSKEY nicely for both my domain and my www subdomain. It would be nice if Netlify DNS had these options, and maybe PGP too. To make our websites safer.
Also, a more intuitive and editable snippet injection feature, like editing already existing snippets, rearranging them, so it’s not just one big snippet for the head and the body if needed. Maybe not just adding it before the end of the section, but also right affter the beginning.

2 Likes

On the topic of snippet injection: I’d really love to be able to edit my snippets too, instead of having to delete existing ones and adding new ones!

2 Likes

Also, snippets should keep “formatting”, like how you use tabs/spaces to maintain a pretty code. The first line always ignores the tabs/spaces, and there is no break after the last line, closing of head and body just goes right after, which can be very unpleasant when you browse the source code in the browser, especially if it’s a long link to a CSS or JS.
It’s not a big deal, but it triggers my faux ocd. :smiley:

You can conditionally set identifiers to help keep your data clean, as demonstrated in this article: https://www.netlify.com/docs/split-testing/#using-netlify-snippet-injection-to-track-split-testing-information .

Not a perfect solution but maybe a useful workaround, to key off of contexts to change config :slight_smile:

I don’t use split testing, can I still use this? And this is in addition to the normal analytics script? Won’t the normal analytics script also set a pageview then?

Also not sure what this Branch syntax does.

The docs could definitely be improved here.

Snippet Injection(s) at the start of the <body> Tag

As indicated in the “Google Tag Manager container snippet” section of Google’s Verify site ownership page, the <noscript> portion of the Tag Manager code is to be placed “immediately after the opening <body> tag.”

(I realize that Netlify offers a paid service for Analytics, however, we are using in Google’s solution across the entire University. Therefore, we are unable to use Netlify’s Analytics as a replacement.)

One of the stated objectives of the Snippet Injection feature is to prevent “[pollution of] the source code”, which is fantastic. However, the only options currently offered are “before the closing </head> tag [and] before the closing </body> tag.” This limitation prevents proper use of the Google Tag Manager code.

FR: Please offer the ability to inject code immediately after the opening <body> tag.