Best practice to paste Goolge Tags and Facebook Pixel code into website via database?

Best practice to paste Goolge Tags and Facebook Pixel code into website via database?
Would it be OK… if a client paste javascript into a database table to be used for google analytics and pixel good… is that good or bad practice. As they normally get these scripts to copy and paste into their sites… so would one create a “longtext” field and just let the user paste this into the table? and then just query that as per normal?

<script async src="https://www.googletagmanager.com/gtag/js?id=G-12346789sample"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-12346789sampleL');
</script>

How about hard-coding most of it and just replacing the actual tag with dynamic data?

yes, that was the idea… but looking at some of the clients codes… some use old analytics tags… others use other tracking software and need to paste in javascript… as i cannot cater i guess for each tracking software or custom js code… so i guess it will have to be that they can paste in script tags… eish… at least its password protected… and hopefully they will keep it secure…

Done some googling, as this is something we will implement later as well.

I’m not sure what your context is but we will probably use grapesjs as page builder.
This might help you to figure out how they store it in the database: https://stackoverflow.com/questions/64798432/how-to-save-a-page-assembled-using-grapejs-to-a-database-using-asp-net-mvc

Looking at the docs quickly https://grapesjs.com/docs/api/storage_manager.html#load they seem to store it as objects in the database.
So I’m assuming it’s save to do that. But I’m not an expert on this

o well this is what i end up doing ... if you might need to do it in the future.